R in Action reading notes (3)-sixth chapter: Basic graphics

Source: Internet
Author: User

Sixth Chapter Basic Graphics

6.1 Bar Chart

A bar chart shows the distribution (frequency) of category variables by vertical or horizontal bars. Function: Barplot (height)

6.1.1 Simple Bar Chart

6.1.2 Push-Masonry bar and Group bar charts

If the height is a matrix instead of a vector, the drawing result will be a stacked bar chart or a grouped bar chart. If Beside=false (the default), each column in the matrix will generate a bar in the graph, and the values in each column will give the height of the stacked "sub-bar". If beside=true, each column in the matrix represents a grouping, and the values in each column are tied instead of stacked.

6.1.3 Mean bar chart

Bar charts are not necessarily based on count data or frequency data. You can use the data consolidation function and pass the results to the Barplot () function to create a bar chart that represents the mean, median, and standard deviation.

6.1.4 fine-tuning of the bar chart

As the number of bars increases, the labels of the bars may begin to overlap. You can use the parameter cex.names to reduce the font size. Specifying it as a value less than 1 reduces the size of the label. The optional parameter Names.arg allows you to specify a character vector as the label name for the bar. You can also use graphical parameters to assist in adjusting text intervals.

6.1.5 Spine-like chart

Before we end the discussion of bar charts, let's look at a special bar chart called a Spine chart (Spinogram). The spikes are re-scaled for stacked bar charts so that each bar has a height of 1 and the height of each segment is expressed as a scale. A spine chart can be drawn by the function spine () in a VCD package

Library (VCD)

Attach (arthritis)

Counts<-table (treatment,improved)

Spine (counts,main= "spinogaram example")

Detach (Athritis)

6.2 Pie Chart

Pie charts can be created by the following functions: Pie (X,labels)

where x is a nonnegative numeric vector representing the area of each sector, while labels is a character vector that represents each sector label.

R in Action reading notes (3)-sixth chapter: Basic graphics

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.