Description Usage Arguments Details Value Author(s) References See Also Examples
View source: R/ggplot2.customize.R
Customize a graph generated by ggplot2 package
1 |
plot |
A plot object generated with ggplot2 or easyGgplot2 packages (boxplot, densityplot, histogram, dotplot, ....) |
... |
Any argument from the list of the arguments indicated below. |
plot A plot object generated with ggplot2 or easyGgplot2 packages (boxplot, densityplot, histogram, dotplot, ....)
... Any argument from the list of the arguments indicated below. Customize plot title
mainTitle Title of the plot.
mainTitleFont A vector of length 3 indicating respectively the size, the style and the color of main title. Possible values for font style are "plain", "italic", "bold", "bold.italic". Color can be specified as an hexadecimal code (e.g: "#FFCC00") or by the name (e.g : "red", "green"). Default value is: mainTitleFont=c(14, "bold", "black").
Customize x and y axis
xShowTitle, yShowTitleif TRUE, x axis and y axis titles will be shown. Default values are TRUE.
xtitle, ytitlex and y axis labels.
xtitleFont, ytitleFontA vector of length 3 indicating respectively the size, the style and the color of x and y axis titles. Default values are c(14,"bold", "black").
xlim, ylimLimit for the x and y axis. Default values are NULL.
xScale, yScalex and y axis scales. Possible values are c("none", "log2", "log10"). Example: yScale="log2". Default values are "none".
xShowTickLabel, yShowTickLabelif TRUE, x and y axis tick mark labels will be shown. Default values are TRUE.
xTickLabelFont, yTickLabelFontA vector of length 3 indicating respectively the size, the style and the color of x and y axis tick label fonts. Default values are c(12, "bold", "black").
xtickLabelRotation, ytickLabelRotationRotation angle of x and y axis tick labels. Default values are 0.
hideAxisTicksif TRUE, x and y axis ticks are removed. Default value is FALSE.
axisLineA vector of length 3 indicating respectively the size, the line type and the color of axis lines. Default value is c(0.5, "solid", "#E5E5E5").
Customize plot background
removePanelBorderif TRUE, the top-right border of the plot are removed. Default value is FALSE.
removePanelGridif TRUE, panel grids are removed. Default value is FALSE.
backgroundColorbackground color of plot panel. Default value is "gray".
gridColorColor of plot panel grids. Default value is "white".
Customize plot legend
showLegendif TRUE, plot legend will be shown. Default value is TRUE.
legendPositionPosition of legend box. Default value is "right". Possible values for legend position are "right", "left","top", "bottom". LegendPosition can be also a numeric vector c(x, y) indicating the coordinate of legend box. x and y values must be between 0 and 1. c(0,0) corresponds to the "bottom left" and c(1,1) corresponds to the "top right" position.
legendBackgroundA vector of length 4 indicating boxFill, boxLineSize, boxLineType, boxLineColor. Default value is legendBackground=c("#FFFFFF", 0.5, "blank", "black" ).
legendTextFontA vector of length 3 indicating respectively the size, the style and the color of legend text. Default value is c(10, "plain", "black"). Possible values for font style are "plain", "italic", "bold", "bold.italic".
legendTitleFontA vector of length 3 indicating respectively the size, the style and the color of legend title. Default value is c(10, "plain", "black")
legendItemOrderCharacter vector indicating the order of items in the legends. Example: c("2", "1", "0.5")
Faceting : split a plot into a matrix of pannels
facetingif TRUE, the data are split up by one or two variables and graphs are displayed in different panels. In this case, you have to indicate the facetingVarNames. Default value is FALSE.
facetingVarNamesthe names of the columns containing variables to use for faceting. Default value is NULL.
facetingDirectionpossibles values are "vertical" and "horizontal". Default value is vertical. Default value is "vertical".
facetingScales By default, all the panels have the same scale ('facetingScales="fixed"'). They can be made independent, by setting scales to "free", "free_x", or "free_y". Default value is "fixed".
facetingFontChange facet label apperance. A vector of length 3 indicating respectively the size, the font style and the color of the text. Default value is facetingFont=c(size=12, font="plain", color="black").
facetingRectModify the apperance of the rectangle around the facet label.Default value is list(background=NULL, lineType=NULL, lineColor=NULL, lineSize=NULL).
facetingTextAnglesModify the facet label text orientation. It indicates the angles of the x and y texts (in [0, 360]). Default value is c(NULL, NULL).
Others
orientationChange the orientation of the plot. Possible values are c("standard", "horizontal", "yAxisReversed"). Default value is "standard".
a ggplot
Alboukadel Kassambara <alboukadel.kassambara@gmail.com>
http://www.sthda.com
1 2 3 4 5 6 7 8 9 10 11 12 | #data
set.seed(1234)
df <- data.frame(grp = factor( rep(c("A","B"), each=200) ),
var = c(rnorm(200),rnorm(200, mean=.8)))
#use ggplot2.customize to customize the plot
plot<-ggplot2.density(data=df, xName='var',groupName='grp', groupColors=c('#999999','#E69F00'))
print(plot)
plot<-ggplot2.customize(plot, mainTitle="Plot of variable histogram \nper group",
xtitle="Variable", ytitle="Density")
print(plot)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.