Theme() with options to override default - GitHub Pages
Modifying ggplot2 themes
theme() with options to override default
line rect text title aspect.ratio
axis.title axis.title.x axis.title. axis.title.y axis.title.y.right axis.text axis.text.x axis.text. axis.text.y axis.text.y.right axis.ticks axis.ticks.x axis.ticks.y axis.ticks.length axis.line axis.line.x axis.line.y
legend.background legend.margin legend.spacing legend.spacing.x
legend.spacing.y
legend.key legend.key.size legend.key.height legend.key.width legend.text legend.text.align
Overall all line elements (element_line) all rectangular elements (element_rect) all text elements (element_text) all title elements: plot, axes, legends (element_text; inherits from text) aspect ratio of the panel
Axes label of axes (element_text; inherits from text) x axis label (element_text; inherits from axis.title) x axis label on top axis (element_text; inherits from axis.title.x) y axis label (element_text; inherits from axis.title) y axis label on right axis (element_text; inherits from axis.title.y) tick labels along axes (element_text; inherits from text) x axis tick labels (element_text; inherits from axis.text) x axis tick labels on top axis (element_text; inherits from axis.text.x) y axis tick labels (element_text; inherits from axis.text) y axis tick labels on right axis (element_text; inherits from axis.text.y) tick marks along axes (element_line; inherits from line) x axis tick marks (element_line; inherits from axis.ticks) y axis tick marks (element_line; inherits from axis.ticks) length of tick marks (unit) lines along axes (element_line; inherits from line) line along x axis (element_line; inherits from axis.line) line along y axis (element_line; inherits from axis.line)
Legend background of legend (element_rect; inherits from rect) the margin around each legend (margin) the spacing between legends (unit) the horizontal spacing between legends (unit); inherits from legend.spacing the horizontal spacing between legends (unit); inherits from legend.spacing background underneath legend keys (element_rect; inherits from rect) size of legend keys (unit) key background height (unit; inherits from legend.key.size) key background width (unit; inherits from legend.key.size) legend item labels (element_text; inherits from text) alignment of legend labels (number from 0 (left) to 1 (right))
legend.title legend.title.align legend.position
legend.direction legend.justification
legend.box legend.box.just
legend.box.margin legend.box.background legend.box.spacing
panel.background
panel.border
panel.spacing panel.spacing.x
panel.spacing.y panel.grid panel.grid.major panel.grid.minor panel.grid.major.x panel.grid.major.y panel.grid.minor.x panel.grid.minor.y panel.ontop
plot.background plot.title
plot.subtitle
plot.caption
plot.margin
strip.background
title of legend (element_text; inherits from title) alignment of legend title (number from 0 (left) to 1 (right)) the position of legends ("none", "left", "right", "bottom", "top", or twoelement numeric vector) layout of items in legends ("horizontal" or "vertical") anchor point for positioning legend inside plot ("center" or two-element numeric vector) or the justification according to the plot area when positioned outside the plot arrangement of multiple legends ("horizontal" or "vertical") justification of each legend within the overall bounding box, when there are multiple legends ("top", "bottom", "left", or "right") margins around the full legend area, as specified using margin background of legend area (element_rect; inherits from rect) The spacing between the plotting area and the legend box (unit)
Panel background of plotting area, drawn underneath plot (element_rect; inherits from rect) border around plotting area, drawn on top of plot so that it covers tick marks and grid lines. This should be used with fill=NA (element_rect; inherits from rect) spacing between facet panels (unit) horizontal spacing between facet panels (unit; inherits from panel.spacing) vertical spacing between facet panels (unit; inherits from panel.spacing) grid lines (element_line; inherits from line) major grid lines (element_line; inherits from panel.grid) minor grid lines (element_line; inherits from panel.grid) vertical major grid lines (element_line; inherits from panel.grid.major) horizontal major grid lines (element_line; inherits from panel.grid.major) vertical minor grid lines (element_line; inherits from panel.grid.minor) horizontal minor grid lines (element_line; inherits from panel.grid.minor) option to place the panel (background, gridlines) over the data layers. Usually used with a transparent or blank panel.background. (logical)
Plot background of the entire plot (element_rect; inherits from rect) plot title (text appearance) (element_text; inherits from title) left-aligned by default plot subtitle (text appearance) (element_text; inherits from title) leftaligned by default caption below the plot (text appearance) (element_text; inherits from title) right-aligned by default margin around entire plot (unit with the sizes of the top, right, bottom, and left margins)
Strips background of facet labels (element_rect; inherits from rect)
strip.placement strip.text strip.text.x strip.text.y strip.switch.pad.grid strip.switch.pad.wrap ... complete
validate
placement of strip with respect to axes, either "inside" or "outside". Only important when axes and strips are on the same side of the plot. facet labels (element_text; inherits from text)
facet labels along horizontal direction (element_text; inherits from strip.text) facet labels along vertical direction (element_text; inherits from strip.text) space between strips and axes when strips are switched (unit)
space between strips and axes when strips are switched (unit)
Other
additional element specifications not part of base ggplot2. If supplied validate needs to be set to FALSE. set this to TRUE if this is a complete theme, such as the one returned by theme_grey(). Complete themes behave differently when added to a ggplot object. Also, when settingcomplete = TRUE all elements will be set to inherit from blank elements. TRUE to run validate_element, FALSE to bypass checks.
In conjunction with the theme system, the element_ functions specify the display of how nondata components of the plot are a drawn.
? element_blank( ): draws nothing, and assigns no space. ? element_rect( ): borders and backgrounds. ? element_line( ): lines. ? element_text( ): text. ? unit( ): size. for example unit(3, "cm")
Usage
margin(t = 0, r = 0, b = 0, l = 0, unit = "pt")
element_blank()
element_rect(fill = NULL, color = NULL, size = NULL, linetype = NULL, color = NULL, inherit.blank = FALSE)
element_line(color = NULL, size = NULL, linetype = NULL, lineend = NULL, color = NULL, arrow = NULL, inherit.blank = FALSE)
element_text(family = NULL, face = NULL, color = NULL, size = NULL, hjust = NULL, vjust = NULL, angle = NULL, lineheight = NULL, color = NULL, margin = NULL, debug = NULL, inherit.blank = FALSE)
rel(x)
t, r, b, l unit
fill color, color size linetype
inherit.blank
lineend arrow family face hjust vjust angle lineheight margin
debug
x
Dimensions of each margin. (To remember order, think trouble). Default units of dimensions. Defaults to "pt" so it can be most easily scaled with the text. Fill color. Line/border color. Color is an alias for color.
Line/border size in mm; text size in pts. Line type. An integer (0:8), a name (blank, solid, dashed, dotted, dotdash, longdash, twodash), or a string with an even number (up to eight) of hexadecimal digits which give the lengths in consecutive positions in the string. Should this element inherit the existence of an element_blank among its parents? If TRUE the existence of a blank element among its parents will cause this element to be blank as well. If FALSE any blank parent element will be ignored when calculating final element state. Line end Line end style (round, butt, square)
Arrow specification, as created by arrow Font family Font face ("plain", "italic", "bold", "bold.italic") Horizontal justification (in [0, 1]) Vertical justification (in [0, 1]) Angle (in [0, 360])
Line height Margins around the text. See margin for more details. When creating a theme, the margins should be placed on the side of the text facing towards the center of the plot. If TRUE, aids visual debugging by drawing a solid rectangle behind the complete text area, and a point where each label is anchored. A single number specifying size relative to parent element.
Using System Fonts (On Windows)
install.packages("extrafont")
library(extrafont) font_import() # import system fonts ? only supports TrueType fonts
# this can take a while
You may see some warnings, but you should be able to ignore them. After the fonts are imported, you can view the available fonts by running fonts() or fonttable():
fonts() ## [1] "Andale Mono" ## [3] "Arial Black" ## [5] "Arial Narrow" ## [7] "Arial Unicode MS" ## [9] "Brush Script MT" ## [11] "Courier New" ## [13] "Gujarati Sangam MN" ## ...
"AppleMyungjo" "Arial" "Arial Rounded MT Bold" "Bangla Sangam MN" "Comic Sans MS" "Georgia" "Impact"
# This will show more detailed information about fonts fonttable()
# access system fonts # This registers fonts so that they can be used with the pdf, postscript, # or Windows bitmap output device. It must be run once in each R session. loadfonts(device="win") # can be "pdf", "postscript", or "win"
example
ggplot(data=mtcars, aes(x=wt, y=mpg, color=factor(am))) + geom_point() +
facet_wrap(~am) + theme(strip.background=element_rect(fill="skyblue", color="white"), strip.text=element_text(color="white", face="bold", hjust=.1, family="Rockwell"))
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- how to change legend title size in ggplot2 weebly
- three ways to add texts to graphics in proc sgplot sas
- from attribute labels to faces face generation using a conditional
- guide to editing map legends harvard university
- data visualization with ggplot2 cheat sheet bookdown
- visualize tumor response data using ggplot2 r package through examples
- improving a graph using proc gplot and the goptions statement
- data visualization stats and r
- data visualization with ggplot2 cheat sheet
- a ggplot2 primer data action lab
Related searches
- options to viagra
- how to override administrator password
- how to override administrator password win 7
- how to override administrator permissions
- best options to invest money
- best options to buy today
- command to reinstall default apps
- best options to refinance mortgage
- best stock options to buy
- options to invest money
- how to change default display windows 10
- how to change default file opener