As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
+We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
+Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
+Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
+Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
+This Code of Conduct is adapted from the Contributor Covenant (http:contributor-covenant.org), version 1.0.0, available at http://contributor-covenant.org/version/1/0/0/
+YEAR: 2018 +COPYRIGHT HOLDER: Jeffrey Arnold ++ +
Copyright (c) 2018 Jeffrey Arnold
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ggtufte
Package • ggtufteggtufte
Packagevignettes/intro.Rmd
+ intro.Rmd
library("ggplot2")
+library("ggtufte")
+extrafont::loadfonts()
## Registering font with R using pdfFonts(): ETBembo
+
+
+
+ggtufte
: Geoms and theme implementing Tufte’s style in ggplot2The ggtufte package provides ggplot2 theme and geoms inspired by the work of Edward Tufte.
+These functions were formerly contained in the ggthemes package and have been split into their own package.
+NEWS.md
+ ET Book fonts
+ +font_et
+
+ length 5 character vector. Values are the +font names, and names are the description of the font.
+ +ET Book (ETBembo font-family) comprises five fonts:
"ETBembo RomanLF"
: Roman (lining figures)
"ETBembo RomanOSF"
: Roman (oldstyle figures)
"ETBembo SemiBoldOSF"
: Semi-bold (oldstyle figures)
"ETBembo BoldLF"
: Bold (lining figures)
"ETBembo DisplayItalic"
: Display Italic (oldstyle figures)
+font_et#> Roman (line figures) Roman (old-style figures) +#> "ETBembo RomanLF" "ETBembo RomanOSF" +#> Bold (line figures) Semi-bold (old-style figures) +#> "ETBembo BoldLF" "ETBembo SemiBoldOSF" +#> Display italic +#> "ETBembo DisplayItalic"
Axis lines which extend to the maximum and minimum of the plotted data.
+ +geom_rangeframe(mapping = NULL, data = NULL, stat = "identity", + position = "identity", ..., sides = "bl", na.rm = FALSE, + show.legend = NA, inherit.aes = TRUE)+ +
mapping | +Set of aesthetic mappings created by |
+
---|---|
data | +The data to be displayed in this layer. There are three +options: +If A A |
+
stat | +The statistical transformation to use on the data for this +layer, as a string. |
+
position | +Position adjustment, either as a string, or the result of +a call to a position adjustment function. |
+
... | +Other arguments passed on to |
+
sides | +A string that controls which sides of the plot the frames appear on.
+It can be set to a string containing any of |
+
na.rm | +If |
+
show.legend | +logical. Should this layer be included in the legends?
+ |
+
inherit.aes | +If |
+
colour
size
linetype
alpha
Tufte, Edward R. (2001) The Visual Display of +Quantitative Information, Chapter 6.
+ +Other geom tufte: geom_tufteboxplot
+library("ggplot2") +library("extrafont")#>#>
Edward Tufte's revisions of the box plot as described in +The Visual Display of Quantitative Information. +This functions provides several box plot variants:
A point indicating the median, a gap indicating the + interquartile range, and lines for whiskers.
An offset line indicating the interquartile range + and a gap indicating the median.
A line indicating the interquartile range, + a gap indicating the median, and points indicating + the minimum and maximum values
A wide line indicating the interquartile range, + a gap indicating the median, and lines indicating the minimum and + maximum.
geom_tufteboxplot(mapping = NULL, data = NULL, stat = "fivenumber", + position = "dodge", outlier.colour = "black", outlier.shape = 19, + outlier.size = 1.5, outlier.stroke = 0.5, voffset = 0.01, + hoffset = 0.005, na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, + median.type = "point", whisker.type = "line", ...)+ +
mapping | +Set of aesthetic mappings created by |
+
---|---|
data | +The data to be displayed in this layer. There are three +options: +If A A |
+
stat | +The statistical transformation to use on the data for this +layer, as a string. |
+
position | +Position adjustment, either as a string, or the result of +a call to a position adjustment function. |
+
outlier.colour | +colour for outlying points |
+
outlier.shape | +shape of outlying points |
+
outlier.size | +size of outlying points |
+
outlier.stroke | +stroke for outlying points |
+
voffset | +controls the size of the gap in the line representing the
+median when |
+
hoffset | +controls how much the interquartile line is offset from the
+whiskers when |
+
na.rm | +If |
+
show.legend | +logical. Should this layer be included in the legends?
+ |
+
inherit.aes | +If |
+
median.type | +If |
+
whisker.type | +If |
+
... | +Other arguments passed on to |
+
x [required]
y [required]
colour
size
linetype
shape
fill
alpha
Tufte, Edward R. (2001) The Visual Display of +Quantitative Information, Chapter 6.
+McGill, R., Tukey, J. W. and Larsen, W. A. (1978) Variations of +box plots. The American Statistician 32, 12-16.
+ +Other geom tufte: geom_rangeframe
+#>+p <- ggplot(mtcars, aes(factor(cyl), mpg)) +# with a point for the median and lines for whiskers +p + geom_tufteboxplot()# with a line for the interquartile range and points for whiskers +p + geom_tufteboxplot(median.type = "line", whisker.type = "point", hoffset = 0)# with a wide line for the interquartile range and lines for whiskers +p + geom_tufteboxplot(median.type = "line", hoffset = 0, width = 3)#> Warning: position_dodge requires non-overlapping x intervals# with an offset line for the interquartile range and lines for whiskers +p + geom_tufteboxplot(median.type = "line")# combined with theme_tufte +p + geom_tufteboxplot() + + theme_tufte() + + theme(axis.ticks.x = element_blank())
There is an option ggtufte.loadfonts
which -- if set to TRUE
-- will
+call extrafont::loadfonts()
to register non-core fonts with R PDF & PostScript
+devices. If you are running under Windows, the package calls the same function
+to register non-core fonts with the Windows graphics device.
import_et_book()
+
+ https://github.com/edwardtufte/et-book
+ +This will take care of ensuring PDF/PostScript usage. The location of the +font directory is displayed after the base import is complete. It is highly +recommended that you install them on your system the same way you would any +other font you wish to use in other programs.
+ +R/extended_range_breaks.R
+ range_breaks.Rd
This function returns pretty axis breaks that always include the extreme values of the data. +This works by calling the extended Wilkinson algorithm (Talbot et. al, 2010), constrained to solutions interior to the data range. +Then, the minimum and maximum labels are moved to the minimum and maximum of the data range.
+ +extended_range_breaks_(dmin, dmax, n = 5, Q = c(1, 5, 2, 2.5, 4, 3), + w = c(0.25, 0.2, 0.5, 0.05)) + +extended_range_breaks(n = 5, ...)+ +
dmin | +minimum of the data range |
+
---|---|
dmax | +maximum of the data range |
+
n | +desired number of breaks |
+
Q | +set of nice numbers |
+
w | +weights applied to the four optimization components (simplicity, coverage, density, and legibility) |
+
... | +other arguments passed to |
+
For extended_range_breaks
, the vector of axis label locations.
+For scales_extended_range_breaks
, a function which takes a single argument, a vector of data, and returns the vector of axis label locations.
A function which returns breaks given a vector.
+ +extended_range_breaks
implements the algorithm and returns the break values.
+scales_extended_range_breaks
uses the conventions of the scales package, and returns a function.
Talbot, J., Lin, S., Hanrahan, P. (2010) An Extension of Wilkinson's Algorithm for Positioning Tick Labels on Axes, InfoVis 2010.
+ + +R/extended_range_breaks.R
+ smart_digits.Rd
Format numbers with automatic number of digits
+ +smart_digits(x, ...) + +smart_digits_format(x, ...)+ +
x | +A numeric vector to format |
+
---|---|
... | +Parameters passed to |
+
smart_digits
returns a character vector.
+smart_digits_format
returns a function with a single argument x
, a numeric vector, that returns a character vector.
Josh O'Brien, http://stackoverflow.com/questions/23169938/select-accuracy-to-display-additional-axis-breaks/23171858#23171858.
+ + +R/stat-fivenumber.R
+ stat_fivenumber.Rd
The five number summary of a sample is the minimum, first quartile, +median, third quartile, and maximum.
+ +stat_fivenumber(mapping = NULL, data = NULL, geom = "boxplot", qs = c(0, + 0.25, 0.5, 0.75, 1), na.rm = FALSE, position = "identity", + show.legend = NA, inherit.aes = TRUE, ...)+ +
mapping | +Set of aesthetic mappings created by |
+
---|---|
data | +The data to be displayed in this layer. There are three +options: +If A A |
+
geom | +The geometric object to use display the data |
+
qs | +Quantiles to use for the five number summary. |
+
na.rm | +If |
+
position | +Position adjustment, either as a string, or the result of +a call to a position adjustment function. |
+
show.legend | +logical. Should this layer be included in the legends?
+ |
+
inherit.aes | +If |
+
... | +Other arguments passed on to |
+
A data frame with additional columns:
+width of boxplot
minimum
lower hinge, 25% quantile
median, 50% quantile
upper hinge, 75% quantile
maximum
stat_boxplot
Theme based on Chapter 6 'Data-Ink Maximization and Graphical
+Design' of Edward Tufte *The Visual Display of Quantitative
+Information*. No border, no axis lines, no grids. This theme works
+best in combination with geom_rug
or
+geom_rangeframe
.
theme_tufte(base_size = 11, + base_family = extrafont::choose_font(ggtufte::tufte_theme_fonts), + ticks = TRUE)+ +
base_size | +base font size |
+
---|---|
base_family | +base font family |
+
ticks | +
|
+
The default font family is set to 'serif' as he uses serif fonts +for labels in 'The Visual Display of Quantitative Information'. +The serif font used by Tufte in his books is a variant of Bembo, +while the sans serif font is Gill Sans. If these fonts are +installed on your system, then you can use them with the package +extrafont.
+ +Tufte, Edward R. (2001) The Visual Display of +Quantitative Information, Chapter 6.
+ + ++#>+p <- ggplot(mtcars, aes(x = wt, y = mpg)) + + geom_point() + + scale_x_continuous(breaks = extended_range_breaks()(mtcars$wt)) + + scale_y_continuous(breaks = extended_range_breaks()(mtcars$mpg)) + + ggtitle("Cars") + +p + geom_rangeframe() + + theme_tufte()
List of font or font-families to use with theme_tufte
.
+It starts with the preferred ETBembo font used in Tufte's book along with
+fallback options.
tufte_theme_fonts
+
+ A character vector.
+ +This list is derived from the list of fonts used in +https://github.com/edwardtufte/tufte-css
+ + ++tufte_theme_fonts#> [1] "ETBembo RomanLF" "Palatino" "Palatino Linotype" +#> [4] "Palatino LT STD" "Book Antiqua" "Georgia" +#> [7] "serif"