Library (GGPLOT2)############################################## summaryse############################################### Summarizes data.## Gives count, mean, standard deviation, standard error of the mean, and confidence interval (default 95% ). # # DATA:A Data frame.## measurevar:the name of a column that contains the variable to be summariezed## groupvars : A vector containing names of columns that contain grouping variables## Na.rm:a Boolean that
Ggplot2 Scale Related SettingsScale settings: Mainly used to adjust settings for each layer after Ggplot drawing.1. Related attribute scale settingIncludes Scale_size (), Scale_alpha (), Scale_shape ()As you can see from the name above, these three settings are primarily related to the Ggplot layer properties, including size, transparency, and shape.The main parameters for this setting are listed below:SCALE_XXX (name = Waiver (), breaks = waiver (),
After Geom settings and scale settings, to make the picture beautiful, the theme setting is not less thanElement_text () is an important piece of content in the theme settingsElement_text(Family =Null, Face =Null, Colour =Null, size =Null, Hjust =Null, Vjust =Null, Angle =Null, lineheight =Null)Parameter family represents a font styleThe parameter face represents the font format, the desired value ("plain", "italic", "bold", "Bold.italic")Parameter colour indicates font colorParameter size indi
Ggplot2 scale correlation settings-coordinate transformationThere are several forms of axis conversion in R, including logarithmic conversion, square root conversion, and pre-and post-scale exchange of coordinates.The functions used are:SCALE_X_LOG10 (...) SCALE_Y_LOG10 (...) Scale_x_sqrt (...) Scale_y_sqrt (...) Scale_x_reverse (...) Scale_y_reverse (...) The above functions are actually based on scale_x_continuous (name = Waiver (), breaks = Waiver
can choose X or Y, indicate the extension coordinates, start is coordinates start angle, default actually position is 12 o'clock,The direction represents the direction of the data, 1 is clockwise, and 1 is counterclockwise.Let's look at some specific examples:Library (Ggplot2) P The Cartesian coordinate transformation is the same as the normal drawing effect.P+coord_flip () The horizontal and vertical coordinates are interchanged, and a bar chart m
In the process of drawing, sometimes we may need to add some lines, so that the visualization of the graph becomes better, such as some trend lines and so on.Let's take a look at some of the ways the lines are added.Geom_abline (mapping = NULL, data = NULL, ..., slope, intercept, na.rm = FALSE, show.legend = NA) geom_hline (mapping = NULL, data = null, ..., yintercept, na.rm = FALSE, show.legend = NA) geom_vline (mapping = NULL, data = NULL, ..., xintercept, NA . RM = FALSE, show.legend = NA) Th
Introduction
We can also handle the axes of the graph, including x, y-axis swapping, setting axis range, tick mark modification and removal, and so on. In order to play the graphics, axis processing proficiency is indispensable. Axis Swap
We use the Coord_flip () function to swap the axes.
Library (GGPLOT2)
Library (Gcookbook)
Ggplot (Plantgrowth, AES (X=group, Y=weight)) + Geom_boxplot ()
Ggplot (Plantgrowth, AES (X=group, Y=weight)) + geom_boxplot (
Distribution in R should be regarded as a relatively important content, and by drawing to show the distribution of data, you can more intuitively let us understand the distribution of dataHistogramGeom_histogram (mapping = NULL, data = NULL, stat = "bin", Position = "stack", ..., binwidth = null, bins = NULL, NA.RM = F Alse, show.legend = NA, Inherit.aes = TRUE)Density mapgeom_density (mapping = NULL, data = NULL, stat = "density", Position = "identity", ..., na.rm = FALSE, show.legend = na, I N
Introduction
A line chart is generally used to describe a variable of one-dimensional variables as a continuous variable, which is usually time. In other words, a line chart is best suited to describe changes in time series data. Of course, with the change of discrete variables is also possible, but this discrete variable must be ordered. Draw a line chart
A basic line chart is relatively simple, as long as the AES in the Ggplot x,y data and Geom designated as line. If x is a continuous variable
second plot ()function to do the same, but place the graph in the first column and the second row. Because the plot () function starts a new page by default, you need to disable the operation, so set the option NewPage = FALSEUse the position = option to have more control over size and placement:> Plot (graph1,position=c (0,.3,1,1)) > Plot (graph2,position=c (0,0,1,.3), Newpage=false)Position = C (xmin, ymin, Xmax, ymax), the page's X-y coordinate system is a rectangle, the x-axis and y-axis di
Detailed usage of the Qplot () function:Library (GGPLOT2)# test Data set, Ggplot2 built-in diamond dataQplot (carat, price, data = diamonds)Dsmall #1. Visualize by basic classification of Color,size,shape#1.1 Simple scatter plot (using color classification, diamonds of different colors are represented by dots of different colors)Qplot (carat, price, data = dsmall, colour = color)
There are four frameworks for generating graphs, basic graphs, meshes, grids, and Ggplot2 in R.Visualization of categorical data using bar, point, column, spine, treemap, pie, and 40 percent chartsVisualization of continuous data Using box plots, histograms, scatter plots and their variants, Pareto graphs==============================================I. Visualization of categorical data1. Bar ChartThe bar chart can be implemented through the Barplot fu
Turn http://www.cnblogs.com/jiangmiaomiao/p/6991632.html0 IntroductionR supports 4 types of graphics: base graphics, grid graphics, lattice graphics, Ggplot2. Where the Base graphics is the default graphics system for R.1 Basic graphics Functions plot ()The type parameter in the plot () command is used to clarify how the drawing is drawn, using the following type values:
"P" for "points"
"L" for "lines"
"O" for "overlaid" (e.g., lines
% points are taken out of the data.
3. Read data from MySQL
Library (' Rmysql ')
Readdatafrommysql
Drv
Con
Sqlstatement=paste ("Select * from", TableName)
if (nchar (targetdate) >0) {
SQLStatement = Paste (SQLStatement, "where date= '", TargetDate, "'", sep= ')
}
Print (SQLStatement)
Data=dbgetquery (Con, sqlstatement)
Dbdisconnect (Con)
Return (data)
}
* For SQLite or other database can correspond to the transformation.
4. Problem solving
For the 3rd chapter of the header data analysis, the s
Today encountered an exception, the code is as follows:set.seed(12345)require(ggplot2)AData i p # all rightp p # Error: Aesthetics must either be length one, or the same length as the dataProblems:AData下面的代码就ok:example myplot geom_text(aes(label=rownames(example)), size=4.4, hjust=0.5, vjust=-1)根据异常信息,应该是说Glabel与AData的长度不同,但具体什么原因不了解。stackover上面的解释是:对于0.9.0版本的ggplot2有这个问题,0.9.1版本中已经解决。(http://stackoverflow.
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.