[med-svn] [r-cran-ggplot2] 01/04: Imported Upstream version 1.0.0
Benjamin Eikel
benjamin-guest at moszumanska.debian.org
Wed Jun 18 10:17:32 UTC 2014
This is an automated email from the git hooks/post-receive script.
benjamin-guest pushed a commit to branch master
in repository r-cran-ggplot2.
commit 10dffaabdf57153a78ddcd7a7a69c9c0f03bd76b
Author: Benjamin Eikel <debian at eikel.org>
Date: Wed Jun 18 11:56:20 2014 +0200
Imported Upstream version 1.0.0
---
DESCRIPTION | 98 +++--
MD5 | 776 +++++++++++++++++----------------
NAMESPACE | 16 +
NEWS | 150 +++++--
R/aaa-.r | 14 +-
R/aes-calculated.r | 45 ++
R/aes-colour-fill-alpha.r | 18 +-
R/aes-group-order.r | 44 +-
R/aes-linetype-size-shape.r | 28 +-
R/aes-position.r | 48 +-
R/aes.r | 98 +++--
R/annotation-custom.r | 31 +-
R/annotation-map.r | 18 +-
R/annotation-raster.r | 26 +-
R/annotation.r | 30 +-
R/autoplot.r | 2 +-
R/bench.r | 10 +-
R/coord-.r | 32 +-
R/coord-cartesian-.r | 36 +-
R/coord-fixed.r | 6 +-
R/coord-flip.r | 18 +-
R/coord-map.r | 58 +--
R/coord-munch.r | 22 +-
R/coord-polar.r | 90 ++--
R/coord-quickmap.R | 65 +++
R/coord-transform.r | 46 +-
R/facet-.r | 16 +-
R/facet-grid-.r | 138 +++---
R/facet-labels.r | 132 +++++-
R/facet-layout.r | 52 ++-
R/facet-locate.r | 36 +-
R/facet-null.r | 28 +-
R/facet-viewports.r | 20 +-
R/facet-wrap.r | 86 ++--
R/fortify-lm.r | 45 +-
R/fortify-map.r | 27 +-
R/fortify-multcomp.r | 18 +-
R/fortify-spatial.r | 18 +-
R/fortify.r | 14 +-
R/geom-.r | 22 +-
R/geom-abline.r | 30 +-
R/geom-bar-.r | 64 +--
R/geom-bar-histogram.r | 37 +-
R/geom-bin2d.r | 10 +-
R/geom-blank.r | 8 +-
R/geom-boxplot.r | 129 ++++--
R/geom-crossbar.r | 14 +-
R/geom-defaults.r | 8 +-
R/geom-dotplot.r | 40 +-
R/geom-error.r | 36 +-
R/geom-errorh.r | 32 +-
R/geom-freqpoly.r | 12 +-
R/geom-hex.r | 24 +-
R/geom-hline.r | 22 +-
R/geom-linerange.r | 21 +-
R/geom-map.r | 62 +--
R/geom-path-.r | 84 ++--
R/geom-path-contour.r | 8 +-
R/geom-path-density2d.r | 14 +-
R/geom-path-line.r | 38 +-
R/geom-path-step.r | 20 +-
R/geom-point-.r | 78 ++--
R/geom-point-jitter.r | 24 +-
R/geom-pointrange.r | 10 +-
R/geom-polygon.r | 38 +-
R/geom-quantile.r | 8 +-
R/geom-raster.r | 34 +-
R/geom-rect.r | 30 +-
R/geom-ribbon-.r | 46 +-
R/geom-ribbon-density.r | 8 +-
R/geom-rug.r | 12 +-
R/geom-segment.r | 28 +-
R/geom-smooth.r | 32 +-
R/geom-text.r | 40 +-
R/geom-tile.r | 35 +-
R/geom-violin.r | 34 +-
R/geom-vline.r | 26 +-
R/ggplot2.r | 68 +--
R/grob-absolute.r | 26 +-
R/grob-dotstack.r | 11 +-
R/grob-null.r | 24 +-
R/guide-colorbar.r | 70 +--
R/guide-legend.r | 91 ++--
R/guides-.r | 42 +-
R/guides-axis.r | 18 +-
R/guides-grid.r | 10 +-
R/labels.r | 12 +-
R/layer.r | 123 +++---
R/limits.r | 49 ++-
R/matrix.r | 48 --
R/panel.r | 71 ++-
R/plot-build.r | 30 +-
R/plot-construction.r | 10 +-
R/plot-last.r | 6 +-
R/plot-render.r | 52 ++-
R/plot.r | 42 +-
R/position-.r | 12 +-
R/position-collide.r | 39 +-
R/position-dodge.r | 14 +-
R/position-fill.r | 14 +-
R/position-identity.r | 2 +-
R/position-jitter.r | 20 +-
R/position-jitterdodge.R | 87 ++++
R/position-stack.r | 22 +-
R/quick-plot.r | 1 +
R/save.r | 52 +--
R/scale-.r | 198 +++++----
R/scale-alpha.r | 6 +-
R/scale-area.r | 4 +-
R/scale-brewer.r | 83 +++-
R/scale-continuous.r | 22 +-
R/scale-date.r | 40 +-
R/scale-datetime.r | 24 +-
R/scale-discrete-.r | 58 +--
R/scale-gradient.r | 18 +-
R/scale-gradient2.r | 27 +-
R/scale-gradientn.r | 22 +-
R/scale-grey.r | 10 +-
R/scale-hue.r | 16 +-
R/scale-identity.r | 22 +-
R/scale-linetype.r | 8 +-
R/scale-manual.r | 10 +-
R/scale-shape.r | 14 +-
R/scale-size.r | 16 +-
R/scales-.r | 57 +--
R/stat-.r | 28 +-
R/stat-bin.r | 58 +--
R/stat-bin2d.r | 48 +-
R/stat-bindot.r | 16 +-
R/stat-binhex.r | 48 +-
R/stat-boxplot.r | 37 +-
R/stat-contour.r | 38 +-
R/stat-density-2d.r | 36 +-
R/stat-density.r | 56 +--
R/stat-ecdf.r | 8 +-
R/stat-ellipse.R | 102 +++++
R/stat-function.r | 24 +-
R/stat-identity.r | 14 +-
R/stat-qq.r | 34 +-
R/stat-quantile.r | 40 +-
R/stat-smooth-methods.r | 24 +-
R/stat-smooth.r | 100 ++---
R/stat-spoke.r | 10 +-
R/stat-sum.r | 22 +-
R/stat-summary-2d.r | 22 +-
R/stat-summary-hex.r | 34 +-
R/stat-summary.r | 112 ++---
R/stat-unique.r | 12 +-
R/stat-vline.r | 38 +-
R/stat-ydensity.r | 4 +-
R/summary.r | 16 +-
R/templates.r | 211 ++-------
R/theme-defaults.r | 118 ++++-
R/theme-elements.r | 44 +-
R/theme.r | 60 +--
R/translate-qplot-base.r | 56 +--
R/translate-qplot-ggplot.r | 30 +-
R/translate-qplot-gpl.r | 14 +-
R/translate-qplot-lattice.r | 14 +-
R/utilities-break.r | 10 +-
R/utilities-grid.r | 6 +-
R/utilities-layer.r | 12 +-
R/utilities-matrix.r | 48 +-
R/utilities-resolution.r | 8 +-
R/utilities-table.r | 6 +-
R/utilities.r | 54 +--
R/xxx-digest.r | 14 +-
R/zxx.r | 4 +
R/zzz.r | 8 +-
README.md | 19 +-
build/partial.rdb | Bin 157469 -> 148046 bytes
build/vignette.rds | Bin 0 -> 245 bytes
inst/doc/development.R | 18 +
inst/doc/development.Rmd | 263 +++++++++++
inst/doc/development.html | 435 ++++++++++++++++++
inst/doc/release.R | 10 +
inst/doc/release.Rmd | 107 +++++
inst/doc/release.html | 243 +++++++++++
inst/staticdocs/README.md | 0
inst/staticdocs/icons.R | 422 ++++++++++++++++++
inst/staticdocs/index.r | 775 ++++++++++----------------------
inst/test_ns/R/my-plot.r | 4 +-
inst/tests/helper-plot-data.r | 14 +-
inst/tests/test-aes-grouping.r | 10 +-
inst/tests/test-aes-setting.r | 10 +-
inst/tests/test-aes.r | 10 +-
inst/tests/test-build.r | 16 +-
inst/tests/test-data.r | 2 +-
inst/tests/test-facet-.r | 18 +-
inst/tests/test-facet-layout.r | 32 +-
inst/tests/test-facet-locate.r | 26 +-
inst/tests/test-fortify.r | 6 +-
inst/tests/test-layer.r | 18 +
inst/tests/test-qplot.r | 6 +-
inst/tests/test-scale-manual.r | 16 +-
inst/tests/test-scales-breaks-labels.r | 90 ++--
inst/tests/test-scales.r | 56 +--
inst/tests/test-stats.r | 54 +--
man/absoluteGrob.Rd | 9 +-
man/add_theme.Rd | 16 +-
man/aes.Rd | 30 +-
man/aes_all.Rd | 8 +-
man/aes_auto.Rd | 9 +-
man/aes_colour_fill_alpha.Rd | 5 +-
man/aes_group_order.Rd | 3 +-
man/aes_linetype_size_shape.Rd | 5 +-
man/aes_position.Rd | 23 +-
man/aes_string.Rd | 40 +-
man/annotate.Rd | 34 +-
man/annotation_custom.Rd | 42 +-
man/annotation_logticks.Rd | 65 ++-
man/annotation_map.Rd | 12 +-
man/annotation_raster.Rd | 30 +-
man/autoplot.Rd | 19 +-
man/benchplot.Rd | 9 +-
man/borders.Rd | 21 +-
man/calc_element.Rd | 14 +-
man/continuous_scale.Rd | 98 ++---
man/coord.Rd | 7 +-
man/coord_cartesian.Rd | 18 +-
man/coord_expand_defaults.Rd | 5 +-
man/coord_fixed.Rd | 29 +-
man/coord_flip.Rd | 13 +-
man/coord_map.Rd | 37 +-
man/coord_polar.Rd | 16 +-
man/coord_quickmap.Rd | 51 +++
man/coord_trans.Rd | 26 +-
man/cut_interval.Rd | 16 +-
man/cut_number.Rd | 15 +-
man/cweave.Rd | 9 +-
man/diamonds.Rd | 31 +-
man/discrete_scale.Rd | 105 +++--
man/economics.Rd | 29 +-
man/element_blank.Rd | 7 +-
man/element_line.Rd | 17 +-
man/element_rect.Rd | 17 +-
man/element_text.Rd | 28 +-
man/expand_limits.Rd | 12 +-
man/facet.Rd | 11 +-
man/facet_grid.Rd | 97 ++---
man/facet_null.Rd | 11 +-
man/facet_wrap.Rd | 41 +-
man/fortify-multcomp.Rd | 19 +-
man/fortify.Rd | 19 +-
man/fortify.lm.Rd | 28 +-
man/fortify.map.Rd | 15 +-
man/fortify.sp.Rd | 30 +-
man/geom_abline.Rd | 66 ++-
man/geom_area.Rd | 55 ++-
man/geom_bar.Rd | 114 +++--
man/geom_bin2d.Rd | 37 +-
man/geom_blank.Rd | 35 +-
man/geom_boxplot.Rd | 122 +++---
man/geom_contour.Rd | 54 ++-
man/geom_crossbar.Rd | 51 +--
man/geom_density.Rd | 46 +-
man/geom_density2d.Rd | 61 ++-
man/geom_dotplot.Rd | 155 +++----
man/geom_errorbar.Rd | 49 +--
man/geom_errorbarh.Rd | 39 +-
man/geom_freqpoly.Rd | 39 +-
man/geom_hex.Rd | 37 +-
man/geom_histogram.Rd | 50 +--
man/geom_hline.Rd | 62 ++-
man/geom_jitter.Rd | 58 ++-
man/geom_line.Rd | 43 +-
man/geom_linerange.Rd | 52 ++-
man/geom_map.Rd | 51 ++-
man/geom_path.Rd | 61 ++-
man/geom_point.Rd | 96 ++--
man/geom_pointrange.Rd | 49 +--
man/geom_polygon.Rd | 42 +-
man/geom_quantile.Rd | 55 ++-
man/geom_raster.Rd | 64 ++-
man/geom_rect.Rd | 37 +-
man/geom_ribbon.Rd | 49 +--
man/geom_rug.Rd | 44 +-
man/geom_segment.Rd | 59 ++-
man/geom_smooth.Rd | 43 +-
man/geom_step.Rd | 41 +-
man/geom_text.Rd | 41 +-
man/geom_tile.Rd | 41 +-
man/geom_violin.Rd | 50 +--
man/geom_vline.Rd | 62 ++-
man/gg-add.Rd | 61 ++-
man/gg_dep.Rd | 42 +-
man/ggfluctuation.Rd | 41 --
man/ggmissing.Rd | 40 --
man/ggorder.Rd | 14 -
man/ggpcp.Rd | 39 --
man/ggplot.Rd | 71 +--
man/ggplot.data.frame.Rd | 21 +-
man/ggplot2.Rd | 3 +-
man/ggplotGrob.Rd | 7 +-
man/ggplot_build.Rd | 21 +-
man/ggplot_gtable.Rd | 28 +-
man/ggsave.Rd | 72 ++-
man/ggscale.Rd | 30 +-
man/ggstructure.Rd | 19 -
man/ggtheme.Rd | 77 ++++
man/guide_colourbar.Rd | 181 ++++----
man/guide_legend.Rd | 142 +++---
man/guides.Rd | 16 +-
man/hmisc.Rd | 23 +-
man/interleave.Rd | 8 +-
man/is.coord.Rd | 5 +-
man/is.facet.Rd | 7 +-
man/is.ggplot.Rd | 7 +-
man/is.rel.Rd | 7 +-
man/is.theme.Rd | 7 +-
man/label_both.Rd | 13 +-
man/label_bquote.Rd | 15 +-
man/label_parsed.Rd | 15 +-
man/label_value.Rd | 15 +-
man/label_wrap_gen.Rd | 17 +
man/labeller.Rd | 74 ++++
man/labs.Rd | 16 +-
man/last_plot.Rd | 7 +-
man/layer.Rd | 5 +-
man/limits.Rd | 9 +-
man/map_data.Rd | 30 +-
man/mean_se.Rd | 11 +-
man/midwest.Rd | 54 ++-
man/movies.Rd | 47 +-
man/mpg.Rd | 32 +-
man/msleep.Rd | 38 +-
man/opts.Rd | 9 +-
man/plot-templates.Rd | 31 ++
man/plotmatrix.Rd | 23 -
man/position_dodge.Rd | 20 +-
man/position_fill.Rd | 26 +-
man/position_identity.Rd | 20 +-
man/position_jitter.Rd | 20 +-
man/position_jitterdodge.Rd | 36 ++
man/position_stack.Rd | 20 +-
man/presidential.Rd | 9 +-
man/print.ggplot.Rd | 17 +-
man/qplot.Rd | 76 ++--
man/rel.Rd | 7 +-
man/resolution.Rd | 19 +-
man/rweave.Rd | 9 +-
man/scale_alpha.Rd | 22 +-
man/scale_area.Rd | 21 +-
man/scale_brewer.Rd | 115 +++--
man/scale_continuous.Rd | 42 +-
man/scale_date.Rd | 58 ++-
man/scale_datetime.Rd | 57 ++-
man/scale_discrete.Rd | 43 +-
man/scale_gradient.Rd | 92 ++--
man/scale_gradient2.Rd | 90 ++--
man/scale_gradientn.Rd | 78 ++--
man/scale_grey.Rd | 56 +--
man/scale_hue.Rd | 74 ++--
man/scale_identity.Rd | 25 +-
man/scale_linetype.Rd | 23 +-
man/scale_manual.Rd | 35 +-
man/scale_shape.Rd | 19 +-
man/scale_size.Rd | 27 +-
man/scale_size_area.Rd | 22 +-
man/seals.Rd | 19 +-
man/should_stop.Rd | 7 +-
man/stat_abline.Rd | 33 +-
man/stat_bin.Rd | 70 ++-
man/stat_bin2d.Rd | 45 +-
man/stat_bindot.Rd | 107 +++--
man/stat_binhex.Rd | 46 +-
man/stat_boxplot.Rd | 65 ++-
man/stat_contour.Rd | 44 +-
man/stat_density.Rd | 66 ++-
man/stat_density2d.Rd | 46 +-
man/stat_ecdf.Rd | 38 +-
man/stat_ellipse.Rd | 74 ++++
man/stat_function.Rd | 55 ++-
man/stat_hline.Rd | 33 +-
man/stat_identity.Rd | 40 +-
man/stat_qq.Rd | 45 +-
man/stat_quantile.Rd | 55 ++-
man/stat_smooth.Rd | 96 ++--
man/stat_spoke.Rd | 41 +-
man/stat_sum.Rd | 46 +-
man/stat_summary.Rd | 89 ++--
man/stat_summary2d.Rd | 58 ++-
man/stat_summary_hex.Rd | 59 ++-
man/stat_unique.Rd | 35 +-
man/stat_vline.Rd | 33 +-
man/stat_ydensity.Rd | 82 ++--
man/summary.ggplot.Rd | 10 +-
man/theme.Rd | 271 ++++++------
man/theme_blank.Rd | 19 +-
man/theme_bw.Rd | 15 -
man/theme_classic.Rd | 16 -
man/theme_grey.Rd | 16 -
man/theme_minimal.Rd | 15 -
man/theme_update.Rd | 18 +-
man/translate_qplot_base.Rd | 14 +-
man/translate_qplot_ggplot.Rd | 14 +-
man/translate_qplot_gpl.Rd | 6 +-
man/translate_qplot_lattice.Rd | 8 +-
man/update_defaults.Rd | 11 +-
man/update_element.Rd | 17 +-
man/update_labels.Rd | 9 +-
man/waiver.Rd | 13 +-
man/xylim.Rd | 24 +-
man/zeroGrob.Rd | 5 +-
vignettes/development.Rmd | 263 +++++++++++
vignettes/release.Rmd | 107 +++++
406 files changed, 10084 insertions(+), 7975 deletions(-)
diff --git a/DESCRIPTION b/DESCRIPTION
index e912ffc..23d94cf 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,41 +1,48 @@
Package: ggplot2
Type: Package
Title: An implementation of the Grammar of Graphics
-Version: 0.9.3.1
-Author: Hadley Wickham <h.wickham at gmail.com>, Winston Chang
- <winston at stdout.org>
+Version: 1.0.0
+Author: Hadley Wickham <h.wickham at gmail.com>, Winston Chang <winston at stdout.org>
Maintainer: Hadley Wickham <h.wickham at gmail.com>
-Description: An implementation of the grammar of graphics in R. It
- combines the advantages of both base and lattice graphics:
- conditioning and shared axes are handled automatically, and you
- can still build up a plot step by step from multiple data
- sources. It also implements a sophisticated multidimensional
- conditioning system and a consistent interface to map data to
- aesthetic attributes. See the ggplot2 website for more
- information, documentation and examples.
+Description: An implementation of the grammar of graphics
+ in R. It combines the advantages of both base and
+ lattice graphics: conditioning and shared axes are
+ handled automatically, and you can still build up a
+ plot step by step from multiple data sources. It also
+ implements a sophisticated multidimensional
+ conditioning system and a consistent interface to map
+ data to aesthetic attributes. See the ggplot2 website
+ for more information, documentation and examples.
Depends: R (>= 2.14), stats, methods
Imports: plyr (>= 1.7.1), digest, grid, gtable (>= 0.1.1), reshape2,
scales (>= 0.2.3), proto, MASS
Suggests: quantreg, Hmisc, mapproj, maps, hexbin, maptools, multcomp,
- nlme, testthat
+ nlme, testthat, knitr, mgcv
+VignetteBuilder: knitr
Enhances: sp
License: GPL-2
-URL: http://had.co.nz/ggplot2/
+URL: http://ggplot2.org, https://github.com/hadley/ggplot2
+BugReports: https://github.com/hadley/ggplot2/issues
LazyData: true
-Collate: 'aaa-.r' 'aaa-constants.r' 'aes-colour-fill-alpha.r'
- 'aes-linetype-size-shape.r' 'aes.r' 'annotation.r' 'bench.r'
+Collate: 'aaa-.r' 'aaa-constants.r' 'aes-calculated.r'
+ 'aes-colour-fill-alpha.r' 'aes-group-order.r'
+ 'aes-linetype-size-shape.r' 'aes-position.r' 'aes.r' 'geom-.r'
+ 'annotation-custom.r' 'annotation-logticks.r' 'geom-polygon.r'
+ 'geom-map.r' 'annotation-map.r' 'geom-raster.r'
+ 'annotation-raster.r' 'annotation.r' 'autoplot.r' 'bench.r'
'coord-.r' 'coord-cartesian-.r' 'coord-fixed.r' 'coord-flip.r'
'coord-map.r' 'coord-munch.r' 'coord-polar.r'
- 'coord-transform.r' 'facet-.r' 'facet-grid-.r' 'facet-labels.r'
- 'facet-layout.r' 'facet-locate.r' 'facet-null.r'
- 'facet-viewports.r' 'facet-wrap.r' 'fortify-lm.r'
- 'fortify-map.r' 'fortify-spatial.r' 'fortify.r' 'geom-.r'
+ 'coord-quickmap.R' 'coord-transform.r' 'facet-.r'
+ 'facet-grid-.r' 'facet-labels.r' 'facet-layout.r'
+ 'facet-locate.r' 'facet-null.r' 'facet-viewports.r'
+ 'facet-wrap.r' 'fortify-lm.r' 'fortify-map.r'
+ 'fortify-multcomp.r' 'fortify-spatial.r' 'fortify.r'
'geom-abline.r' 'geom-bar-.r' 'geom-bar-histogram.r'
'geom-bin2d.r' 'geom-blank.r' 'geom-boxplot.r'
'geom-crossbar.r' 'geom-defaults.r' 'geom-dotplot.r'
'geom-error.r' 'geom-errorh.r' 'geom-freqpoly.r' 'geom-hex.r'
- 'geom-hline.r' 'geom-linerange.r' 'geom-polygon.r' 'geom-map.r'
- 'geom-path-.r' 'geom-path-contour.r' 'geom-path-density2d.r'
+ 'geom-hline.r' 'geom-linerange.r' 'geom-path-.r'
+ 'geom-path-contour.r' 'geom-path-density2d.r'
'geom-path-line.r' 'geom-path-step.r' 'geom-point-.r'
'geom-point-jitter.r' 'geom-pointrange.r' 'geom-quantile.r'
'geom-rect.r' 'geom-ribbon-.r' 'geom-ribbon-density.r'
@@ -43,35 +50,34 @@ Collate: 'aaa-.r' 'aaa-constants.r' 'aes-colour-fill-alpha.r'
'geom-tile.r' 'geom-violin.r' 'geom-vline.r' 'ggplot2.r'
'grob-absolute.r' 'grob-dotstack.r' 'grob-null.r'
'guide-colorbar.r' 'guide-legend.r' 'guides-.r' 'guides-axis.r'
- 'guides-grid.r' 'labels.r' 'layer.r' 'limits.r' 'matrix.r'
- 'panel.r' 'plot-build.r' 'plot-construction.r' 'plot-last.r'
+ 'guides-grid.r' 'labels.r' 'layer.r' 'limits.r' 'panel.r'
+ 'plot-build.r' 'plot-construction.r' 'plot-last.r'
'plot-render.r' 'plot.r' 'position-.r' 'position-collide.r'
'position-dodge.r' 'position-fill.r' 'position-identity.r'
- 'position-jitter.r' 'position-stack.r' 'quick-plot.r' 'save.r'
- 'scale-.r' 'scale-alpha.r' 'scale-area.r' 'scale-brewer.r'
- 'scale-continuous.r' 'scale-date.r' 'scale-datetime.r'
- 'scale-discrete-.r' 'scale-gradient.r' 'scale-gradient2.r'
- 'scale-gradientn.r' 'scale-grey.r' 'scale-hue.r'
- 'scale-identity.r' 'scale-linetype.r' 'scale-manual.r'
- 'scale-shape.r' 'scale-size.r' 'scales-.r' 'stat-.r'
- 'stat-summary-2d.r' 'stat-summary-hex.r' 'stat-bin.r'
- 'stat-bin2d.r' 'stat-binhex.r' 'stat-boxplot.r'
+ 'position-jitter.r' 'position-jitterdodge.R' 'position-stack.r'
+ 'quick-plot.r' 'save.r' 'scale-.r' 'scale-alpha.r'
+ 'scale-area.r' 'scale-brewer.r' 'scale-continuous.r'
+ 'scale-date.r' 'scale-datetime.r' 'scale-discrete-.r'
+ 'scale-gradient.r' 'scale-gradient2.r' 'scale-gradientn.r'
+ 'scale-grey.r' 'scale-hue.r' 'scale-identity.r'
+ 'scale-linetype.r' 'scale-manual.r' 'scale-shape.r'
+ 'scale-size.r' 'scales-.r' 'stat-.r' 'stat-bin.r'
+ 'stat-bin2d.r' 'stat-bindot.r' 'stat-binhex.r' 'stat-boxplot.r'
'stat-contour.r' 'stat-density-2d.r' 'stat-density.r'
- 'stat-bindot.r' 'stat-function.r' 'stat-identity.r' 'stat-qq.r'
- 'stat-quantile.r' 'stat-smooth-methods.r' 'stat-smooth.r'
- 'stat-spoke.r' 'stat-sum.r' 'stat-summary.r' 'stat-unique.r'
- 'stat-vline.r' 'stat-ydensity.r' 'stat-ecdf.r' 'summary.r'
- 'templates.r' 'theme-defaults.r' 'theme-elements.r' 'theme.r'
- 'utilities-break.r' 'utilities-grid.r' 'utilities-layer.r'
+ 'stat-ecdf.r' 'stat-ellipse.R' 'stat-function.r'
+ 'stat-identity.r' 'stat-qq.r' 'stat-quantile.r'
+ 'stat-smooth-methods.r' 'stat-smooth.r' 'stat-spoke.r'
+ 'stat-sum.r' 'stat-summary-2d.r' 'stat-summary-hex.r'
+ 'stat-summary.r' 'stat-unique.r' 'stat-vline.r'
+ 'stat-ydensity.r' 'summary.r' 'templates.r' 'theme-defaults.r'
+ 'theme-elements.r' 'theme.r' 'translate-qplot-base.r'
+ 'translate-qplot-ggplot.r' 'translate-qplot-gpl.r'
+ 'translate-qplot-lattice.r' 'utilities-break.r'
+ 'utilities-grid.r' 'utilities-help.r' 'utilities-layer.r'
'utilities-matrix.r' 'utilities-resolution.r'
'utilities-table.r' 'utilities.r' 'xxx-digest.r' 'zxx.r'
- 'geom-raster.r' 'annotation-raster.r' 'annotation-map.r'
- 'autoplot.r' 'zzz.r' 'fortify-multcomp.r' 'annotation-custom.r'
- 'aes-group-order.r' 'aes-position.r' 'translate-qplot-base.r'
- 'translate-qplot-ggplot.r' 'translate-qplot-gpl.r'
- 'translate-qplot-lattice.r' 'annotation-logticks.r'
- 'utilities-help.r'
-Packaged: 2013-03-01 17:44:46 UTC; ubuntu
+ 'zzz.r'
+Packaged: 2014-05-20 22:12:23 UTC; hadley
NeedsCompilation: no
Repository: CRAN
-Date/Publication: 2013-03-02 15:56:56
+Date/Publication: 2014-05-21 15:36:28
diff --git a/MD5 b/MD5
index f5b3ac5..e4ed439 100644
--- a/MD5
+++ b/MD5
@@ -1,172 +1,176 @@
-a8481dde4e6366e1c98c38e25a60ce09 *DESCRIPTION
-b0e2c27896c6311e1e8a06f1406d75e0 *NAMESPACE
-8298f7bc3ec5ab60baac889eb6c831d6 *NEWS
-cdc165b0b74d5b1cfd879769181ec510 *R/aaa-.r
+5c89ce3b925a20918e40ba750fe50685 *DESCRIPTION
+04e7f17188c0ab22a4c6c7f1f0175920 *NAMESPACE
+04d175a8b4adf715c0b588b38f9dd4c9 *NEWS
+f619b0ed74903b4c2418c5c6e46e370c *R/aaa-.r
dc3d3aab5c3802286ba7ad449eb6645d *R/aaa-constants.r
-ae3f1d04a847f7593b3bf8836667104f *R/aes-colour-fill-alpha.r
-821d0759319d37cfb974286a280c9ac5 *R/aes-group-order.r
-733c7a9a947c30697e3ddb85ab08d944 *R/aes-linetype-size-shape.r
-26e076e6333d7400c1603faa7781c1c1 *R/aes-position.r
-2f5636b06947da866e2de3206fcf8ab0 *R/aes.r
-ec76f496165349653ce58dda55ab4060 *R/annotation-custom.r
+437908a74682d578f7eb223c8ed863ba *R/aes-calculated.r
+334f021337c8c344810d57a74b0be07a *R/aes-colour-fill-alpha.r
+173e513577570948eb00a5ac883358f6 *R/aes-group-order.r
+cd3be935c62fff91d804b5de7b617082 *R/aes-linetype-size-shape.r
+db5b22d2da805d40e1b3d3314d259f22 *R/aes-position.r
+418cbbe4cd2fa4705ea9f19dd230e310 *R/aes.r
+003e6a9360721c43535526a5880514ce *R/annotation-custom.r
466f11d4b6932c2743166c594db6eae6 *R/annotation-logticks.r
-b980276fc6b0634c3b43a20f0a2e2061 *R/annotation-map.r
-fc7ae95535ec205a2fe554f0e0ef22f0 *R/annotation-raster.r
-96bee574f5054fc0fbf55ebaa76cabc1 *R/annotation.r
-156e572d485fde7adbff14cf0c05ce0b *R/autoplot.r
-62aaf848259fcb7f4b350ff67acb990f *R/bench.r
-730026efd522ee584c63c4575f6e2b51 *R/coord-.r
-ab13bd1bc481f073ed166080817ea44a *R/coord-cartesian-.r
-16feb9d43c4d09600f9dbd700fe50a2f *R/coord-fixed.r
-cc9622bcbc7ab527f537ffec6e7088b3 *R/coord-flip.r
-27cd6c317dd6caceb6acc53837f9ede9 *R/coord-map.r
-3da104d697aaff354286c05f24c0b0c3 *R/coord-munch.r
-ca4435bb4a62eb3c56dc4da7e86e49fb *R/coord-polar.r
-6cad54068e3731a1c83fcf18e31efb64 *R/coord-transform.r
-46888370c9fc6579da7e7b0879c5ab19 *R/facet-.r
-9b7abe1dfbfdd87ebe4ccbb9ddd05737 *R/facet-grid-.r
-6582f033d70914a7ff8a34adfc8a00d4 *R/facet-labels.r
-a8bdd31838cc1dc8553493e9ca3edca8 *R/facet-layout.r
-c1b757c44b4b7fb483b51396cb032000 *R/facet-locate.r
-1534b4f9dae20090e0ddc7364bc72fca *R/facet-null.r
-ec37671843792b0e848e43cd5d117737 *R/facet-viewports.r
-afff0480da1871dd98227f22a1f4d0de *R/facet-wrap.r
-b5ea8f828872428e2cd545b6a2bcaa9d *R/fortify-lm.r
-eb936fc87c719c92e4cd00d2e0d3db9e *R/fortify-map.r
-0781a7193e77311d3652c0a26e3ace8a *R/fortify-multcomp.r
-d698473b30629cf5c2a1b4fe8fcc239d *R/fortify-spatial.r
-c66a8210303d12e2fd9ae738de3c80be *R/fortify.r
-84d3db481f87ff9d8a356fc70455edf7 *R/geom-.r
-5ac2256187aa8389e25ced8c3654df79 *R/geom-abline.r
-5f3535690fd257e85fc9830fedd98cf2 *R/geom-bar-.r
-f6aabd443b95a624eeef95d10cb9a4e5 *R/geom-bar-histogram.r
-f8834f3ae2b4dd73fb2f458ca386845f *R/geom-bin2d.r
-6f93f7e8856b4e8f693ef36f74b2d6af *R/geom-blank.r
-b7b1ba7b38b750c778b5b4d9dd60f7b6 *R/geom-boxplot.r
-f89f62a4771b8235486a721e4f7edf91 *R/geom-crossbar.r
-bbb969602ad4726f07b8f47e0e045f8f *R/geom-defaults.r
-48520da055a141e0f40c272f660d03b0 *R/geom-dotplot.r
-3427bab8fe3b8b62dc8099eed3593906 *R/geom-error.r
-19bd1eb401094ce7f5be89e63650e82c *R/geom-errorh.r
-9363f7e61c12375012710cac58c089cb *R/geom-freqpoly.r
-5d2de1907f582a3480deff97a961bde9 *R/geom-hex.r
-945f11becbafd976228fd1bb7b7955a2 *R/geom-hline.r
-a89b8b5600e9d6fd98e5bdcd90b160de *R/geom-linerange.r
-6897f36f55964f8286be02137e206e47 *R/geom-map.r
-e3950aa2d3c3e922400efceca8a06dd7 *R/geom-path-.r
-bf878d11dcb897ecef17541ea8a046bb *R/geom-path-contour.r
-60e9c5e5b491d45ec0c3ab8181b1aff9 *R/geom-path-density2d.r
-2dc4ab51b3c59edf1ce6a80ad242a6bd *R/geom-path-line.r
-51e68049a1070d460097551d9c5458d6 *R/geom-path-step.r
-ac048bc7f2741bd1cbbba7581af94dee *R/geom-point-.r
-818ff3f54e006d46812a34aa8dac1160 *R/geom-point-jitter.r
-c4ff344620a297654ad59fb89628818e *R/geom-pointrange.r
-4b3b8102b51f97ac79f3f5b5c2c25836 *R/geom-polygon.r
-bbbdea8f534809cf26b586c011d7c5ff *R/geom-quantile.r
-15434417882afed1b3abddce75047c12 *R/geom-raster.r
-01b8f2a9a51200c853ccd77e270ed66d *R/geom-rect.r
-b364e888a1e006ad4ea8096c02b4cd99 *R/geom-ribbon-.r
-56d9a7db16135a425fd37c1e7bfe4380 *R/geom-ribbon-density.r
-609ff55cb6571c4c706ecb9a9df1e0e8 *R/geom-rug.r
-e6c3d0257b133b328f14f6c66235f580 *R/geom-segment.r
-06ee79739ea7568fc7fa409d8c525fea *R/geom-smooth.r
-f13c34536947ff33c9e059f6fb44c7df *R/geom-text.r
-7a312bb3081a867fcd3078491b80a3d1 *R/geom-tile.r
-89fd74daef645c5aec59ba89d97f6193 *R/geom-violin.r
-fbc31911c59baaddc2fa915f75914ff6 *R/geom-vline.r
-c4bf756d21c84a8542fd6071de4e98e8 *R/ggplot2.r
-a16f5e7db9df6da53fa0b73fd9ea6dc7 *R/grob-absolute.r
-59073fb400325d5aacec56c908a62be5 *R/grob-dotstack.r
-a95eedcd254245038c02583eca451496 *R/grob-null.r
-6b4b5ebf999737e4788193fc421604f4 *R/guide-colorbar.r
-32bcfddd0d4f788b9558de374cced279 *R/guide-legend.r
-d97690d6d583e86f025be2a9429605d1 *R/guides-.r
-3af4e324ffbb2bf024d90a4d98f9580e *R/guides-axis.r
-ba942d2a3cac6427ad5e432d6344deec *R/guides-grid.r
-c78cf3ebdfe741464530b1fd74979fcc *R/labels.r
-55b65267b558cbff7ae87c8200c5b1a3 *R/layer.r
-b8dc88ca7b246c1f856d97ad0dbc5894 *R/limits.r
-2563cc48c409528da1a632c30d35c992 *R/matrix.r
-507e7f65ffa6ab71f3f36015e3ffa773 *R/panel.r
-b08a2294565e0155be791f0394db953a *R/plot-build.r
-a9d6f62b2221cf9aee7342c5a5d8abd7 *R/plot-construction.r
-1fe2bd58d7d34c6370ec8680bac55641 *R/plot-last.r
-d44ed7cee7180f23e30d7bfb43b68557 *R/plot-render.r
-898fa70042b03446748daa7d2ad1b7a9 *R/plot.r
-25eecd71bdbda3dd0357f17bd40ddea6 *R/position-.r
-b9725a3356cd9ad7d603ae630a7b2da9 *R/position-collide.r
-3b6c1ad7cf9ab5cb52328fc2c04d330a *R/position-dodge.r
-bae3978e0f907c21e26dc4aa2c929fb4 *R/position-fill.r
-5f0742181315d120ef24343cc7e89915 *R/position-identity.r
-fd316941e9fd8eb8537c579a3302df6d *R/position-jitter.r
-87c45a8daeb86d8e415f125f763636ac *R/position-stack.r
-49f635097439d8aeea4407e786796d88 *R/quick-plot.r
-a50cf57f38afabcd774b149b6b63bc83 *R/save.r
-aa677b621332bcbf01407ca5229dadfc *R/scale-.r
-0b94bc43c9a1f19a11efcc0f9e1f7eab *R/scale-alpha.r
-d2d7f41130b5a88899f9cb15cde0c2d6 *R/scale-area.r
-ec2f962e810d9eaff052b39aa73b7aef *R/scale-brewer.r
-e922db62ed12e535ebeadf79c72dac75 *R/scale-continuous.r
-411ae283f14a9cbfaf89b450ce9295ea *R/scale-date.r
-bd9a20524f0d5f728fe59d0aef7718db *R/scale-datetime.r
-216ca4997f765eb174c13db53436f3dd *R/scale-discrete-.r
-fd8f838856c003bc69939aea0f0aa780 *R/scale-gradient.r
-e05bb9a55b15069a2ea9404b09525810 *R/scale-gradient2.r
-228c009cb66c0eafdeda9e92d44db1be *R/scale-gradientn.r
-bf02cee25c672069385cc20ec0c8afd6 *R/scale-grey.r
-812ba631431e610c460e32be53fd4cd9 *R/scale-hue.r
-ec6c426256d89a7236fa9c547bfa6b8e *R/scale-identity.r
-ba7b404533f49db0b916d3e0deea7bad *R/scale-linetype.r
-73941853b55fbe85ee43d514616cf278 *R/scale-manual.r
-621f0c32a080738b66f290c0a7ecdf4f *R/scale-shape.r
-59866fc36aa00a75c17a227c830dd106 *R/scale-size.r
-5501500faea17cce988ed90e08ccad09 *R/scales-.r
-913469f5bdd833a806b3f05bd06e3269 *R/stat-.r
-100bcca190ae776c187a64a9d90bf392 *R/stat-bin.r
-e04072f2f78615a5b2b8b9fed837069a *R/stat-bin2d.r
-655a60570160ec9cbada68e0e3ca81fc *R/stat-bindot.r
-72b80b2e70f00c77743d471c95d7b35a *R/stat-binhex.r
-8c780eb83459452d0cf2fc7e9b289cfc *R/stat-boxplot.r
-235bef1027e06ea8a0601c0784b1424c *R/stat-contour.r
-bad50ec69ed8cc4b65486c7f3c1431d0 *R/stat-density-2d.r
-2d4674031c3003793c49f0650cfd090d *R/stat-density.r
-914a84e1cb5c26a7eabe49c5a6bfe131 *R/stat-ecdf.r
-4bd724861e96053ce912ef90a9122b9c *R/stat-function.r
-1aa6d8d13dd3c1ebc055dc8a15d115b5 *R/stat-identity.r
-279f0e942ed40c9c3e0da7c7bf9f2431 *R/stat-qq.r
-77f819801f9a9e0b2c454e7a1495178d *R/stat-quantile.r
-9b03451d84893346d904947bdcb23ea2 *R/stat-smooth-methods.r
-9d30760907d8d03aad7b2b9c0ea0de28 *R/stat-smooth.r
-d7297e51a7ca5fc19a36205d364f8c8f *R/stat-spoke.r
-96119f89a7493a8035104e66fa51ece7 *R/stat-sum.r
-c9ffea7b3cd36374aba20d5069cd2a3e *R/stat-summary-2d.r
-82e4a422d748d706b82ae7dba4290aa4 *R/stat-summary-hex.r
-9b5cb76c8b6622182c858acd6a4ddf87 *R/stat-summary.r
-7b6e46124c9b52aef0ac1d1f141638d8 *R/stat-unique.r
-7b419d8ad895280d4afc810f3c319ff1 *R/stat-vline.r
-b2a578fe70d950d21dfa1ee91198edae *R/stat-ydensity.r
-3cd3f00683a2712f83f7343c450823ba *R/summary.r
-df52bbff80d38abe06678cd140ffd9f2 *R/templates.r
-1657c2eb4da3283b00f6da87b578df08 *R/theme-defaults.r
-4817702b925e5aa7bcca20edb047911a *R/theme-elements.r
-b4ae203e46e8dbdd3df16e281cfd42aa *R/theme.r
-35bad6637d640ff42f356aa4f32d2880 *R/translate-qplot-base.r
-848208d3ba4fa95b9772c30ab7719b07 *R/translate-qplot-ggplot.r
-fee87f2af65cb375fde0c9e2861fe20e *R/translate-qplot-gpl.r
-44c20592c21fb28a06bd6bd649c10fa0 *R/translate-qplot-lattice.r
-fa4087800994bd078cf0a495b3f2f93b *R/utilities-break.r
-529807804c64e4144ec5048f49660ea4 *R/utilities-grid.r
+0cd85d549020a22ff0e356fc9c52294c *R/annotation-map.r
+c09a4fd2a87dc99b85fe56a03e230f28 *R/annotation-raster.r
+28be5bf186120cf1cf4f54e763e4c7e3 *R/annotation.r
+2e7da6e309c0d9a583c19e034f8439bc *R/autoplot.r
+002d571b02b862da365019e5ad665947 *R/bench.r
+b4b4e57c494cb5f702594197864adf0b *R/coord-.r
+4683128fa78f31064204ded093ff2766 *R/coord-cartesian-.r
+3138096ebcab95e7367f19bc5b03b436 *R/coord-fixed.r
+6b31f68b65f0b819995a1e98f99cdc94 *R/coord-flip.r
+14873643f38eaea3ca1cc78fdc818f46 *R/coord-map.r
+3cae8e956b77a36e051830619960f7cb *R/coord-munch.r
+d95e60b9e7640efec0339a193552daf9 *R/coord-polar.r
+5303b40f6b4ac06b0000e038abb47dfc *R/coord-quickmap.R
+56c4dee9e75c15c297b484a0d91b46eb *R/coord-transform.r
+1cc34cbdb97662693545d1f09f53c080 *R/facet-.r
+580691f36d9eeff2389ba8846b5939b4 *R/facet-grid-.r
+9b12151f5570c6425ef26b61817bf9a5 *R/facet-labels.r
+ee052f06a431f3d7398363e7e3e95d99 *R/facet-layout.r
+3237a0155df325b5f839c2aa77ebb8c8 *R/facet-locate.r
+0fccaf52ac692a2536b9a5d7a04618fb *R/facet-null.r
+7c2d0996eee3e6b0b592f190086e05ed *R/facet-viewports.r
+5e7ef96ae8241158c87545ec18c21067 *R/facet-wrap.r
+aaa3fc7bb671c4b504f4a00e50640e98 *R/fortify-lm.r
+dc79c0352642bbea357b7640fb91933d *R/fortify-map.r
+74311415c2f72fbd804da74a7e0f97b4 *R/fortify-multcomp.r
+15c2b10b5d61e092a79b5bc8501c202a *R/fortify-spatial.r
+b16daaa3a96ef6da619b3a27db789504 *R/fortify.r
+2eba55e1d2236ca737f662d8aae4d729 *R/geom-.r
+89029b74dfe36d80f6660e58d0a8f43c *R/geom-abline.r
+73ee231468fd5419e5c3a812e52aea6d *R/geom-bar-.r
+c4191294aba5be8a2950401c74b05b8b *R/geom-bar-histogram.r
+7ac893cece36513f1f68d5af9bce6407 *R/geom-bin2d.r
+797a0761fcd2b4150b6d3a959f78137a *R/geom-blank.r
+0dad76ee22dd7dc122938cd9a32c1d45 *R/geom-boxplot.r
+838b60d4df9e0b9cb254f0bfcabee6b3 *R/geom-crossbar.r
+6f76afb959cf4de6c5393ab30007b4e6 *R/geom-defaults.r
+5aa9371ced151ed66d3526fa846108c8 *R/geom-dotplot.r
+9b015b902ec0cdbd7183c05213ec1f4f *R/geom-error.r
+32b5c79d2f1631552a0aeda040e74a2b *R/geom-errorh.r
+de9028d2868412479685ab1a56dcd520 *R/geom-freqpoly.r
+dae6db66265424ac9717783ee9951817 *R/geom-hex.r
+e2e5efc4758fc52183b0521e9715d2ad *R/geom-hline.r
+dfa8fd5027a398a6bfdc95420c471ad8 *R/geom-linerange.r
+532eb327b4c056506b6649df9cb04682 *R/geom-map.r
+854bd32e6cb03241278ac9619f81cffa *R/geom-path-.r
+8cd868ce8b0403868e3f48dbb6e6925e *R/geom-path-contour.r
+3498d5f68d59a4314d2d5ee7444ee55d *R/geom-path-density2d.r
+4d88e896ed0324a7c81a65039f709f26 *R/geom-path-line.r
+eafcf3374d4169c1f13a57fbb4fc21bb *R/geom-path-step.r
+aaee5da813a00b7c289148d021779116 *R/geom-point-.r
+0a22af9812a4dfebc0592035b3e2a8a8 *R/geom-point-jitter.r
+daf31eae92cdb40077ba12c7ed8bcf5b *R/geom-pointrange.r
+c69833ed42949f88ceff97f23b262c82 *R/geom-polygon.r
+328eb9f974aa1cc45bd2adccc1f672e1 *R/geom-quantile.r
+e9c122841a2b04ea88d927ac9142fecc *R/geom-raster.r
+25aa195ff8d6fae219db9afa3dc9958a *R/geom-rect.r
+f80372ab7b9b0c779dae329e4b6e9c47 *R/geom-ribbon-.r
+d5a97849e493fe2e4c2f3a324b374b56 *R/geom-ribbon-density.r
+177470afc369a077d12a87587d121cad *R/geom-rug.r
+fec5c5228d49615ef159fd3c2c4f3a49 *R/geom-segment.r
+aefdb484bdc794d89197bd1e92b1d5b0 *R/geom-smooth.r
+97e73dd29928a218132dcefa6fd38d0b *R/geom-text.r
+b7798c5d38d9b51a119e17f7178d5487 *R/geom-tile.r
+adb729cebdfe71e1cb0ee93e2c825248 *R/geom-violin.r
+ed7e61ce71f1d2c676d459f2eb48819c *R/geom-vline.r
+93380c43b85735ebfb3c8a558b164d94 *R/ggplot2.r
+9ecf3ee0f58c470cff0b94b4b2b4c483 *R/grob-absolute.r
+a92d5cd7213cc67efd8d5eb261da363c *R/grob-dotstack.r
+1df573f9a098435be0d8a5f4bd1139db *R/grob-null.r
+3a22df8f718757c26717fed745d3b3ef *R/guide-colorbar.r
+f1ef060eb2fe8af19da878f0d091e262 *R/guide-legend.r
+df9873781cc0c4017ac0672e51ed7011 *R/guides-.r
+8b21d8b40e32e982429a6817db86f17d *R/guides-axis.r
+49c53870378098a3523f3ac48df86b43 *R/guides-grid.r
+18ba5f8c124934c35b9fcb471212477e *R/labels.r
+3b59b0102f48796bacab0d08d5edc035 *R/layer.r
+e40ae7451b7eb711ca65bfb2e6b289dc *R/limits.r
+40fb5a4aa9d14ecf34f219c570520004 *R/panel.r
+a880b6457f54f07c749458de66e99005 *R/plot-build.r
+eac13dd299a1a608f0e02024a5e2deb8 *R/plot-construction.r
+e7d2e29ecfc09bffcf8518894eec414b *R/plot-last.r
+c98775ee91cac1e88e2bf526529ea79e *R/plot-render.r
+2fc63b9c8af17e00d71d183117483833 *R/plot.r
+d1d036c42de52bd227e173e536a8117d *R/position-.r
+7c712c4a10f5e82b89cb25813940e725 *R/position-collide.r
+9122c08241b1d6a6dc6acc97d43fa55f *R/position-dodge.r
+dd3d6309b06152f9e0f109bb596fb5b6 *R/position-fill.r
+adefea880e0fdcd381d48eb397dacbaf *R/position-identity.r
+7eca3412b594ecdbb6fd157d5c37dd39 *R/position-jitter.r
+9bbaa6b648c2241e5956dca5e2a6d250 *R/position-jitterdodge.R
+d23f824339cb7cb1dead47c71cc68aa8 *R/position-stack.r
+34b96125d8448a5f5b46f1246dd6dcc6 *R/quick-plot.r
+bbc3613dbfe61c759ad95f891dcb155c *R/save.r
+2d403f211a5dec31013b7ed8a2aa27ad *R/scale-.r
+3cf8ae7ae428a496151ac12c00246c35 *R/scale-alpha.r
+9d4e143f827a8ada210e509e4129a394 *R/scale-area.r
+3aa82d13974ee266d63d88f1eb170f8a *R/scale-brewer.r
+71ddaadd63f1a81132f1d7cfd97388c1 *R/scale-continuous.r
+f73a89c5213beab09846a7958f8850c0 *R/scale-date.r
+165796cac80658af2524b9f7118c0507 *R/scale-datetime.r
+b8010c01da84c6e434cd3bb8a0c0dd03 *R/scale-discrete-.r
+c8f38cac586662e423824a5f8de4e80e *R/scale-gradient.r
+0fee5d5e99888e66b7b74428abcf615b *R/scale-gradient2.r
+7b70d88e128f6c707e619dafb6637641 *R/scale-gradientn.r
+44e0d7b7b33f43a4ce5b172a0d45a3c6 *R/scale-grey.r
+4684519e905cc620580296d3b4bd4620 *R/scale-hue.r
+2ce4d8bf820d32f331e2a00b7f232c86 *R/scale-identity.r
+5518b49ebaef372bf32bba55771fc4ab *R/scale-linetype.r
+7efacd05dceb31b0cc7bb6e78347fdfa *R/scale-manual.r
+1f31154c84baeafffdefda6101df6e8f *R/scale-shape.r
+21cd9e75546deacf869ae68654d21641 *R/scale-size.r
+c986df3b9231146a05c3548c1bf665ea *R/scales-.r
+91503213da0b0a4fba4fd80650783f71 *R/stat-.r
+f9bd6fb941a19c25d7ac748c87fcd820 *R/stat-bin.r
+a747eae385ccf605a6572a549bb3b272 *R/stat-bin2d.r
+3b15d2033f30c902ae8282733dad7433 *R/stat-bindot.r
+52c3f5920ed7272d5878f23d9a431790 *R/stat-binhex.r
+47e9cce7592903970fe666470497ffaa *R/stat-boxplot.r
+35ea3c58d577163cc70120abc29abd19 *R/stat-contour.r
+4d9fde8e9b9f145b3723a7fc5d145af2 *R/stat-density-2d.r
+1aa16c6faa97d62cf39915c0bd70be4c *R/stat-density.r
+8eb465733148a29108da357c691b75dc *R/stat-ecdf.r
+fed06a28a53b3294c3470adb691b96d7 *R/stat-ellipse.R
+adccc25e424f422bbd1ac4cfb44e44bc *R/stat-function.r
+c66776fb2e2d75dade61ab65988bd442 *R/stat-identity.r
+843729a267306bed15774602b7da1df0 *R/stat-qq.r
+f67e69db4d9761022835b61fed1a49c7 *R/stat-quantile.r
+7fa079e08b611c22763856d1977c7237 *R/stat-smooth-methods.r
+2de08c61cd902ea5797ea5a690060615 *R/stat-smooth.r
+f2c556e4fed9ee698ca0cda10e4877b2 *R/stat-spoke.r
+20911610c78693674e865668226bdf2e *R/stat-sum.r
+aec239677a41aec83e5daa5495bd7e7d *R/stat-summary-2d.r
+0b057fd945dae31f50caff6716935c40 *R/stat-summary-hex.r
+45f9667778980b11ed71a60a1e85ba02 *R/stat-summary.r
+4e5d8cd311dcba7608c2c585990b85c6 *R/stat-unique.r
+f6f71512cecc01fdbb0e04fa16ff2bfe *R/stat-vline.r
+ce95ac4c849973d6e6ea0256931b6a16 *R/stat-ydensity.r
+7eaa6b3f8b149eef3f4c663e59761ca4 *R/summary.r
+f6d61c2edc9384a9e4a2e0227b100027 *R/templates.r
+d4a52d63d9e4287dae9ccf701242f7c0 *R/theme-defaults.r
+4fcb0b71412d3c6386a34a4e5426c27a *R/theme-elements.r
+2cc865751c2c3099548de462b6ace289 *R/theme.r
+1239cf068ccaa1a1c58d38793e91caf3 *R/translate-qplot-base.r
+b97bd5e0d2c69643142fb2b4529a0cad *R/translate-qplot-ggplot.r
+1bd070722cc8df670a421f418332430f *R/translate-qplot-gpl.r
+aa1989d59c8de002c60dbaa89f40c58e *R/translate-qplot-lattice.r
+feb283c70f8bcc6347beebc0b03a169e *R/utilities-break.r
+aac51c69462f8ba3a39324092ca86992 *R/utilities-grid.r
7d2253be1f20087c6d0316d0443b73b7 *R/utilities-help.r
-1831f357299303b55978c2cda95b32b4 *R/utilities-layer.r
-afc6431171cfd73e050e71df95bfa0dd *R/utilities-matrix.r
-c7fde74a4a34021d39442b0ae7d8552d *R/utilities-resolution.r
-57c5dfa7816f7df6c73f04705350ddd8 *R/utilities-table.r
-5e4f767a7a86173e4ef339b664c705e1 *R/utilities.r
-34d407a106599d53ab46fdd91be6eab3 *R/xxx-digest.r
-610971f2b52b5165ac7e29106eff0b0a *R/zxx.r
-1eaf05da9731eb13f290fba1abd4b073 *R/zzz.r
-b4fab9a4162bad65843f1af6f2568dae *README.md
-c5bbe13cd390f0c20a6f97dbc2c712f2 *build/partial.rdb
+08517a0c6322429c9555c3d6aba1d02e *R/utilities-layer.r
+5410fb5e04e464764ed86dc00bffc4a6 *R/utilities-matrix.r
+a2f6c224351ced0c10b6f55dcd941fd3 *R/utilities-resolution.r
+e72a2689dc0d2076b7492a6ebd165b62 *R/utilities-table.r
+4df100d2cd3585c7daea8ffd9341bdd2 *R/utilities.r
+5e3565930d6b2543aa0772d2611fb34e *R/xxx-digest.r
+f93fe51f34d83c7e9736eef199216b47 *R/zxx.r
+62b43ab5691752c5156baadc1fbefa27 *R/zzz.r
+92cf5ffe3de9a67d9994ef6ab9797a6d *README.md
+a2eab29151bf7ffc828092f375fbc25a *build/partial.rdb
+d7d1b707862fa3a91fcc8f9c04ea7c49 *build/vignette.rds
9cb6a35588a5dd6989b03aece1b60e03 *data/datalist
4096c2eeb1224845fc5f0e25e9974c25 *data/diamonds.rda
8985076e2ad3bed814a263e66cda6536 *data/economics.rda
@@ -177,233 +181,241 @@ d4a17298bd70c76813a5413330c1cd23 *data/mpg.rda
f11e86b50338713740fae032ed3d32bc *data/presidential.rda
401d0becb289a0ca4b041bb64e3b8aa0 *data/seals.rda
d5d8dadfa9a1796813880c6dd466051b *inst/CITATION
+42794e3176a87bcfc14d6983554b036d *inst/doc/development.R
+ca9a9bfa8225e85a1400d060568ada6a *inst/doc/development.Rmd
+3007808db617bbcb11bae62aa3ad3aa6 *inst/doc/development.html
+a9a3984d026d63358006a9972e13a779 *inst/doc/release.R
+031c78a8fbe505a4ee120726f622d005 *inst/doc/release.Rmd
+87bc2b705306a47e123ad93c23ceb1fc *inst/doc/release.html
+d41d8cd98f00b204e9800998ecf8427e *inst/staticdocs/README.md
7a09459ca2898424c3714a03f20665fd *inst/staticdocs/footer.html
923198a65466326dfb62fec20e793e3c *inst/staticdocs/head.html
-1636c128fb7de2919590069e9d19d17a *inst/staticdocs/index.r
+a24a2d726dd6a2fa5e49c58626272d89 *inst/staticdocs/icons.R
+650e05ef6010bc7ca18e7c543c8b551e *inst/staticdocs/index.r
866901e6be1bdbaba1c9c2d7b879e8dc *inst/test_ns/DESCRIPTION
b21b353b8831ab5ccca59122881140d3 *inst/test_ns/NAMESPACE
-81187edd664288ddb04c48475fbcb663 *inst/test_ns/R/my-plot.r
+e2f433ef982d4a7577a9364adfb6c952 *inst/test_ns/R/my-plot.r
06a9f7ef332826077bd8e50b13121112 *inst/test_ns/man/my_plot.Rd
-54a5e91c31e50f11f6cfcf0a56fea081 *inst/tests/helper-plot-data.r
-740526641fb432626a257d0becf6fd1a *inst/tests/test-aes-grouping.r
-d238d83a85d5579410180f485ba7b7ea *inst/tests/test-aes-setting.r
-38c1a42c898de0abf1f995e748276833 *inst/tests/test-aes.r
+77945a46a6b20d19e78bf208dd8032cd *inst/tests/helper-plot-data.r
+93ddf3d657ca72d8f55339560a53ec7f *inst/tests/test-aes-grouping.r
+cc9e57a09518a730a765c21e45b5e04b *inst/tests/test-aes-setting.r
+61f07cdbec3e2551558fbe5c8a379d34 *inst/tests/test-aes.r
196e9a7accdbb9fb1f2e13f4aece3918 *inst/tests/test-boxplot.r
-92e9538a12d82532d919860a548e00a2 *inst/tests/test-build.r
+6dc1254d98d2934283c5841d0d4e7d8a *inst/tests/test-build.r
0465e5e3f7e11018338ea4bdf774ad20 *inst/tests/test-coord-polar.r
70db5dd20f4b1a8a0164cf522feec0fd *inst/tests/test-coord-train.r
-8b9dd7f814320cdeb5954ce0f4292a66 *inst/tests/test-data.r
+e1f64293358ced2a79f18dc1b336cc51 *inst/tests/test-data.r
c4ec1dc18f683b9afdefb6ee82b4f5d2 *inst/tests/test-dotplot.r
1b12e4284c255e898648b3e81edee1d4 *inst/tests/test-empty-data.r
-ea4aa03be81acb5157bc833e4b97365c *inst/tests/test-facet-.r
-a2c0ce251e99c0b018439d607b0c7451 *inst/tests/test-facet-layout.r
-827676b38f580ed2c48bbdb375962295 *inst/tests/test-facet-locate.r
-0d8de00a68ac094bed41ebe50710aedf *inst/tests/test-fortify.r
+54d9d6f682eb8574e28a03ac1fef1cc6 *inst/tests/test-facet-.r
+747e7df23151f233e6c2b574a5942af6 *inst/tests/test-facet-layout.r
+8f34247aa95dfa5f50a5a0189f87bece *inst/tests/test-facet-locate.r
+38e013c546215e5d1d1d4809be98219c *inst/tests/test-fortify.r
6318ef949123e4e13c938ffc0e3d4010 *inst/tests/test-labels.r
-df4857f8b4cb04d4846337dd0021b5e1 *inst/tests/test-qplot.r
-a5c8acb60c96d7e0f7210a8c15b452b3 *inst/tests/test-scale-manual.r
-369b0bf3b04cbc0d462ec7bd40f7b6ea *inst/tests/test-scales-breaks-labels.r
-3d9276f75fee9feb42e5b9773568f8be *inst/tests/test-scales.r
-0fd040a1a7d2ad8ddcd32b93cfe22ce4 *inst/tests/test-stats.r
+a172b0ff15b8c249e0c69af0c014007c *inst/tests/test-layer.r
+972abcb47b4a68ac9f086af1c8198da9 *inst/tests/test-qplot.r
+ef9d5bdaf6d1f4560a86d7841c9d1e85 *inst/tests/test-scale-manual.r
+447ee9f3231c9fbb114dcfc888dae316 *inst/tests/test-scales-breaks-labels.r
+724df5b5fbd7cb01740cf7467e50cae9 *inst/tests/test-scales.r
+1ea4b0add6ed2f15724d58441483c1a8 *inst/tests/test-stats.r
640dc2d0eb7ef9a9c47129a70f1ae465 *inst/tests/test-theme.r
f3cbac27a85b4d7022031b7dfbe80e2d *inst/tests/test-utilities.r
-16aeac0d13e4203be6c6677c02cb6ac9 *man/absoluteGrob.Rd
-8c59bdf467a2341257524a06d12bf751 *man/add_theme.Rd
-48515c5fab3181ad53687c13d3bc7728 *man/aes.Rd
-7f0268389edbd543590ab20f72c4e546 *man/aes_all.Rd
-2f508fdb273bacaf2882a4effcecc477 *man/aes_auto.Rd
-4889de6f483e4079fac585a2a92588e9 *man/aes_colour_fill_alpha.Rd
-e909864117cd52d01c932d4fa02aabdc *man/aes_group_order.Rd
-d334b490b3496de05acd9c12d612dfd7 *man/aes_linetype_size_shape.Rd
-eb6a3d6a8e76ebb2d8fecf1acf01771a *man/aes_position.Rd
-3382823074948794bc5449627edd1ec3 *man/aes_string.Rd
-e7874d09f0afd7d01e19112b4e48d319 *man/annotate.Rd
-efa994a5941ffdb03dc0c954590a94d7 *man/annotation_custom.Rd
-e3105bd4f1ca0256fd37b1a71b524975 *man/annotation_logticks.Rd
-c440509810d49e6438a8698ec95e9ad8 *man/annotation_map.Rd
-e8f45fdecf5d239f5d172c001de6aab4 *man/annotation_raster.Rd
-393d6cd345f15044dbccc0fc1fbcccc8 *man/autoplot.Rd
-3ce5324191cfe1f4576ef322a7ac814b *man/benchplot.Rd
-33f26a4c3f709c607370b58182324866 *man/borders.Rd
-0b5a8125d4bad4068151e37b446650d0 *man/calc_element.Rd
-1a7fc8e2b4ddb698e1eb734a1888af7d *man/continuous_scale.Rd
-d34c77ebd995ddff20015b6441396e44 *man/coord.Rd
-d4560d8c1d434d6b1969c67ea6feab18 *man/coord_cartesian.Rd
-198428d7c27059306765abfb1cb7e0e9 *man/coord_expand_defaults.Rd
-8fe89dcc188c784453283cae8362436f *man/coord_fixed.Rd
-1a92e019a78f44be33b30ea8d13dd4b5 *man/coord_flip.Rd
-c21e0ae69f763926ec02d03998af01b0 *man/coord_map.Rd
-4f75d31c5433fd6bbe4b1b140f2c2f30 *man/coord_polar.Rd
-be90cdf6f48758df386904cb1e0340ea *man/coord_trans.Rd
-cc75f9311945e00800acb2cc383b5c6e *man/cut_interval.Rd
-1f083848b4454297935ed8002d432d08 *man/cut_number.Rd
-7cd340627cfffd0588ec01efe119282c *man/cweave.Rd
-8dffced7acdd73572b0f897495fd484f *man/diamonds.Rd
-ed317052cda52383f79a6cc803ded516 *man/discrete_scale.Rd
-66c51e6282fbdd4a6ea92aeeaf2f7468 *man/economics.Rd
-9201d3655e0d2681d6f302acee35dd6d *man/element_blank.Rd
-10dbf678e0aa4c6053010b87735fff50 *man/element_line.Rd
-32d5e3ca63a01a6723bdf7dbe78ac4e6 *man/element_rect.Rd
-18c93cfcc019ea5e4dca58a7ad0254d9 *man/element_text.Rd
-1f4a6518a545649170b4f6630033fa47 *man/expand_limits.Rd
-fc0007c0b99136ba561d5f83445f0f6c *man/facet.Rd
-2ceea38d8c4982b3a5f20d52bada6636 *man/facet_grid.Rd
-bd47b24e7720e45cf0e493b1708de99c *man/facet_null.Rd
-f57a0979f4214aea4be33ff16a35b98e *man/facet_wrap.Rd
-ad9a52790670dd0f25a8adc4b6846508 *man/fortify-multcomp.Rd
-aa54f670390829f838de4a1f5f223928 *man/fortify.Rd
-7b991855af7377a4e7fc5ba9019a6e5e *man/fortify.lm.Rd
-d2032405c06f63e3cff901d0c2fa7285 *man/fortify.map.Rd
-10e9282c972588bea0c6e1276d288c60 *man/fortify.sp.Rd
-9d2de08867c752df6073a8ee84492027 *man/geom_abline.Rd
-55eee75c1601c95a7171abafd0031082 *man/geom_area.Rd
-716ab0e1cea0ec1efd100700d2302802 *man/geom_bar.Rd
-265dcb094bb678164c6d7f2152b5c3f2 *man/geom_bin2d.Rd
-7e436461f5ef6b9776042f10a3b5cea0 *man/geom_blank.Rd
-444ea49a70b544baad302ef0fd7ad539 *man/geom_boxplot.Rd
-315278ff76400b029d27ad4abfdec95b *man/geom_contour.Rd
-e56c6035bef0da33e85937a89592f766 *man/geom_crossbar.Rd
-e6812e01526f280024ec38687585e9a9 *man/geom_density.Rd
-8c6bd54adf9b7efa06fe5ba7a99b77e6 *man/geom_density2d.Rd
-30681808473da3e9cd672911a2587dba *man/geom_dotplot.Rd
-10b44e28f18c77f272f713fb0c396521 *man/geom_errorbar.Rd
-5d46766eb0de0cb23e3af6160c12ed18 *man/geom_errorbarh.Rd
-1e590519dd98a717d95bc0e691efc652 *man/geom_freqpoly.Rd
-9d6db3b63912b82de455be4f83d37ceb *man/geom_hex.Rd
-858c1ac63ec2173db2ecc2685006d53f *man/geom_histogram.Rd
-05e997f7dd5a9c4c5d4021abcfc3bf0a *man/geom_hline.Rd
-8ac6dd0f01b2379c9c67c541098a6da8 *man/geom_jitter.Rd
-ce9355e3a1c5e5c887c20b0fda11fae4 *man/geom_line.Rd
-bb693a40276af193970e71a4b0c64913 *man/geom_linerange.Rd
-9e43b2ec31c2ef9165dbdb3c593b872d *man/geom_map.Rd
-354b975cea027771965b028f82b4c7bf *man/geom_path.Rd
-0831ae36392538c1e60361b862debdd5 *man/geom_point.Rd
-daceb836a1a8d03ae3e692ed3d21bd90 *man/geom_pointrange.Rd
-847e619ce8374639d3bcc964b308c3a7 *man/geom_polygon.Rd
-8ee0fe25436ad26608b8bd06408d6d7b *man/geom_quantile.Rd
-18e8cbb591ac4f0e7e703be76aa6f582 *man/geom_raster.Rd
-62e37a830b42d6215aa33245de5758da *man/geom_rect.Rd
-976f710a3aa1b7276d7c8551ac191340 *man/geom_ribbon.Rd
-0a12e30560e6d7dd0023bb56d2517d57 *man/geom_rug.Rd
-b442cfc5be5a16800eb7a784ca1ad23c *man/geom_segment.Rd
-5d534acaa2fa0b54e1a3eacbb4cb58d6 *man/geom_smooth.Rd
-eb47dd70c3a99f23ba4aa8c4711a3d52 *man/geom_step.Rd
-77a04b2deea526b2ad3a7bac8bd8ebb0 *man/geom_text.Rd
-7cd3e9f99d79412b3f4c12e24a641946 *man/geom_tile.Rd
-14c703c7d09ac0eaaf78185c50b34af9 *man/geom_violin.Rd
-572cea5856774208823d60283d18a1c2 *man/geom_vline.Rd
-143a3afcc226d7d0af5f04c8682c636e *man/gg-add.Rd
-9bf0640589a09029fff3886636b758c4 *man/gg_dep.Rd
-16b0138513709ece3bbd7e6e9382937c *man/ggfluctuation.Rd
-7beb1db580ceb3931b981e4eede3901f *man/ggmissing.Rd
-877f2848360ec22736d2239ed769f8cf *man/ggorder.Rd
-a988d0bff727b0608579d65373190a4f *man/ggpcp.Rd
-f151d88a6cef612dbbc21b02a35bd3d6 *man/ggplot.Rd
-52513056e66e78b84f32bc44024acaac *man/ggplot.data.frame.Rd
-2bbfff326c3bc5638703bf039cbf7283 *man/ggplot2.Rd
-e9285c4d6200f92c1c0792280cb4a27d *man/ggplotGrob.Rd
-c2ebf1d0f9d2c215314e58d280733242 *man/ggplot_build.Rd
-990d440ce353930c6e6aa085ea5a07ac *man/ggplot_gtable.Rd
-f15898088591e71642fe9fdd6a7cd9ef *man/ggsave.Rd
-5247e8cc2e5a23b5860b81d12962e134 *man/ggscale.Rd
-ad9f2cd99b9d5844774cfb09596ee0ae *man/ggstructure.Rd
-152b7f161d5b89daf01b6952bc3011f8 *man/guide_colourbar.Rd
-31fce153247e86fa77286c95e67cb812 *man/guide_legend.Rd
-a2323fc0e4867724a619e697ac001c66 *man/guides.Rd
-b7420217cb903b2dc2973961683d835c *man/hmisc.Rd
-9dee3f314202d4fc488dd129caa85de5 *man/interleave.Rd
-76c692c6530f2210183ac091c5a2dfac *man/is.coord.Rd
-d98ad64f5a8bdcb597009121f2f373f0 *man/is.facet.Rd
-60b34e72f6e6412a317f10b33a4d5775 *man/is.ggplot.Rd
-8011140ccd8cec0499f1d7a24343b610 *man/is.rel.Rd
-b1b68d9b22cdefbaf25beeb5247e17d7 *man/is.theme.Rd
-4984e605e7bf0bad1112a5d260071ba4 *man/label_both.Rd
-eb0ce6c1393f2344ad31aa73952af8f7 *man/label_bquote.Rd
-587b537d6c9f4cd3b74eab03aaa4bc49 *man/label_parsed.Rd
-0ed9bf4b7c87adbf38560d9a74375b7a *man/label_value.Rd
-09febaf96deaa96c7b90584b22e89683 *man/labs.Rd
-b29b0c31ba29e9844bffd6020c46df4b *man/last_plot.Rd
-80b34a8bee023f0600ef6657014496e6 *man/layer.Rd
-2762d7f21a3cf2529acbbd8745fa8ca6 *man/limits.Rd
-b3a7bf62a36bfe4d3c67a03b39c8d9e8 *man/map_data.Rd
-074cbad6e456988198c7467b9e4bcbcf *man/mean_se.Rd
-f02c570c24918618e61d3001825b7ee2 *man/midwest.Rd
-5f1e5983c574b4f66ecb8097dad02c6d *man/movies.Rd
-a4806ff6d4b870c19a071532b5163fd2 *man/mpg.Rd
-47b3e52794e392ed6b552a90c86e4aeb *man/msleep.Rd
-34dd7a626dcd84588acdd9d3bcd501ad *man/opts.Rd
-00bdbf6bae684fd888df9a9e48d0fb99 *man/plotmatrix.Rd
-5bdcf97196cb9f7cc71b8ce8bfc6bd05 *man/position_dodge.Rd
-559631d3055ddc145bfda74cfec500c2 *man/position_fill.Rd
-ebd4285b90632ec8a6420e050173bd85 *man/position_identity.Rd
-9d06805d1d827079dfe6a3238147d187 *man/position_jitter.Rd
-ab4a87ca1886ab7360a28924a7a4833d *man/position_stack.Rd
-ac1e91d5585340e4cc76589d88a9edc3 *man/presidential.Rd
-853f2f249b83aa4a4b418a64f051f592 *man/print.ggplot.Rd
-bd9566cbee356cdf513d6f619ae43681 *man/qplot.Rd
-6d4350b101436d0d3f34cf78d185da57 *man/rel.Rd
-0acc1392857c43b0809f1ae380613d5b *man/resolution.Rd
-508d46677598b489b99bdcbbe9108087 *man/rweave.Rd
-7408246a1dd45760d9415b4e8b52a637 *man/scale_alpha.Rd
-6f724ca1e9c0d96bf73af017532818dc *man/scale_area.Rd
-17f1b699683ac877f335fc3452c1e0b3 *man/scale_brewer.Rd
-45e96c78bdfea81148bd4cf3a2e89a18 *man/scale_continuous.Rd
-1beb44e296a5d1347cc266991579cf17 *man/scale_date.Rd
-1cb1b47cd87d305fa777397de4b015d3 *man/scale_datetime.Rd
-0daafa594ee8e5a7235819a2431fd97c *man/scale_discrete.Rd
-624e7a1dfa7e44976304f97b5b1887ed *man/scale_gradient.Rd
-6e657bf2b08238c4fe9ae438095c3357 *man/scale_gradient2.Rd
-90b4091419fc942918e325c707a393b0 *man/scale_gradientn.Rd
-6edc3841c3756b333013bc103c2f3641 *man/scale_grey.Rd
-edb37737fcbfac52ab01c8706233d456 *man/scale_hue.Rd
-709d463aee9bf3764e4867f3b6de8dd2 *man/scale_identity.Rd
-3f2d791ea0ea8ebda0954878c986a738 *man/scale_linetype.Rd
-b5c95675a9a8866736de3a10b3ccbc56 *man/scale_manual.Rd
-d2a34ce18ab49428a1d12c7a3a04788b *man/scale_shape.Rd
-e107c52a7a21560ee80428266f56434a *man/scale_size.Rd
-d8992c12a1271ff99859005bf7a1299d *man/scale_size_area.Rd
-8d0aadf97c6a1d014267ecc9360b9a36 *man/seals.Rd
-4a91a098bb010e9d226007b3339465c1 *man/should_stop.Rd
-95647a0ba47477d0859c160a15064f4f *man/stat_abline.Rd
-d96256024cc5727a6583ae92141be514 *man/stat_bin.Rd
-eb8025d57a00da47178fdb8f8c028bc6 *man/stat_bin2d.Rd
-4c16af34caaf4a06b79b0d1a2c378766 *man/stat_bindot.Rd
-4ade66a4a13d513ff30e6c976f6171ef *man/stat_binhex.Rd
-e5e43769ffaa6fd08d71dd5f4e09af56 *man/stat_boxplot.Rd
-1ba75982d7c49aba9e751bbe412fbdee *man/stat_contour.Rd
-9b7dd5bd0f1661bc82dbbdda2f42e51a *man/stat_density.Rd
-f608a1ba79d67c045cf194dc96415932 *man/stat_density2d.Rd
-6abd9651d521e9f152508fb6f4cdd32d *man/stat_ecdf.Rd
-ff2922881d62938f9eff7a4dd7cc49c3 *man/stat_function.Rd
-540f7aff74ba9b2f1dc8d0bb98b53258 *man/stat_hline.Rd
-a88cd92639b1584f9ec227cff4615e9e *man/stat_identity.Rd
-dcb55d0b1f61443d078dcfa81e38895f *man/stat_qq.Rd
-ccf706eb15987d26dcd41ec2f0e96c77 *man/stat_quantile.Rd
-dfa0d475cab6b7ee010d21065ab8ecfc *man/stat_smooth.Rd
-7c8be194b1a5fc6cb4d4e6207a782eee *man/stat_spoke.Rd
-6690b2633df5dfb60a91904148bd1ec4 *man/stat_sum.Rd
-13541ac66e18e00684fd04af8b612f73 *man/stat_summary.Rd
-af49d4166c5bbcd041c1eebd7113eaf2 *man/stat_summary2d.Rd
-ff969e2ff834e2ac5ff61a7be24fad43 *man/stat_summary_hex.Rd
-93c6a2cf5aa5084084dcd7e630600c00 *man/stat_unique.Rd
-5023474d338e73a610a2fe9606e7203b *man/stat_vline.Rd
-2906bed985c4195c28e1ff133cd3aec6 *man/stat_ydensity.Rd
-07450b4d2de2fa5bc07a246582fc0242 *man/summary.ggplot.Rd
-fdd4abdb2bf29592e8b0c349ee4327e5 *man/theme.Rd
-96930d94e0d4c65472e853b6975a9a45 *man/theme_blank.Rd
-a1ec7cf071b2e250d22fa00ea24a63ab *man/theme_bw.Rd
-6883032a5fd2003e825df1f5cd8a2927 *man/theme_classic.Rd
-4c5517b8d019a18f4b7a9d31f69daa6e *man/theme_grey.Rd
-f71863431a58e7e0f4642db6ed510bb2 *man/theme_minimal.Rd
-6fae43aa64823a09e4a043676dd80f53 *man/theme_update.Rd
-bea98576a0986cf8dbe47e982cb6b0bb *man/translate_qplot_base.Rd
-3235f908c962515794b0ed70a06fac49 *man/translate_qplot_ggplot.Rd
-e6f02c978528db770e703bddb2fbde94 *man/translate_qplot_gpl.Rd
-026263dc4ac4f7319dc69ca2fe0d62e8 *man/translate_qplot_lattice.Rd
-4276cbcc0e0dc0d32834c5adb4ac3a7d *man/update_defaults.Rd
-89baa2be7add4ce5410160291522ce84 *man/update_element.Rd
-f0731588d00937d08b2afd2e88e5add2 *man/update_labels.Rd
-cd642e034911fdead3ebe9cec3cce622 *man/waiver.Rd
-e868504746796454f51864acba92cc63 *man/xylim.Rd
-4ca881973a6a28f78ee623155eddd9f1 *man/zeroGrob.Rd
+db0a7b260e837ee6cfd8e211819f0096 *man/absoluteGrob.Rd
+4e9d9ca198b3f7d6ce67e884776ffad9 *man/add_theme.Rd
+83e789d35f18eaf239f116f0640e47e2 *man/aes.Rd
+4773e30cc9083cc2a024a94c4a0034f3 *man/aes_all.Rd
+a217323909de237411b9ddb8ea6c7960 *man/aes_auto.Rd
+186c710c21cbb190211c7030d03e3271 *man/aes_colour_fill_alpha.Rd
+0fa83c9656505a8564cc61c44679f829 *man/aes_group_order.Rd
+db04f2ac60b84cba034a6e1e7de0db90 *man/aes_linetype_size_shape.Rd
+a65803c3ee2faa898f75271a847a4ade *man/aes_position.Rd
+21e50ddf7144b828427d24dfd327e671 *man/aes_string.Rd
+80a635d02dd203a5f845b073a450f2b2 *man/annotate.Rd
+15299e465a1a331d21836dca472e1937 *man/annotation_custom.Rd
+007f2a3867cbfba6ce25b45d98b3b961 *man/annotation_logticks.Rd
+3f664ed78e742fd90f8565eded2ea6cf *man/annotation_map.Rd
+6ee974b5a725ea2ffa9526a37b0b6925 *man/annotation_raster.Rd
+128b7723a21a678b03baf7ffabe3b65c *man/autoplot.Rd
+89d7921263e789a179b70674e2b4a7c5 *man/benchplot.Rd
+6807623885183878ed7cd45d6402fbc5 *man/borders.Rd
+4530af66c83266d5175da516e0a39270 *man/calc_element.Rd
+e686ddfb2bda248b2b4db45a1c97b23c *man/continuous_scale.Rd
+986226ab6aa713e7bfbe0cf3a01f6c21 *man/coord.Rd
+6575bed1d39b9daf39c5c81552c2b82c *man/coord_cartesian.Rd
+49d46443b407bb8126a8831259118577 *man/coord_expand_defaults.Rd
+03bd5e95ebad89f5f078c0ee3fe1a1ad *man/coord_fixed.Rd
+6c35af46bb866f924b46e663ca2758c6 *man/coord_flip.Rd
+b7e5bf141f82b19f9ae62369d8ade990 *man/coord_map.Rd
+fa0fe4b8ffe55ee6ed883aed018072e4 *man/coord_polar.Rd
+4e84ddd19b8d9764feba980353b46210 *man/coord_quickmap.Rd
+ca535b450d54b20e4a02622615410854 *man/coord_trans.Rd
+f123afc58de1837e37fa04cabe6f6390 *man/cut_interval.Rd
+b6c336b5cd64cae202603486cb6df44e *man/cut_number.Rd
+b9cbb6b4408f8128f95e0fd999975751 *man/cweave.Rd
+3f335726f48eba7ed8f31404c5fe3971 *man/diamonds.Rd
+c6101120b8fd2af864131b07620d3a38 *man/discrete_scale.Rd
+ecc8c04b5f3e34c678fea046e8f54e22 *man/economics.Rd
+3774dedbc62152cbadf54cc44c84cddd *man/element_blank.Rd
+11c9a5bad5536cd20777387682f387d4 *man/element_line.Rd
+d87c002edde017ad0d61f2377bd18e41 *man/element_rect.Rd
+e1ec72de385145b4e5234fd242c39359 *man/element_text.Rd
+0232bf9c8dd3f70084b75b81a5c52783 *man/expand_limits.Rd
+32ccc2286b4b75be6fc36cb73a1d30eb *man/facet.Rd
+648a133d9d3ff7339d9d429424de1d0a *man/facet_grid.Rd
+c47f75b14746613654c8e0797a0b8698 *man/facet_null.Rd
+78cdec4c2aa98ebd9cdcfda25c35bc90 *man/facet_wrap.Rd
+d5e3a1872f009872efa05ad0d4f38534 *man/fortify-multcomp.Rd
+78780c74421aef3ab5d626252da49934 *man/fortify.Rd
+95d95b11b7092eb6a4d07e3fe2256b88 *man/fortify.lm.Rd
+a007720e2073f07802d85fbc1bef96f8 *man/fortify.map.Rd
+6910e43d2a29a966aa055aa479246a44 *man/fortify.sp.Rd
+f1020c0b5cc824e828feb7cd40880b15 *man/geom_abline.Rd
+9c1db1190c32a49a2b57ab6a80a76e6a *man/geom_area.Rd
+c549ded76abf927017610ac0e273832d *man/geom_bar.Rd
+d661a7d2b924c791833668a1ae8c1905 *man/geom_bin2d.Rd
+7c65e927c05e42cb9ce021a752bb4202 *man/geom_blank.Rd
+ed8ec0da68e02e0ccff02c053876ee58 *man/geom_boxplot.Rd
+e4c149b7240230a6d0a121180fcf0d4c *man/geom_contour.Rd
+c2f6a04251d3b2d46d2bdd3c4583b69c *man/geom_crossbar.Rd
+6d3bce80fb4dff42e62caa8473f056df *man/geom_density.Rd
+4e93874fa67f038d63103351c4c43cad *man/geom_density2d.Rd
+f2d07cf304625fd65e8dec19dc6c1bc5 *man/geom_dotplot.Rd
+0d236e96979fbd3dd12f23ab8855aea0 *man/geom_errorbar.Rd
+d037fea69fa16b76108a4c15074e9099 *man/geom_errorbarh.Rd
+d64377ced6927170f3fea7d5262e9ee1 *man/geom_freqpoly.Rd
+17405e721c730db004dd47eea1f528a4 *man/geom_hex.Rd
+a5fb27020f4b1a4287845f9f0f777a04 *man/geom_histogram.Rd
+5b6fe20de21c03395dd1e547757b37e6 *man/geom_hline.Rd
+7efcbf994a288140d4bb61146afe3977 *man/geom_jitter.Rd
+d525e96e92bc903b4ab4507e8846781e *man/geom_line.Rd
+af607ac4c44cd7c7139635e34058163b *man/geom_linerange.Rd
+77c5a144f7b78a0a7901e03f89335bed *man/geom_map.Rd
+1ff9d2aa71ed6602e6f2437dea785655 *man/geom_path.Rd
+c94690f397c6750020742e19349802fe *man/geom_point.Rd
+9b27b5550005065e9c07f4e349e35c9f *man/geom_pointrange.Rd
+a1ffc1b341aa90fb20212e456a04d4ce *man/geom_polygon.Rd
+1d8a8319532ea82197e24849ce47fd7d *man/geom_quantile.Rd
+d829a5428bffc7fb61893643139a01e1 *man/geom_raster.Rd
+2a999fb0e218dd9686765d66e1aba46f *man/geom_rect.Rd
+9a8de24f069883ac7d5f1dcf2be9c905 *man/geom_ribbon.Rd
+8c2453e32ab068857dc41d011c2e1377 *man/geom_rug.Rd
+0a247952da3b47157b7864f2c8690e17 *man/geom_segment.Rd
+136d4a7fe3f26dd9a4aa80a455809bbf *man/geom_smooth.Rd
+92c92ca5d896eae04fe09b880b3a9649 *man/geom_step.Rd
+ce3aa5bcd1979d11366cf3045ace17e4 *man/geom_text.Rd
+0a4410f20cccf3d4bdad3761c60a7756 *man/geom_tile.Rd
+6745b49efb40cc67afb09b78decd05b9 *man/geom_violin.Rd
+964499631ddd0cfe344b3915dd7e7f02 *man/geom_vline.Rd
+9de29e137ffefba45b243bd505497c6b *man/gg-add.Rd
+a42de93fb74c9eb8d50c17fe64124675 *man/gg_dep.Rd
+1becd03f4f571b46a146e486a8f95e2c *man/ggplot.Rd
+67f04bfaeff241854cca0334cac9cb4b *man/ggplot.data.frame.Rd
+4f0fe4974bc70c07025aa0321ad44fe8 *man/ggplot2.Rd
+b6f3b087beb12c9260b03e4d4e47e955 *man/ggplotGrob.Rd
+c02cae49c38215509a2c7c306f7b62e8 *man/ggplot_build.Rd
+baea57a5f1767cc41c68a008f020deb8 *man/ggplot_gtable.Rd
+28afe1df290d27a934a7abc6a803a15c *man/ggsave.Rd
+25814d7d63ebb03b3b19c8096b7dfac2 *man/ggscale.Rd
+2fa2b8d20b45a1c3ec92b7f5c341daef *man/ggtheme.Rd
+78fcc1596c86517ac025391b411bdcef *man/guide_colourbar.Rd
+518ea5a0d91cc807b70de8ac8dcf798c *man/guide_legend.Rd
+b133b606e1895408dba22121c93f7133 *man/guides.Rd
+650c3ef42ac0886c26f05e811195946c *man/hmisc.Rd
+eafd81714968e1137b968f9cd4bc9ea5 *man/interleave.Rd
+9128a0fc3a18ed7a967b661cbe12bc0b *man/is.coord.Rd
+883593b1c629800cd0905ade92972fda *man/is.facet.Rd
+bc25ac591450b3b4dced93d10f1b13da *man/is.ggplot.Rd
+5234b3fd8e68267dc2d40ce707bd0778 *man/is.rel.Rd
+5627dacda3ab331095fd95cc10c3757e *man/is.theme.Rd
+2b8611858b9a7429c68dfdef782c970b *man/label_both.Rd
+8a97f242c018f4047f1fec76990382d2 *man/label_bquote.Rd
+1144431ed7021c6ecac8b060414c0e7a *man/label_parsed.Rd
+1d7bb0a7e23563198c2da08fe11727d8 *man/label_value.Rd
+ab381963b2f8a906adcf55a76afeebd6 *man/label_wrap_gen.Rd
+4b69389d36001a6c6f2c2fb149e71f34 *man/labeller.Rd
+793cf2bc3952a49ddb641a59777bb20b *man/labs.Rd
+9b226f3c9623291aa58a118a95c3e20f *man/last_plot.Rd
+0a394a7d81dc5831a6edba3288d1b9da *man/layer.Rd
+d80c5615fdad688f63d62e8e31decf09 *man/limits.Rd
+1bddee119161d65a465146a1774dbd42 *man/map_data.Rd
+2fc1e8978fd97ac88aee43392694cef0 *man/mean_se.Rd
+f990ba20be0cc42f351a35c4f5b455c3 *man/midwest.Rd
+2aa93c44989dcdcd1292fda797447237 *man/movies.Rd
+806678ec94206df0a3ae765812cf8e3d *man/mpg.Rd
+680a97b306e6b20f7c6c32f6647c898a *man/msleep.Rd
+53096d15b7d3bb77d0e61ff218880bdc *man/opts.Rd
+f24188259faf7f2ef63cc6c1c4a05be7 *man/plot-templates.Rd
+de436b256dd8448982c1d7eb5f8adc60 *man/position_dodge.Rd
+e00873c4ef710bdba7fc4483b86a0737 *man/position_fill.Rd
+a8844575fc274895ac3b2f7456bc74c2 *man/position_identity.Rd
+2278589a638a43fdd8bd12d59f2d7367 *man/position_jitter.Rd
+83561dd14cd076332043018559c908d7 *man/position_jitterdodge.Rd
+38c1e7b0331d4bd4554c5b489ad5f792 *man/position_stack.Rd
+1a3243a29c5985fb99f6a037010e400d *man/presidential.Rd
+0aee5cd0562649bfdf108b7538886759 *man/print.ggplot.Rd
+d2d7a5c933ff42c441cc308c40bf988a *man/qplot.Rd
+5158a5f476c97aced99cec74c4a85587 *man/rel.Rd
+3df3f1af355368e679809bebae7ff3d9 *man/resolution.Rd
+54d8731ebfd7ccba872d9466ecd5816d *man/rweave.Rd
+8f2d29492ae74684c35d9b424c219961 *man/scale_alpha.Rd
+0550dde1c987f6ab53a3ce68510eb3dd *man/scale_area.Rd
+aa301f47aa7183a49f4eb3c95a59b32f *man/scale_brewer.Rd
+da10c7035ade8126a96f7a9d23cf1fa6 *man/scale_continuous.Rd
+38e9f9fb97313403891276fefa3dda10 *man/scale_date.Rd
+5a148c349827afda220f394e21d17909 *man/scale_datetime.Rd
+da421ec22613dc9e9073f8443096cf02 *man/scale_discrete.Rd
+d676f893913e91819567dcb41343198c *man/scale_gradient.Rd
+ea160637955261e9f7874bfe185f4769 *man/scale_gradient2.Rd
+1eaf8f6c0d9f9755906cee8c6aa229f6 *man/scale_gradientn.Rd
+e13776592fa016580ff46a0821346e4b *man/scale_grey.Rd
+8833eedf1faab9c018e7edcdeff9cad0 *man/scale_hue.Rd
+dfabaf2c46056584058b12abbd458c5b *man/scale_identity.Rd
+c440f77061eb574cf127b5bb5891f7b8 *man/scale_linetype.Rd
+80301b9d9125110080ff9e87b5d45fb4 *man/scale_manual.Rd
+275e5650dfc6414c73dbdad504935bb8 *man/scale_shape.Rd
+3416fff4c534645526f5790958b15759 *man/scale_size.Rd
+8cc8cbb15eeeb926b00b15c410d5d0c2 *man/scale_size_area.Rd
+8df9265e30b8af146d1fe00e618de25a *man/seals.Rd
+d8de67d80d20f5528e9cd4e5f30117fe *man/should_stop.Rd
+00479844704bf84f95e8ebf9551d1e84 *man/stat_abline.Rd
+f2172785a7ad301bab7c6d440d38b5b4 *man/stat_bin.Rd
+06e946eb8d6b44d4239352a2fb7c3988 *man/stat_bin2d.Rd
+55a40f8409e7c43448ce93f8f844466c *man/stat_bindot.Rd
+2f97584da380017b21d9b0547fff1e22 *man/stat_binhex.Rd
+e10cab86c790d3915accd220c6544e69 *man/stat_boxplot.Rd
+6b29b4b2ce8aa0c4df9dc8611f3a85fc *man/stat_contour.Rd
+293bafd6a08db7a9faad4a3c820ccfdd *man/stat_density.Rd
+76e9de05d016f140db5182c176d70521 *man/stat_density2d.Rd
+45d4c125c025d6a3e8ea1872452f8236 *man/stat_ecdf.Rd
+4b8ea6b7a8ca01219bec5e1915f8699d *man/stat_ellipse.Rd
+237c33ae88026c72664f693ff42548f5 *man/stat_function.Rd
+ddc1023a60fdeb4332cd04c85b2a39c6 *man/stat_hline.Rd
+aa2e4700f7fd740ff8149491d5332cef *man/stat_identity.Rd
+25c8f08b7637986abdc1f4f0f2fa24b8 *man/stat_qq.Rd
+c7976ece441c2b62f0e31e3fbfa605a9 *man/stat_quantile.Rd
+bf110be85fd2cfffc2e072802fedc4c3 *man/stat_smooth.Rd
+2d1f28ae85c9567e87b4d03eab3f66f6 *man/stat_spoke.Rd
+73cbf962c8edf60672e187143151f793 *man/stat_sum.Rd
+106b446f3c2c59aee5fd032a17625572 *man/stat_summary.Rd
+d48aa6256f13beff3bf40f25921e38d6 *man/stat_summary2d.Rd
+56daa0415799866e0ea7f99142f31df5 *man/stat_summary_hex.Rd
+35a8a33a5198dacb41102c7734d0379b *man/stat_unique.Rd
+32dcbd9d52c465aceac487863c63b23c *man/stat_vline.Rd
+1844eb183cb3c3910c12b3154a073ddf *man/stat_ydensity.Rd
+bfe2c67649561276d95a377cfbc1f170 *man/summary.ggplot.Rd
+bd089e0f26fe80f50a6c271349615e26 *man/theme.Rd
+4bbcaa73d9086577fa6c1d7a20968bbf *man/theme_blank.Rd
+4b9364f726a6fe44740a488fcc7ef315 *man/theme_update.Rd
+5c0412147657f587bedc5b4e6ebec40b *man/translate_qplot_base.Rd
+c90de971dd5f9c92380bc46e86d4c442 *man/translate_qplot_ggplot.Rd
+bdacfb766b1e6bf288889118add438b1 *man/translate_qplot_gpl.Rd
+79bb7419c839004ce940a2495682bc71 *man/translate_qplot_lattice.Rd
+abcbac9f95beddfdefadea13608c0648 *man/update_defaults.Rd
+21263c23f856d8a89f84c4fb73a7c86e *man/update_element.Rd
+8db8abc4c568a33518ea9bf27c507ae2 *man/update_labels.Rd
+c5d75ae1ce6e8d5a49b10c4142a6d327 *man/waiver.Rd
+aa223bee34839695884bb45e35646b84 *man/xylim.Rd
+88d4bc179cb552861bd6d79496409493 *man/zeroGrob.Rd
18ce871dfe61dcdd288c02929f1b55d7 *tests/test-all.R
+ca9a9bfa8225e85a1400d060568ada6a *vignettes/development.Rmd
+031c78a8fbe505a4ee120726f622d005 *vignettes/release.Rmd
diff --git a/NAMESPACE b/NAMESPACE
index 8598ef0..69b10df 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -1,3 +1,5 @@
+# Generated by roxygen2 (4.0.1): do not edit by hand
+
S3method("+",gg)
S3method("[",uneval)
S3method(as.character,uneval)
@@ -6,6 +8,7 @@ S3method(coord_aspect,default)
S3method(coord_aspect,fixed)
S3method(coord_aspect,map)
S3method(coord_aspect,polar)
+S3method(coord_aspect,quickmap)
S3method(coord_distance,cartesian)
S3method(coord_distance,map)
S3method(coord_distance,polar)
@@ -177,6 +180,7 @@ export("%+replace%")
export(aes)
export(aes_all)
export(aes_auto)
+export(aes_q)
export(aes_string)
export(annotate)
export(annotation_custom)
@@ -195,6 +199,7 @@ export(coord_fixed)
export(coord_flip)
export(coord_map)
export(coord_polar)
+export(coord_quickmap)
export(coord_trans)
export(cut_interval)
export(cut_number)
@@ -270,6 +275,8 @@ export(label_both)
export(label_bquote)
export(label_parsed)
export(label_value)
+export(label_wrap_gen)
+export(labeller)
export(labs)
export(last_plot)
export(layer)
@@ -285,6 +292,7 @@ export(position_dodge)
export(position_fill)
export(position_identity)
export(position_jitter)
+export(position_jitterdodge)
export(position_stack)
export(qplot)
export(quickplot)
@@ -299,6 +307,7 @@ export(scale_area)
export(scale_color_brewer)
export(scale_color_continuous)
export(scale_color_discrete)
+export(scale_color_distiller)
export(scale_color_gradient)
export(scale_color_gradient2)
export(scale_color_gradientn)
@@ -309,6 +318,7 @@ export(scale_color_manual)
export(scale_colour_brewer)
export(scale_colour_continuous)
export(scale_colour_discrete)
+export(scale_colour_distiller)
export(scale_colour_gradient)
export(scale_colour_gradient2)
export(scale_colour_gradientn)
@@ -319,6 +329,7 @@ export(scale_colour_manual)
export(scale_fill_brewer)
export(scale_fill_continuous)
export(scale_fill_discrete)
+export(scale_fill_distiller)
export(scale_fill_gradient)
export(scale_fill_gradient2)
export(scale_fill_gradientn)
@@ -367,6 +378,7 @@ export(stat_contour)
export(stat_density)
export(stat_density2d)
export(stat_ecdf)
+export(stat_ellipse)
export(stat_function)
export(stat_hline)
export(stat_identity)
@@ -388,7 +400,9 @@ export(theme_classic)
export(theme_get)
export(theme_gray)
export(theme_grey)
+export(theme_light)
export(theme_line)
+export(theme_linedraw)
export(theme_minimal)
export(theme_rect)
export(theme_segment)
@@ -411,4 +425,6 @@ import(plyr)
import(proto)
import(reshape2)
import(scales)
+importFrom(MASS,cov.trob)
importFrom(MASS,kde2d)
+importFrom(methods,setRefClass)
diff --git a/NEWS b/NEWS
index dde899c..f76aa20 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,87 @@
+ggplot2 1.0.0
+----------------------------------------------------------------
+
+NEW FEATURES
+
+* New coordinate system for small scale maps. `coord_quickmap()` computes and
+ sets the correct aspect ratio between one degree of latitude and one degree
+ of longitude at the centre of the plotted region. It does not perform full
+ fledged mapping projection as `coord_map()` does and therefore is much
+ faster. Yet, it gives a correct approximation for small scale maps (a few
+ degrees in either direction) at medium to low latitudes (@jiho, #922).
+
+* `geom_boxplot` gain new `varwidth` argument for controlling whether or not
+ the width of boxplots should be proportional to the size of the groups
+ (@tsieger, #927).
+
+* `position_jitterdodge()` combines `position_jitter()` and `position_dodge()`,
+ allowing the user to plot and align points generated by e.g. `geom_point()`
+ with those generated by a dodged `geom_boxplot()`. See
+ `example(position_jitterdodge)` for a potential usage. (@kevinushey, #932)
+
+* Allow specifying only one of the limits in a scale and use the automatic
+ calculation of the other limit by passing NA to to the limit function,
+ `xlim()` or `ylim()` (@jimhester, #557).
+
+* Allow to use brewer palettes for continuous scales, through the new
+ `scale_fill/colour_distiller()` functions (@jiho, #925).
+
+* `stat_ellipse()` adds data ellipses. It supports bivariate normal and t distributions,
+ as well as a euclidian distance circle. (@jofrhwld, #926)
+
+* Add new themes: `theme_linedraw()` is similar to `theme_bw()` but with
+ truly only white and black elements and spacing between elements identical
+ to `theme_gray`. `theme_light` is similar but with light gray box and axes
+ around the plot, to emphasise content more (@jiho, #923)
+
+* new theme settings panel.margin.x and panel.margin.y (units) allow
+ specifying horizontal and vertical gap between panels in facetted plots (for
+ both grid and wrap). (Kirill Müller. Fixes #839)
+
+* Fix vertical justification for rotated text. This will change the appearance
+ of plots that use textual elements that are rotated by 90° or 270° and have a
+ `vjust` parameter other than the default 0.5; the interpretation of `vjust`
+ and `hjust` is now the same for both rotated and non-rotated text elements
+ (0 = top/left, 1 = bottom/right, 0.5 = centered). (@krlmlr, #883)
+
+* Added helper function `labeller()` for formatting faceting values.
+ (@stefanedwards, #910). Added `label_wrap_gen` based on
+ https://github.com/hadley/ggplot2/wiki/labeller#writing-new-labellers
+ (@stefanedwards, #910)
+
+BUG FIXES AND MINOR IMPROVEMENTS
+
+* `aes()` no more treats variables like `a..x..b as a calculated aesthetic.
+ (@krlmlr, #834.)
+
+* New `aes_q()` function to generate aesthetic specifications from
+ quoted calls/names. `aes_string()` uses names `x` and `y` for first
+ two unnamed arguments.
+
+* `fortify.SpatialPolygonsDataFrame()` now calls `polygons` without
+ requiring the `sp` to be loaded first (@seancarmody, #879).
+
+* The outliers of `geom_boxplot()` use the default colour, size and shape from
+ `geom_point()`. Changing the defaults of `geom_point()` with
+ `update_geom_defaults()` will apply the same changes to the outliers of
+ `geom_boxplot()`. Changing the defaults for the outliers was previously not
+ possible. (@ThierryO, #757)
+
+* `geom_dotplot()` now works with `qplot()`. (@rasmusab. Fixes #825)
+
+* Marginal improvements to `theme_bw()` and `theme_classic()` (@jiho, #934)
+
+* `stat_smooth()` checks for `method = "auto"` and `method = "glm"` in
+ a safer way.
+
+* Add `"none"` to documentation of `theme()` for parameter `legend.position`
+ (@krlmlr, #829).
+
+REMOVED FUNCTIONALITY
+
+* `ggpcp()`, `ggfluctuation()`, `ggmissing()`, `ggstructure()`, and
+ `ggorder()` are now defunct and have been removed.
+
ggplot2 0.9.3.1
----------------------------------------------------------------
@@ -256,7 +340,7 @@ ggplot2 0.9.1
MINOR FEATURES
-* `ggstructure` and `ggorder`, which call `ggpcp`, no longer have a
+* `ggstructure` and `ggorder`, which call `ggpcp`, no longer have a
`scale` argument since `ggpcp` does not have one.
* built in datasets have been checked to make sure they use characters,
@@ -323,7 +407,7 @@ BUG FIXES
* `scale_*_manual` will throw an error if you have too few values. (Fixes
#512)
-
+
* `facet_wrap` gets the `as.table` argument back. (Fixes #497)
* `resolution` now returns 1 when range is zero. (Fixes #526)
@@ -444,7 +528,7 @@ SCALES
scale for an aesthetic, just create a function called
`scale_aesthetic_continuous` or `scale_aesthetic_discrete` that returns the
scale that you want. For example:
-
+
p <- qplot(mpg, wt, data = mtcars, colour = factor(cyl))
p
scale_colour_discrete <- scale_colour_brewer
@@ -469,7 +553,7 @@ FACETS
faceting. This special case is implemented more efficiently and results in
substantial performance improvements for non-facetted plots.
-* Facetting variables will no longer interfere with aesthetic mappings -
+* Facetting variables will no longer interfere with aesthetic mappings -
`facet_wrap(~ colour)` will no longer affect the colour of points.
DEVELOPMENT
@@ -500,7 +584,7 @@ COORDS
coordinates have been transformed to other names (eg., theta and r). (Thanks
to Winston Chang)
-RENDERING
+RENDERING
* When printing a ggplot2 object, the rendered plot information is returned
invisibly. You can capture this with (e.g.) `x <- print(qplot(mpg, wt, data
@@ -568,7 +652,7 @@ MINOR CHANGES
specific to a given data structure. Default implementation throws
an error. It is designed to have implementations provided by other
packages. (Thanks to suggestion by Brian Diggs)
-
+
* `ggpcp` loses the `scale` argument because it relied on reshape(1) code
* `map_data` passes `...` on to `maps::map` (Fixes #223)
@@ -582,7 +666,7 @@ MINOR CHANGES
* `stat_binhex` uses correct bin width for computing y axis bounds. (Fixes
#299, thanks to Dave Henderson for bug report and fix.)
-* `stat_smooth` now adjusts confidence intervals from `loess` using a
+* `stat_smooth` now adjusts confidence intervals from `loess` using a
t-based approximation
* `stat_smooth` reports what method is used when method is "auto". It also
@@ -590,7 +674,7 @@ MINOR CHANGES
group. (Thanks to Winston Chang)
* `stat_bin` and `geom_histogram` now use right-open, left-closed intervals by
- default. Use `right = TRUE` to return to previous behaviour.
+ default. Use `right = TRUE` to return to previous behaviour.
* `geom_vline`, `geom_hline`, and `geom_abline` now work with non-Cartesian
coordinate systems. (Thanks to Winston Chang)
@@ -668,7 +752,7 @@ BUG FIXES
* stat_function: now works without y values
-* stat_smooth: draw line if only 2 unique x values, not three as previously
+* stat_smooth: draw line if only 2 unique x values, not three as previously
* guides: fixed #126
@@ -700,7 +784,7 @@ Bug fixes:
* geom_hline and geom_vline will not impact legend when used for fixed
intercepts
-* geom_hline/geom_vline: intercept values not set quite correctly which
+* geom_hline/geom_vline: intercept values not set quite correctly which
caused a problem in conjunction with transformed scales (reported by Seth
Finnegan)
@@ -753,7 +837,7 @@ ggplot2 0.8.7
* coord_map gains xlim and ylim arguments to control region of projection
-* corrected label generation for computed aesthetics (..x..) and special
+* corrected label generation for computed aesthetics (..x..) and special
names (`x x`)
* fullseq: now always returns vector of length two, even when range is 0
@@ -769,10 +853,10 @@ ggplot2 0.8.7
* stat_bin2d: fix typo in breaks calculation
-* stat_bin: deals with floating point rounding issues using the same
+* stat_bin: deals with floating point rounding issues using the same
algorithm as base::hist
-* stat_density2d: fixed bug when contour = FALSE (Thanks to Takahashi Kohske)
+* stat_density2d: fixed bug when contour = FALSE (Thanks to Takahashi Kohske)
ggplot2 0.8.6
@@ -849,30 +933,30 @@ NEW FEATURES
* coord_equal: when ratio = NULL (the default), it will adjust the aspect
ratio of the plot, rather than trying to extend the shortest axis.
-* x and y positions can be set to Inf or -Inf to refer to the top/right and
+* x and y positions can be set to Inf or -Inf to refer to the top/right and
bottom/left extents of the panel. (Implements #18)
-* expand_limits(): a new function to make it easy to force the inclusion of
+* expand_limits(): a new function to make it easy to force the inclusion of
any set of values in the limits of any aesthetic.
NEW FEATURES (MINOR)
-* aesthetics: when _setting_ an aesthetic, you may only set it to a single
- value. This was always a good idea, but now it is enforced with an
+* aesthetics: when _setting_ an aesthetic, you may only set it to a single
+ value. This was always a good idea, but now it is enforced with an
informative error message.
* stat_contour bump up default number of contours
-* stat_density2d: make number of grid points used for density estimation
+* stat_density2d: make number of grid points used for density estimation
user controllable (implements #9)
-* geom_bin now allows you to set whether bins used intervals of the form
+* geom_bin now allows you to set whether bins used intervals of the form
(a, b] or [a, b) with the "right" parameter (implements #20)
-* geom_path: linejoin, lineend and linemitre are now user controllable
+* geom_path: linejoin, lineend and linemitre are now user controllable
(implements #24)
-* scales: all scales check that breaks are supplied if labels are, and
+* scales: all scales check that breaks are supplied if labels are, and
that breaks and labels are the same length (implements #40)
* scales: if breaks are a named vector, the names will be used as labels
@@ -895,10 +979,10 @@ BUG FIXES
* coord_polar correctly combines labels on end of axis if expressions
(fixes #39)
-* coord_trans now respects scale expand parameter (expansion occurs after
+* coord_trans now respects scale expand parameter (expansion occurs after
transformation) (fixes #14)
-* facet_grid with scales = "free" and space = "free" now calculates space
+* facet_grid with scales = "free" and space = "free" now calculates space
correctly if the range of the scale is < 1 (fixes #1)
* facet_grid works once more when facetting with multiple variables in one
@@ -921,7 +1005,7 @@ BUG FIXES
* legends will only merge if both the title and all labels are the same.
(fixes #16)
-* legends: fix for bug #19: Legend with three constraints doesn't work
+* legends: fix for bug #19: Legend with three constraints doesn't work
* stat_contour & stat_density2d: fix grouping bugs (issue #7)
@@ -985,7 +1069,7 @@ New features
* labels_parsed and labels_bquote functions to make it easier to display expressions on facet labels
-* scale_manual now supports breaks and limits
+* scale_manual now supports breaks and limits
* subset: experimental new feature. Layers now have a subset argument, which takes subsets formatted like .(var1 < 5, var2 == 3) etc.
@@ -1355,7 +1439,7 @@ ggplot2 0.7
Bugs fixed
-* geom_boxplot: now displays outliers even if only one present
+* geom_boxplot: now displays outliers even if only one present
* geom_jitter: setting one jitter direction to 0 now works
@@ -1480,7 +1564,7 @@ Improved documentation and error messages
ggplot2 0.6
----------------------------------------------------------------
-The two big changes in this release are improved documentation and legends.
+The two big changes in this release are improved documentation and legends.
* all major ggplot2 components now have their own built in documentation, so
that (e.g.) ?stat_smooth or ?geom_point now give you useful information
@@ -1493,7 +1577,7 @@ The two big changes in this release are improved documentation and legends.
geom_smooth, geom_boxplot, geom_vline, geom_abline, geom_pointrange).
These features are new, so there are likely to be a few bugs that I haven't discovered. Please me know if you discover any.
-
+
Other additions and corrections
* coord_equal: should now work correctly in all situations
@@ -1769,7 +1853,7 @@ Other improvements:
control purposes
New data:
-
+
* seals, contributed by David Brillinger and Charlotte Wickham, used for
vector field example
@@ -1777,7 +1861,7 @@ Bug fixes:
* geoms hline, vline and abline now all work correctly when a grouping variable is used
-* block histograms (where individuals are identifiable) now work correctly
+* block histograms (where individuals are identifiable) now work correctly
* all ggplot objects should now print properly from the command line
@@ -1862,7 +1946,7 @@ Bug fixes:
distribution function
Subtractions:
-
+
* removed grid argument from ggsave, replaced by ggtheme(theme_bw)
* removed add argument from qplot
@@ -1887,7 +1971,7 @@ ggplot2 0.5.3
* added new border.colour and grid.minor.colour options for better control
over plot apperance
-* updated theme_bw to do better when drawing a plot with white background
+* updated theme_bw to do better when drawing a plot with white background
* better default colour choices for gradients (and more discussion in examples)
@@ -1905,7 +1989,7 @@ ggplot2 0.5.3
ggplot2 0.5.2
----------------------------------------------------------------
-* add argument to position dodge so it's now possible to accurately dodge things with different widths to their physical widths
+* add argument to position dodge so it's now possible to accurately dodge things with different widths to their physical widths
* added median summary
diff --git a/R/aaa-.r b/R/aaa-.r
index cc2b8d7..56f5a1b 100644
--- a/R/aaa-.r
+++ b/R/aaa-.r
@@ -3,7 +3,7 @@
# Upper case first letter of string
# This comes from the examples of some R function.
-#
+#
# @keyword internal
firstUpper <- function(s) {
paste(toupper(substring(s, 1,1)), substring(s, 2), sep="")
@@ -13,7 +13,7 @@ TopLevel <- proto(expr = {
find_all <- function(., only.documented = FALSE) {
names <- ls(pattern=paste("^", firstUpper(.$class()), "[A-Z].+", sep=""), parent.env(TopLevel))
objs <- structure(lapply(names, get), names=names)
-
+
if (only.documented) objs <- objs[sapply(objs, function(x) get("doc", x))]
objs
}
@@ -24,13 +24,13 @@ TopLevel <- proto(expr = {
}
get(fullname)
}
-
+
my_name <- function(., prefix=TRUE) {
if (!prefix) return(.$objname)
paste(.$class(), .$objname, sep="_")
}
my_names <- function(.) .$my_name()
-
+
myName <- function(.) {
ps(firstUpper(.$class()), ps(firstUpper(strsplit(.$objname, "_")[[1]])))
}
@@ -38,16 +38,16 @@ TopLevel <- proto(expr = {
params <- function(.) {
param <- .$parameters()
if (length(param) == 0) return()
-
+
if(!exists("required_aes", .)) return(param)
-
+
aesthetics <- c(.$required_aes, names(.$default_aes()))
param[setdiff(names(param), aesthetics)]
}
})
-#' @S3method print proto
+#' @export
print.proto <- function(x, ...) x$pprint(...)
pprint <- function(x, ...) print(as.list(x), ...)
# name.proto <- function (...) {
diff --git a/R/aes-calculated.r b/R/aes-calculated.r
new file mode 100644
index 0000000..139ba37
--- /dev/null
+++ b/R/aes-calculated.r
@@ -0,0 +1,45 @@
+# Regex to determine if an identifier refers to a calculated aesthetic
+match_calculated_aes <- "^\\.\\.([a-zA-Z._]+)\\.\\.$"
+
+# Determine if aesthetic is calculated
+is_calculated_aes <- function(aesthetics) {
+ vars <- lapply(aesthetics, find_vars)
+
+ vapply(vars, function(x) any(grepl(match_calculated_aes, x)), logical(1))
+}
+
+find_vars <- function(expr) {
+ if (is.name(expr)) {
+ as.character(expr)
+ } else if (is.atomic(expr)) {
+ character()
+ } else if (is.call(expr)) {
+ unlist(lapply(expr[-1], find_vars))
+ } else if (is.pairlist(expr)) {
+ # In the unlikely event of an anonymous function
+ unlist(lapply(expr, find_vars))
+ } else {
+ stop("Unknown input:", class(expr)[1])
+ }
+}
+
+# Strip dots from expressions
+strip_dots <- function(expr) {
+ if (is.atomic(expr)) {
+ expr
+ } else if (is.name(expr)) {
+ as.name(gsub(match_calculated_aes, "\\1", as.character(expr)))
+ } else if (is.call(expr)) {
+ expr[-1] <- lapply(expr[-1], strip_dots)
+ expr
+ } else if (is.pairlist(expr)) {
+ # In the unlikely event of an anonymous function
+ as.pairlist(lapply(expr, expr))
+ } else if (is.list(expr)) {
+ # For list of aesthetics
+ lapply(expr, strip_dots)
+ } else {
+ stop("Unknown input:", class(expr)[1])
+ }
+}
+
diff --git a/R/aes-colour-fill-alpha.r b/R/aes-colour-fill-alpha.r
index be9b201..ff60ec6 100644
--- a/R/aes-colour-fill-alpha.r
+++ b/R/aes-colour-fill-alpha.r
@@ -1,13 +1,13 @@
#' Colour related aesthetics: colour, fill and alpha
-#'
-#' This page demonstrates the usage of a sub-group
+#'
+#' This page demonstrates the usage of a sub-group
#' of aesthetics; colour, fill and alpha.
#'
#' @name aes_colour_fill_alpha
-#' @aliases colour color fill alpha
+#' @aliases colour color fill alpha
#' @examples
#' \donttest{
-#'
+#'
#' # Bar chart example
#' c <- ggplot(mtcars, aes(factor(cyl)))
#' # Default plotting
@@ -18,7 +18,7 @@
#' c + geom_bar(colour = "red")
#' # Combining both, you can see the changes more clearly
#' c + geom_bar(fill = "white", colour = "red")
-#'
+#'
#' # The aesthetic fill also takes different colouring scales
#' # setting fill equal to a factor varible uses a discrete colour scale
#' k <- ggplot(mtcars, aes(factor(cyl), fill = factor(vs)))
@@ -35,7 +35,7 @@
#' b + geom_line(colour = "green")
#' b + geom_point()
#' b + geom_point(colour = "red")
-#'
+#'
#' # For large datasets with overplotting the alpha
#' # aesthetic will make the points more transparent
#' df <- data.frame(x = rnorm(5000), y = rnorm(5000))
@@ -44,15 +44,15 @@
#' h + geom_point(alpha = 0.5)
#' h + geom_point(alpha = 1/10)
#'
-#' #If a geom uses both fill and colour, alpha will only modify the fill colour
+#' #If a geom uses both fill and colour, alpha will only modify the fill colour
#' c + geom_bar(fill = "dark grey", colour = "black")
#' c + geom_bar(fill = "dark grey", colour = "black", alpha = 1/3)
-#'
+#'
#' # Alpha can also be used to add shading
#' j <- b + geom_line()
#' j
#' yrng <- range(economics$unemploy)
-#' j <- j + geom_rect(aes(NULL, NULL, xmin = start, xmax = end, fill = party),
+#' j <- j + geom_rect(aes(NULL, NULL, xmin = start, xmax = end, fill = party),
#' ymin = yrng[1], ymax = yrng[2], data = presidential)
#' j
#' library(scales) # to access the alpha function
diff --git a/R/aes-group-order.r b/R/aes-group-order.r
index 85f90a7..662497c 100644
--- a/R/aes-group-order.r
+++ b/R/aes-group-order.r
@@ -1,21 +1,21 @@
#' Aesthetics: group, order
-#'
+#'
#' @name aes_group_order
-#' @aliases group order
-#'
-#' @examples
+#' @aliases group order
+#'
+#' @examples
#' \donttest{
-#'
+#'
#' # By default, the group is set to the interaction of all discrete variables in the
#' # plot. This often partitions the data correctly, but when it does not, or when
#' # no discrete variable is used in the plot, you will need to explicitly define the
#' # grouping structure, by mapping group to a variable that has a different value
#' # for each group.
-#'
-#' # For most applications you can simply specify the grouping with
-#' # various aesthetics (colour, shape, fill, linetype) or with facets.
#'
-#' p <- ggplot(mtcars, aes(wt, mpg))
+#' # For most applications you can simply specify the grouping with
+#' # various aesthetics (colour, shape, fill, linetype) or with facets.
+#'
+#' p <- ggplot(mtcars, aes(wt, mpg))
#' # A basic scatter plot
#' p + geom_point(size = 4)
#' # The colour aesthetic
@@ -28,28 +28,28 @@
#' a + geom_bar()
#' a + geom_bar(aes(fill = factor(cyl)))
#' a + geom_bar(aes(fill = factor(vs)))
-#'
+#'
#' # Using linetypes
#' library(reshape2) # for melt
#' library(plyr) # for colwise
#' rescale01 <- function(x) (x - min(x)) / diff(range(x))
#' ec_scaled <- data.frame(
-#' date = economics$date,
-#' colwise(rescale01)(economics[, -(1:2)]))
+#' date = economics$date,
+#' colwise(rescale01)(economics[, -(1:2)]))
#' ecm <- melt(ec_scaled, id = "date")
#' f <- ggplot(ecm, aes(date, value))
#' f + geom_line(aes(linetype = variable))
-#'
+#'
#' # Using facets
#' k <- ggplot(diamonds, aes(carat, ..density..)) + geom_histogram(binwidth = 0.2)
#' k + facet_grid(. ~ cut)
-#'
+#'
#' # There are three common cases where the default is not enough, and we
#' # will consider each one below. In the following examples, we will use a simple
#' # longitudinal dataset, Oxboys, from the nlme package. It records the heights
#' # (height) and centered ages (age) of 26 boys (Subject), measured on nine
#' # occasions (Occasion).
-#'
+#'
#' # Multiple groups with one aesthetic
#' library(nlme)
#' h <- ggplot(Oxboys, aes(age, height))
@@ -57,16 +57,16 @@
#' h + geom_line()
#' # The group aesthetic maps a different line for each subject
#' h + geom_line(aes(group = Subject))
-#'
+#'
#' # Different groups on different layers
-#' h <- h + geom_line(aes(group = Subject))
+#' h <- h + geom_line(aes(group = Subject))
#' # Using the group aesthetic with both geom_line() and geom_smooth()
#' # groups the data the same way for both layers
#' h + geom_smooth(aes(group = Subject), method = "lm", se = FALSE)
-#' # Changing the group aesthetic for the smoother layer
+#' # Changing the group aesthetic for the smoother layer
#' # fits a single line of best fit across all boys
#' h + geom_smooth(aes(group = 1), size = 2, method = "lm", se = FALSE)
-#'
+#'
#' # Overriding the default grouping
#' # The plot has a discrete scale but you want to draw lines that connect across
#' # groups. This is the strategy used in interaction plots, profile plots, and parallel
@@ -79,12 +79,12 @@
#' # we again need to override the default grouping for that layer with aes(group = Subject)
#' boysbox <- boysbox + geom_boxplot()
#' boysbox + geom_line(aes(group = Subject), colour = "blue")
-#'
+#'
#' # Use the order aesthetic to change stacking order of bar charts
-#' w <- ggplot(diamonds, aes(clarity, fill = cut))
+#' w <- ggplot(diamonds, aes(clarity, fill = cut))
#' w + geom_bar()
#' w + geom_bar(aes(order = desc(cut)))
-#'
+#'
#' # Can also be used to change plot order of scatter plots
#' d <- ggplot(diamonds, aes(carat, price, colour = cut))
#' d + geom_point()
diff --git a/R/aes-linetype-size-shape.r b/R/aes-linetype-size-shape.r
index 2dd59d4..e9c6a29 100644
--- a/R/aes-linetype-size-shape.r
+++ b/R/aes-linetype-size-shape.r
@@ -1,10 +1,10 @@
#' Differentiation related aesthetics: linetype, size, shape
-#'
-#' This page demonstrates the usage of a sub-group
+#'
+#' This page demonstrates the usage of a sub-group
#' of aesthetics; linetype, size and shape.
-#'
+#'
#' @name aes_linetype_size_shape
-#' @aliases linetype size shape
+#' @aliases linetype size shape
#' @examples
#'
#' # Line types should be specified with either an integer, a name, or with a string of
@@ -18,8 +18,8 @@
#' f + geom_line(linetype = 2)
#' f + geom_line(linetype = "dotdash")
#
-#' # An example with hex strings, the string "33" specifies three units on followed
-#' # by three off and "3313" specifies three units on followed by three off followed
+#' # An example with hex strings, the string "33" specifies three units on followed
+#' # by three off and "3313" specifies three units on followed by three off followed
#' # by one on and finally three off.
#' f + geom_line(linetype = "3313")
#'
@@ -28,19 +28,19 @@
#' library(reshape2)
#' rescale01 <- function(x) (x - min(x)) / diff(range(x))
#' ec_scaled <- data.frame(
-#' date = economics$date,
-#' colwise(rescale01)(economics[, -(1:2)]))
+#' date = economics$date,
+#' colwise(rescale01)(economics[, -(1:2)]))
#' ecm <- melt(ec_scaled, id = "date")
#' qplot(date, value, data = ecm, geom = "line", linetype = variable)
-#'
+#'
#' # Size examples
-#' # Should be specified with a numerical value (in millimetres),
+#' # Should be specified with a numerical value (in millimetres),
#' # or from a variable source
#' p <- ggplot(mtcars, aes(wt, mpg))
#' p + geom_point(size = 4)
#' p + geom_point(aes(size = qsec))
#' p + geom_point(size = 2.5) + geom_hline(yintercept = 25, size = 3.5)
-#'
+#'
#' # Shape examples
#' # Shape takes four types of values: an integer in [0, 25],
#' # a single character-- which uses that character as the plotting symbol,
@@ -54,15 +54,15 @@
#'
#' # Shape can also be mapped from a variable
#' p + geom_point(aes(shape = factor(cyl)))
-#'
+#'
#' # A look at all 25 symbols
#' df2 <- data.frame(x = 1:5 , y = 1:25, z = 1:25)
#' s <- ggplot(df2, aes(x = x, y = y))
#' s + geom_point(aes(shape = z), size = 4) + scale_shape_identity()
#' # While all symbols have a foreground colour, symbols 19-25 also take a
#' # background colour (fill)
-#' s + geom_point(aes(shape = z), size = 4, colour = "Red") +
+#' s + geom_point(aes(shape = z), size = 4, colour = "Red") +
#' scale_shape_identity()
-#' s + geom_point(aes(shape = z), size = 4, colour = "Red", fill = "Black") +
+#' s + geom_point(aes(shape = z), size = 4, colour = "Red", fill = "Black") +
#' scale_shape_identity()
NULL
diff --git a/R/aes-position.r b/R/aes-position.r
index 5712409..22e4965 100644
--- a/R/aes-position.r
+++ b/R/aes-position.r
@@ -1,42 +1,48 @@
#' Position related aesthetics: x, y, xmin, xmax, ymin, ymax, xend, yend
-#'
-#' This page demonstrates the usage of a sub-group
+#'
+#' This page demonstrates the usage of a sub-group
#' of aesthetics; x, y, xmin, xmax, ymin, ymax, xend, and yend.
#'
#' @name aes_position
-#' @aliases x y xmin xmax ymin ymax xend yend
+#' @aliases x y xmin xmax ymin ymax xend yend
#' @examples
-#'
-#' # Generate data: means and standard errors of means for prices
-#' # for each type of cut
-#' dmod <- lm(price ~ cut, data = diamonds)
-#' cuts <- data.frame(cut = unique(diamonds$cut), predict(dmod, data.frame(cut =
+#'
+#' # Generate data: means and standard errors of means for prices
+#' # for each type of cut
+#' dmod <- lm(price ~ cut, data = diamonds)
+#' cuts <- data.frame(cut = unique(diamonds$cut), predict(dmod, data.frame(cut =
#' unique(diamonds$cut)), se = TRUE)[c("fit", "se.fit")])
-#' se <- ggplot(cuts, aes(x = cut, y = fit, ymin = fit - se.fit,
-#' ymax = fit + se.fit, colour = cut))
+#' se <- ggplot(cuts, aes(x = cut, y = fit, ymin = fit - se.fit,
+#' ymax = fit + se.fit, colour = cut))
#' se + geom_pointrange()
#'
#' # Boxplot with precomputed statistics
#' # generate sample data
#' library(plyr)
#' abc <- adply(matrix(rnorm(100), ncol = 5), 2, quantile, c(0, .25, .5, .75, 1))
-#' b <- ggplot(abc, aes(x = X1, ymin = "0%", lower = "25%", middle = "50%", upper = "75%", ymax = "100%"))
+#' b <- ggplot(abc, aes(x = X1, ymin = "0%", lower = "25%",
+#' middle = "50%", upper = "75%", ymax = "100%"))
#' b + geom_boxplot(stat = "identity")
#'
#' # Using annotate
#' p <- ggplot(mtcars, aes(wt, mpg)) + geom_point()
-#' p + annotate("rect", xmin = 2, xmax = 3.5, ymin = 2, ymax = 25, fill = "dark grey", alpha = .5)
-#'
+#' p + annotate("rect", xmin = 2, xmax = 3.5, ymin = 2, ymax = 25,
+#' fill = "dark grey", alpha = .5)
+#'
#' # Geom_segment examples
#' library(grid)
-#' p + geom_segment(aes(x = 2, y = 15, xend = 2, yend = 25), arrow = arrow(length = unit(0.5, "cm")))
-#' p + geom_segment(aes(x = 2, y = 15, xend = 3, yend = 15), arrow = arrow(length = unit(0.5, "cm")))
-#' p + geom_segment(aes(x = 5, y = 30, xend = 3.5, yend = 25), arrow = arrow(length = unit(0.5, "cm")))
+#' p + geom_segment(aes(x = 2, y = 15, xend = 2, yend = 25),
+#' arrow = arrow(length = unit(0.5, "cm")))
+#' p + geom_segment(aes(x = 2, y = 15, xend = 3, yend = 15),
+#' arrow = arrow(length = unit(0.5, "cm")))
+#' p + geom_segment(aes(x = 5, y = 30, xend = 3.5, yend = 25),
+#' arrow = arrow(length = unit(0.5, "cm")))
#'
-#' # You can also use geom_segment to recreate plot(type = "h") :
-#' counts <- as.data.frame(table(x = rpois(100, 5)))
-#' counts$x <- as.numeric(as.character(counts$x))
+#' # You can also use geom_segment to recreate plot(type = "h") :
+#' counts <- as.data.frame(table(x = rpois(100, 5)))
+#' counts$x <- as.numeric(as.character(counts$x))
#' with(counts, plot(x, Freq, type = "h", lwd = 10))
-#'
-#' qplot(x, Freq, data = counts, geom = "segment", yend = 0, xend = x, size = I(10))
+#'
+#' qplot(x, Freq, data = counts, geom = "segment", yend = 0, xend = x,
+#' size = I(10))
NULL
diff --git a/R/aes.r b/R/aes.r
index 9ecc2c3..c89339e 100644
--- a/R/aes.r
+++ b/R/aes.r
@@ -9,38 +9,32 @@
.base_to_ggplot <- c(
"col" = "colour",
- "color" = "colour",
+ "color" = "colour",
"pch" = "shape",
- "cex" = "size",
- "lty" = "linetype",
+ "cex" = "size",
+ "lty" = "linetype",
"lwd" = "size",
"srt" = "angle",
"adj" = "hjust",
"bg" = "fill",
"fg" = "colour",
- "min" = "ymin",
+ "min" = "ymin",
"max" = "ymax"
)
#' Generate aesthetic mappings that describe how variables in the data are
#' mapped to visual properties (aesthetics) of geoms.
-#'
+#'
#' \code{aes} creates a list of unevaluated expressions. This function also
#' performs partial name matching, converts color to colour, and old style R
#' names to ggplot names (eg. pch to shape, cex to size)
-#'
-#' @param x x value
-#' @param y y value
-#' @param ... List of name value pairs giving aesthetics to map.
-#' @seealso \code{\link{aes_string}} for passing quoted variable names.
-#" Useful when creating plots within user defined functions. Also,
+#'
+#' @param x,y,... List of name value pairs giving aesthetics to map.
+#' @family aesthetic generators
+#' @seealso See
#' \code{\link{aes_colour_fill_alpha}}, \code{\link{aes_group_order}},
#' \code{\link{aes_linetype_size_shape}} and \code{\link{aes_position}}
#' for more specific examples with different aesthetics.
-#' @S3method str uneval
-#' @S3method print uneval
-#' @S3method "[" uneval
-#' @S3method as.character uneval
#' @export
#' @examples
#' aes(x = mpg, y = wt)
@@ -49,10 +43,14 @@ aes <- function(x, y, ...) {
aes <- structure(as.list(match.call()[-1]), class="uneval")
rename_aes(aes)
}
+#' @export
print.uneval <- function(x, ...) str(unclass(x))
+#' @export
str.uneval <- function(object, ...) str(unclass(object), ...)
-"[.uneval" <- function(x, i, ...) structure(unclass(x)[i], class = "uneval")
+#' @export
+"[.uneval" <- function(x, i, ...) structure(unclass(x)[i], class = "uneval")
+#' @export
as.character.uneval <- function(x, ...) {
char <- as.character(unclass(x))
names(char) <- names(x)
@@ -72,7 +70,7 @@ rename_aes <- function(x) {
aes_to_scale <- function(var) {
var[var %in% c("x", "xmin", "xmax", "xend", "xintercept")] <- "x"
var[var %in% c("y", "ymin", "ymax", "yend", "yintercept")] <- "y"
-
+
var
}
@@ -81,45 +79,61 @@ is_position_aes <- function(vars) {
aes_to_scale(vars) %in% c("x", "y")
}
-#' Generate aesthetic mappings from a string
+#' Generate aesthetic mappings from a string/quoted objects
#'
#' Aesthetic mappings describe how variables in the data are mapped to visual
-#' properties (aesthetics) of geoms. Compared to aes this function operates
-#' on strings rather than expressions.
-#'
-#' \code{aes_string} is particularly useful when writing functions that create
-#' plots because you can use strings to define the aesthetic mappings, rather
-#' than having to mess around with expressions.
+#' properties (aesthetics) of geoms. \code{\link{aes}} uses non-standard
+#' evaluation to capture the variable names. These two variants use
+#' regular evaluation, which is easier to use inside functions.
+#'
+#' \code{aes_string} and \code{aes_q} are particularly useful when writing
+#' functions that create plots because you can use strings or quoted
+#' names/calls to define the aesthetic mappings, rather than having to use
+#' \code{\link{substitute}} to generate a call to \code{aes()}.
#'
-#' @param ... List of name value pairs
+#' @param x,y,... List of name value pairs
+#' @family aesthetic generators
#' @seealso \code{\link{aes}}
#' @export
#' @examples
-#' aes_string(x = "mpg", y = "wt")
-#' aes(x = mpg, y = wt)
-aes_string <- function(...) {
- mapping <- list(...)
- mapping[sapply(mapping, is.null)] <- "NULL"
-
+#' # Threee ways of generating the same aesthetics
+#' aes(mpg, wt, col = cyl, fill = NULL)
+#' aes_string("mpg", "wt", col = "cyl", fill = NULL)
+#' aes_q(quote(mpg), quote(wt), col = quote(cyl), fill = NULL)
+#'
+#' aes(col = cyl, fill = NULL)
+#' aes_string(col = "cyl", fill = NULL)
+#' aes_q(col = quote(cyl), fill = NULL)
+aes_string <- function(x = NULL, y = NULL, ...) {
+ mapping <- c(compact(list(x = x, y = y)), list(...))
+ mapping[vapply(mapping, is.null, logical(1))] <- "NULL"
+
parsed <- lapply(mapping, function(x) parse(text = x)[[1]])
structure(rename_aes(parsed), class = "uneval")
}
+#' @rdname aes_string
+#' @export
+aes_q <- function(x = NULL, y = NULL, ...) {
+ mapping <- c(compact(list(x = x, y = y)), list(...))
+ structure(rename_aes(mapping), class = "uneval")
+}
+
#' Given a character vector, create a set of identity mappings
-#'
+#'
#' @param vars vector of variable names
#' @export
-#' @examples
+#' @examples
#' aes_all(names(mtcars))
#' aes_all(c("x", "y", "col", "pch"))
aes_all <- function(vars) {
names(vars) <- vars
vars <- rename_aes(vars)
-
+
structure(
lapply(vars, function(x) parse(text=x)[[1]]),
class = "uneval"
- )
+ )
}
#' Automatic aesthetic mapping
@@ -131,11 +145,11 @@ aes_all <- function(vars) {
#' df <- data.frame(x = 1, y = 1, colour = 1, label = 1, pch = 1)
#' aes_auto(df)
#' aes_auto(names(df))
-#'
+#'
#' df <- data.frame(xp = 1, y = 1, colour = 1, txt = 1, foo = 1)
#' aes_auto(df, x = xp, label = txt)
#' aes_auto(names(df), x = xp, label = txt)
-#'
+#'
#' df <- data.frame(foo = 1:3)
#' aes_auto(df, x = xp, y = yp)
#' aes_auto(df)
@@ -165,24 +179,24 @@ aes_auto <- function(data = NULL, ...) {
# Aesthetic defaults
# Convenience method for setting aesthetic defaults
-#
+#
# @param data values from aesthetic mappings
# @param y. defaults
# @param params. user specified values
# @value a data.frame, with all factors converted to character strings
aesdefaults <- function(data, y., params.) {
updated <- modifyList(y., params. %||% list())
-
+
cols <- tryapply(defaults(data, updated), function(x) eval(x, data, globalenv()))
-
+
# Need to be careful here because stat_boxplot uses a list-column to store
# a vector of outliers
cols <- Filter(function(x) is.atomic(x) || is.list(x), cols)
list_vars <- sapply(cols, is.list)
cols[list_vars] <- lapply(cols[list_vars], I)
-
+
df <- data.frame(cols, stringsAsFactors = FALSE)
-
+
factors <- sapply(df, is.factor)
df[factors] <- lapply(df[factors], as.character)
df
diff --git a/R/annotation-custom.r b/R/annotation-custom.r
index 57e08b9..7bdf8c3 100644
--- a/R/annotation-custom.r
+++ b/R/annotation-custom.r
@@ -3,8 +3,8 @@ NULL
#' Annotation: Custom grob.
#'
-#' This is a special geom intended for use as static annnotations
-#' that are the same in every panel. These anotations will not
+#' This is a special geom intended for use as static annnotations
+#' that are the same in every panel. These anotations will not
#' affect scales (i.e. the x and y axes will not grow to cover the range
#' of the grob, and the grob will not be modified by any ggplot settings or mappings).
#'
@@ -17,39 +17,38 @@ NULL
#' location of raster
#' @export
#' @note \code{annotation_custom} expects the grob to fill the entire viewport
-#' defined by xmin, xmax, ymin, ymax. Grobs with a different (absolute) size
+#' defined by xmin, xmax, ymin, ymax. Grobs with a different (absolute) size
#' will be center-justified in that region.
#' Inf values can be used to fill the full plot panel (see examples).
#' @examples
#' # Dummy plot
#' base <- qplot(1:10, 1:10, geom = "blank") + theme_bw()
#' # Adding a table
-#' \donttest{
-#' require(gridExtra)
+#' \donttest{if (require(gridExtra)) {
#' base + annotation_custom(grob = tableGrob(head(iris[ ,1:3])),
#' xmin = 3, xmax = 6, ymin = 2, ymax = 8)
#' # full panel
#' base + annotation_custom(grob = roundrectGrob(),
#' xmin = -Inf, xmax = Inf, ymin = -Inf, ymax = Inf)
-#' }
+#' }}
#' # Inset plot
-#' g <- ggplotGrob(qplot(1, 1) +
+#' g <- ggplotGrob(qplot(1, 1) +
#' theme(plot.background = element_rect(colour = "black")))
-#' base +
+#' base +
#' annotation_custom(grob = g, xmin = 1, xmax = 10, ymin = 8, ymax = 10)
-annotation_custom <- function (grob, xmin = -Inf, xmax = Inf, ymin = -Inf, ymax = Inf) {
- GeomCustomAnn$new(geom_params = list(grob = grob, xmin = xmin,
- xmax = xmax, ymin = ymin, ymax = ymax), stat = "identity",
+annotation_custom <- function (grob, xmin = -Inf, xmax = Inf, ymin = -Inf, ymax = Inf) {
+ GeomCustomAnn$new(geom_params = list(grob = grob, xmin = xmin,
+ xmax = xmax, ymin = ymin, ymax = ymax), stat = "identity",
position = "identity", data = NULL, inherit.aes = TRUE)
}
GeomCustomAnn <- proto(Geom, {
objname <- "custom_ann"
-
+
draw_groups <- function(., data, scales, coordinates, grob, xmin, xmax,
ymin, ymax, ...) {
if (!inherits(coordinates, "cartesian")) {
- stop("annotation_custom only works with Cartesian coordinates",
+ stop("annotation_custom only works with Cartesian coordinates",
call. = FALSE)
}
corners <- data.frame(x = c(xmin, xmax), y = c(ymin, ymax))
@@ -63,7 +62,7 @@ GeomCustomAnn <- proto(Geom, {
just = c("center","center"))
editGrob(grob, vp = vp)
}
-
- default_aes <- function(.)
- aes(xmin = -Inf, xmax = Inf, ymin = -Inf, ymax = Inf)
+
+ default_aes <- function(.)
+ aes(xmin = -Inf, xmax = Inf, ymin = -Inf, ymax = Inf)
})
diff --git a/R/annotation-map.r b/R/annotation-map.r
index 0b437a8..4d327dd 100644
--- a/R/annotation-map.r
+++ b/R/annotation-map.r
@@ -3,28 +3,28 @@ NULL
#' Annotation: maps.
#'
-#' @param map data frame representing a map. Most map objects can be
+#' @param map data frame representing a map. Most map objects can be
#' converted into the right format by using \code{\link{fortify}}
#' @param ... other arguments used to modify aesthetics
#' @export
#' @examples
#' library(maps)
#' usamap <- map_data("state")
-#'
+#'
#' seal.sub <- subset(seals, long > -130 & lat < 45 & lat > 40)
#' ggplot(seal.sub, aes(x = long, y = lat)) +
#' annotation_map(usamap, fill = "NA", colour = "grey50") +
#' geom_segment(aes(xend = long + delta_long, yend = lat + delta_lat))
-#'
+#'
#' seal2 <- transform(seal.sub,
#' latr = cut(lat, 2),
#' longr = cut(long, 2))
-#'
+#'
#' ggplot(seal2, aes(x = long, y = lat)) +
#' annotation_map(usamap, fill = "NA", colour = "grey50") +
#' geom_segment(aes(xend = long + delta_long, yend = lat + delta_lat)) +
#' facet_grid(latr ~ longr, scales = "free", space = "free")
-annotation_map <- function(map, ...) {
+annotation_map <- function(map, ...) {
# Get map input into correct form
stopifnot(is.data.frame(map))
@@ -32,7 +32,7 @@ annotation_map <- function(map, ...) {
if (!is.null(map$long)) map$x <- map$long
if (!is.null(map$region)) map$id <- map$region
stopifnot(all(c("x", "y", "id") %in% names(map)))
-
+
GeomAnnotationMap$new(geom_params = list(map = map, ...), data =
NULL, inherit.aes = FALSE)
}
@@ -50,10 +50,10 @@ GeomAnnotationMap <- proto(GeomMap, {
polygonGrob(coords$x, coords$y, default.units = "native",
id = grob_id,
gp = gpar(
- col = data$colour, fill = alpha(data$fill, data$alpha),
+ col = data$colour, fill = alpha(data$fill, data$alpha),
lwd = data$size * .pt))
}
-
+
required_aes <- c()
-
+
})
diff --git a/R/annotation-raster.r b/R/annotation-raster.r
index 0e3016e..7525c69 100644
--- a/R/annotation-raster.r
+++ b/R/annotation-raster.r
@@ -5,7 +5,7 @@ NULL
#' Annotation: High-performance rectangular tiling.
#'
#' This is a special version of \code{\link{geom_raster}} optimised for static
-#' annotations that are the same in every panel. These annotations will not
+#' annotations that are the same in every panel. These annotations will not
#' affect scales (i.e. the x and y axes will not grow to cover the range
#' of the raster, and the raster must already have its own colours).
#'
@@ -16,7 +16,7 @@ NULL
#' location of raster
#' @param ymin,ymax y location (in data coordinates) giving vertical
#' location of raster
-#' @param interpolate If \code{TRUE} interpolate linearly, if \code{FALSE}
+#' @param interpolate If \code{TRUE} interpolate linearly, if \code{FALSE}
#' (the default) don't interpolate.
#' @export
#' @examples
@@ -26,21 +26,21 @@ NULL
#' annotation_raster(rainbow, 15, 20, 3, 4)
#' # To fill up whole plot
#' qplot(mpg, wt, data = mtcars) +
-#' annotation_raster(rainbow, -Inf, Inf, -Inf, Inf) +
+#' annotation_raster(rainbow, -Inf, Inf, -Inf, Inf) +
#' geom_point()
#'
#' rainbow2 <- matrix(hcl(seq(0, 360, length = 10), 80, 70), nrow = 1)
#' qplot(mpg, wt, data = mtcars) +
-#' annotation_raster(rainbow2, -Inf, Inf, -Inf, Inf) +
+#' annotation_raster(rainbow2, -Inf, Inf, -Inf, Inf) +
#' geom_point()
#' rainbow2 <- matrix(hcl(seq(0, 360, length = 10), 80, 70), nrow = 1)
#' qplot(mpg, wt, data = mtcars) +
-#' annotation_raster(rainbow2, -Inf, Inf, -Inf, Inf, interpolate = TRUE) +
+#' annotation_raster(rainbow2, -Inf, Inf, -Inf, Inf, interpolate = TRUE) +
#' geom_point()
-annotation_raster <- function (raster, xmin, xmax, ymin, ymax, interpolate = FALSE) {
+annotation_raster <- function (raster, xmin, xmax, ymin, ymax, interpolate = FALSE) {
raster <- as.raster(raster)
- GeomRasterAnn$new(geom_params = list(raster = raster, xmin = xmin,
- xmax = xmax, ymin = ymin, ymax = ymax, interpolate = interpolate),
+ GeomRasterAnn$new(geom_params = list(raster = raster, xmin = xmin,
+ xmax = xmax, ymin = ymin, ymax = ymax, interpolate = interpolate),
stat = "identity", position = "identity", data = NULL, inherit.aes = TRUE)
}
@@ -49,11 +49,11 @@ GeomRasterAnn <- proto(GeomRaster, {
reparameterise <- function(., df, params) {
df
}
-
+
draw_groups <- function(., data, scales, coordinates, raster, xmin, xmax,
ymin, ymax, interpolate = FALSE, ...) {
if (!inherits(coordinates, "cartesian")) {
- stop("annotation_raster only works with Cartesian coordinates",
+ stop("annotation_raster only works with Cartesian coordinates",
call. = FALSE)
}
corners <- data.frame(x = c(xmin, xmax), y = c(ymin, ymax))
@@ -61,9 +61,9 @@ GeomRasterAnn <- proto(GeomRaster, {
x_rng <- range(data$x, na.rm = TRUE)
y_rng <- range(data$y, na.rm = TRUE)
-
- rasterGrob(raster, x_rng[1], y_rng[1],
- diff(x_rng), diff(y_rng), default.units = "native",
+
+ rasterGrob(raster, x_rng[1], y_rng[1],
+ diff(x_rng), diff(y_rng), default.units = "native",
just = c("left","bottom"), interpolate = interpolate)
}
})
diff --git a/R/annotation.r b/R/annotation.r
index 0600f57..6392074 100644
--- a/R/annotation.r
+++ b/R/annotation.r
@@ -7,52 +7,52 @@
#' reason don't want to put them in a data frame.
#'
#' Note that all position aesthetics are scaled (i.e. they will expand the
-#' limits of the plot so they are visible), but all other aesthetics are
+#' limits of the plot so they are visible), but all other aesthetics are
#' set. This means that layers created with this function will never
#' affect the legend.
-#'
+#'
#' @param geom name of geom to use for annotation
-#' @param x,y,xmin,ymin,xmax,ymax positionining aesthetics - you must
+#' @param x,y,xmin,ymin,xmax,ymax positionining aesthetics - you must
#' specify at least one of these.
#' @param ... other aesthetics. These are not scaled so you can do (e.g.)
-#' \code{colour = "red"} to get a red point.
+#' \code{colour = "red"} to get a red point.
#' @export
#' @examples
#' p <- ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point()
#' p + annotate("text", x = 4, y = 25, label = "Some text")
#' p + annotate("text", x = 2:5, y = 25, label = "Some text")
-#' p + annotate("rect", xmin = 3, xmax = 4.2, ymin = 12, ymax = 21,
+#' p + annotate("rect", xmin = 3, xmax = 4.2, ymin = 12, ymax = 21,
#' alpha = .2)
-#' p + annotate("segment", x = 2.5, xend = 4, y = 15, yend = 25,
+#' p + annotate("segment", x = 2.5, xend = 4, y = 15, yend = 25,
#' colour = "blue")
#' p + annotate("pointrange", x = 3.5, y = 20, ymin = 12, ymax = 28,
#' colour = "red", size = 1.5)
#'
#' p + annotate("text", x = 2:3, y = 20:21, label = c("my label", "label 2"))
annotate <- function(geom, x = NULL, y = NULL, xmin = NULL, xmax = NULL, ymin = NULL, ymax = NULL, ...) {
-
+
position <- compact(list(
- x = x, xmin = xmin, xmax = xmax,
+ x = x, xmin = xmin, xmax = xmax,
y = y, ymin = ymin, ymax = ymax
))
aesthetics <- c(position, list(...))
-
+
# Check that all aesthetic have compatible lengths
lengths <- vapply(aesthetics, length, integer(1))
unequal <- length(unique(setdiff(lengths, 1L))) > 1L
if (unequal) {
bad <- lengths != 1L
- details <- paste(names(aesthetics)[bad], " (", lengths[bad], ")",
+ details <- paste(names(aesthetics)[bad], " (", lengths[bad], ")",
sep = "", collapse = ", ")
stop("Unequal parameter lengths: ", details, call. = FALSE)
}
-
+
data <- data.frame(position)
layer(
- geom = geom,
- geom_params = list(...),
- stat = "identity",
- data = data,
+ geom = geom,
+ geom_params = list(...),
+ stat = "identity",
+ data = data,
mapping = aes_all(names(data)),
inherit.aes = FALSE,
show_guide = FALSE
diff --git a/R/autoplot.r b/R/autoplot.r
index 204e080..86a9da1 100644
--- a/R/autoplot.r
+++ b/R/autoplot.r
@@ -13,7 +13,7 @@ autoplot <- function(object, ...) {
UseMethod("autoplot")
}
-#' @S3method autoplot default
+#' @export
autoplot.default <- function(object, ...) {
error.msg <- paste("Objects of type",class(object),"not supported by autoplot. Please use qplot() or ggplot() instead.\n")
stop(error.msg, call.=FALSE)
diff --git a/R/bench.r b/R/bench.r
index 60d07f8..4096e0e 100644
--- a/R/bench.r
+++ b/R/bench.r
@@ -8,17 +8,17 @@
#' benchplot(qplot(mpg, wt, data = mtcars))
#' benchplot(qplot(mpg, wt, data = mtcars) + facet_grid(.~ cyl))
benchplot <- function(x) {
-
+
construct <- system.time(force(x))
stopifnot(inherits(x, "ggplot"))
-
+
build <- system.time(data <- ggplot_build(x))
render <- system.time(grob <- ggplot_gtable(data))
draw <- system.time(grid.draw(grob))
-
+
times <- rbind(construct, build, render, draw)[, 1:3]
-
+
unrowname(data.frame(
step = c("construct", "build", "render", "draw", "TOTAL"),
- rbind(times, colSums(times))))
+ rbind(times, colSums(times))))
}
diff --git a/R/coord-.r b/R/coord-.r
index 7a44559..872f9cd 100644
--- a/R/coord-.r
+++ b/R/coord-.r
@@ -16,28 +16,28 @@ coord <- function(..., subclass = c()) {
is.coord <- function(x) inherits(x, "coord")
distance <- function(., x, y, details) {
- max_dist <- dist_euclidean(details$x.range, details$y.range)
+ max_dist <- dist_euclidean(details$x.range, details$y.range)
dist_euclidean(x, y) / max_dist
}
coord_aspect <- function(coord, ranges)
UseMethod("coord_aspect")
-#' @S3method coord_aspect default
+#' @export
coord_aspect.default <- function(coord, ranges) NULL
coord_labels <- function(coord, scales) UseMethod("coord_labels")
-#' @S3method coord_labels default
+#' @export
coord_labels.default <- function(coord, scales) scales
-coord_render_fg <- function(coord, scales, theme)
+coord_render_fg <- function(coord, scales, theme)
UseMethod("coord_render_fg")
-#' @S3method coord_render_fg default
+#' @export
coord_render_fg.default <- function(coord, scales, theme)
element_render(theme, "panel.border")
-coord_render_bg <- function(coord, scales, theme)
+coord_render_bg <- function(coord, scales, theme)
UseMethod("coord_render_bg")
-#' @S3method coord_render_bg default
+#' @export
coord_render_bg.default <- function(coord, details, theme) {
x.major <- if(length(details$x.major) > 0) unit(details$x.major, "native")
x.minor <- if(length(details$x.minor) > 0) unit(details$x.minor, "native")
@@ -47,16 +47,16 @@ coord_render_bg.default <- function(coord, details, theme) {
guide_grid(theme, x.minor, x.major, y.minor, y.major)
}
-coord_render_axis_h <- function(coord, scales, theme)
+coord_render_axis_h <- function(coord, scales, theme)
UseMethod("coord_render_axis_h")
-#' @S3method coord_render_axis_h default
+#' @export
coord_render_axis_h.default <- function(coord, details, theme) {
guide_axis(details$x.major, details$x.labels, "bottom", theme)
}
-coord_render_axis_v <- function(coord, scales, theme)
+coord_render_axis_v <- function(coord, scales, theme)
UseMethod("coord_render_axis_v")
-#' @S3method coord_render_axis_v default
+#' @export
coord_render_axis_v.default <- function(coord, details, theme) {
guide_axis(details$y.major, details$y.labels, "left", theme)
}
@@ -64,22 +64,22 @@ coord_render_axis_v.default <- function(coord, details, theme) {
coord_range <- function(coord, scales)
UseMethod("coord_range")
-#' @S3method coord_range default
+#' @export
coord_range.default <- function(coord, scales) {
return(list(x = scales$x.range, y = scales$y.range))
}
-coord_train <- function(coord, scales)
+coord_train <- function(coord, scales)
UseMethod("coord_train")
-coord_transform <- function(coord, data, range)
+coord_transform <- function(coord, data, range)
UseMethod("coord_transform")
coord_distance <- function(coord, x, y, details)
UseMethod("coord_distance")
is.linear <- function(coord) UseMethod("is.linear")
-#' @S3method is.linear default
+#' @export
is.linear.default <- function(coord) FALSE
#' Set the default expand values for the scale, if NA
@@ -87,7 +87,7 @@ is.linear.default <- function(coord) FALSE
coord_expand_defaults <- function(coord, scale, aesthetic = NULL)
UseMethod("coord_expand_defaults")
-#' @S3method coord_expand_defaults default
+#' @export
coord_expand_defaults.default <- function(coord, scale, aesthetic = NULL) {
# Expand the same regardless of whether it's x or y
diff --git a/R/coord-cartesian-.r b/R/coord-cartesian-.r
index f5596cc..d195f71 100644
--- a/R/coord-cartesian-.r
+++ b/R/coord-cartesian-.r
@@ -4,37 +4,37 @@
#' coordinate system. Setting limits on the coordinate system will zoom the
#' plot (like you're looking at it with a magnifying glass), and will not
#' change the underlying data like setting limits on a scale will.
-#'
+#'
#' @param xlim limits for the x axis
#' @param ylim limits for the y axis
#' @param wise deprecated in 0.9.1
#' @export
-#' @examples
-#' # There are two ways of zooming the plot display: with scales or
+#' @examples
+#' # There are two ways of zooming the plot display: with scales or
#' # with coordinate systems. They work in two rather different ways.
-#'
+#'
#' (p <- qplot(disp, wt, data=mtcars) + geom_smooth())
-#'
+#'
#' # Setting the limits on a scale will throw away all data that's not
#' # inside these limits. This is equivalent to plotting a subset of
#' # the original data
#' p + scale_x_continuous(limits = c(325, 500))
-#'
+#'
#' # Setting the limits on the coordinate system performs a visual zoom
#' # the data is unchanged, and we just view a small portion of the original
-#' # plot. See how the axis labels are the same as the original data, and
+#' # plot. See how the axis labels are the same as the original data, and
#' # the smooth continue past the points visible on this plot.
#' p + coord_cartesian(xlim = c(325, 500))
-#'
+#'
#' # You can see the same thing with this 2d histogram
-#' (d <- ggplot(diamonds, aes(carat, price)) +
+#' (d <- ggplot(diamonds, aes(carat, price)) +
#' stat_bin2d(bins = 25, colour="grey50"))
-#'
+#'
#' # When zooming the scale, the we get 25 new bins that are the same
#' # size on the plot, but represent smaller regions of the data space
#' d + scale_x_continuous(limits = c(0, 2))
-#'
-#' # When zooming the coordinate system, we see a subset of original 50 bins,
+#'
+#' # When zooming the coordinate system, we see a subset of original 50 bins,
#' # displayed bigger
#' d + coord_cartesian(xlim = c(0, 2))
coord_cartesian <- function(xlim = NULL, ylim = NULL, wise = NULL) {
@@ -43,25 +43,25 @@ coord_cartesian <- function(xlim = NULL, ylim = NULL, wise = NULL) {
coord(limits = list(x = xlim, y = ylim), subclass = "cartesian")
}
-#' @S3method is.linear cartesian
+#' @export
is.linear.cartesian <- function(coord) TRUE
-#' @S3method coord_distance cartesian
+#' @export
coord_distance.cartesian <- function(coord, x, y, details) {
max_dist <- dist_euclidean(details$x.range, details$y.range)
dist_euclidean(x, y) / max_dist
-}
+}
-#' @S3method coord_transform cartesian
+#' @export
coord_transform.cartesian <- function(., data, details) {
rescale_x <- function(data) rescale(data, from = details$x.range)
rescale_y <- function(data) rescale(data, from = details$y.range)
-
+
data <- transform_position(data, rescale_x, rescale_y)
transform_position(data, squish_infinite, squish_infinite)
}
-#' @S3method coord_train cartesian
+#' @export
coord_train.cartesian <- function(coord, scales) {
c(train_cartesian(scales$x, coord$limits$x, "x"),
train_cartesian(scales$y, coord$limits$y, "y"))
diff --git a/R/coord-fixed.r b/R/coord-fixed.r
index 89c6bae..9e4ed8b 100644
--- a/R/coord-fixed.r
+++ b/R/coord-fixed.r
@@ -15,11 +15,11 @@
#' @examples
#' # ensures that the ranges of axes are equal to the specified ratio by
#' # adjusting the plot aspect ratio
-#'
+#'
#' qplot(mpg, wt, data = mtcars) + coord_fixed(ratio = 1)
#' qplot(mpg, wt, data = mtcars) + coord_fixed(ratio = 5)
#' qplot(mpg, wt, data = mtcars) + coord_fixed(ratio = 1/5)
-#'
+#'
#' # Resize the plot to see that the specified aspect ratio is maintained
coord_fixed <- function(ratio = 1, xlim = NULL, ylim = NULL, wise = NULL) {
if (!is.null(wise))
@@ -30,7 +30,7 @@ coord_fixed <- function(ratio = 1, xlim = NULL, ylim = NULL, wise = NULL) {
}
coord_equal <- coord_fixed
-#' @S3method coord_aspect fixed
+#' @export
coord_aspect.fixed <- function(coord, ranges) {
diff(ranges$y.range) / diff(ranges$x.range) * coord$ratio
}
diff --git a/R/coord-flip.r b/R/coord-flip.r
index f86745b..1260c6f 100644
--- a/R/coord-flip.r
+++ b/R/coord-flip.r
@@ -1,5 +1,5 @@
#' Flipped cartesian coordinates.
-#'
+#'
#' Flipped cartesian coordinates so that horizontal becomes vertical, and
#' vertical, horizontal. This is primarily useful for converting geoms and
#' statistics which display y conditional on x, to x conditional on y.
@@ -15,7 +15,7 @@
#'
#' qplot(cut, data=diamonds, geom="bar")
#' last_plot() + coord_flip()
-#'
+#'
#' h <- qplot(carat, data=diamonds, geom="histogram")
#' h
#' h + coord_flip()
@@ -37,30 +37,30 @@ flip_labels <- function(x) {
new_names <- gsub("^x", "z", new_names)
new_names <- gsub("^y", "x", new_names)
new_names <- gsub("^z", "y", new_names)
-
+
setNames(x, new_names)
}
-#' @S3method is.linear flip
+#' @export
is.linear.flip <- function(coord) TRUE
-#' @S3method coord_transform flip
+#' @export
coord_transform.flip <- function(coord, data, details) {
- data <- flip_labels(data)
+ data <- flip_labels(data)
NextMethod()
}
-#' @S3method coord_range flip
+#' @export
coord_range.flip <- function(coord, scales) {
return(list(x = scales$y.range, y = scales$x.range))
}
-#' @S3method coord_train flip
+#' @export
coord_train.flip <- function(coord, scales) {
flip_labels(NextMethod())
}
-#' @S3method coord_labels flip
+#' @export
coord_labels.flip <- function(coord, scales) {
flip_labels(NextMethod())
}
diff --git a/R/coord-map.r b/R/coord-map.r
index 8367788..a022365 100644
--- a/R/coord-map.r
+++ b/R/coord-map.r
@@ -1,17 +1,17 @@
#' Map projections.
-#'
+#'
#' This coordinate system provides the full range of map projections available
#' in the mapproj package.
-#'
-#' This is still experimental, and if you have any advice to offer regarding
+#'
+#' This is still experimental, and if you have any advice to offer regarding
#' a better (or more correct) way to do this, please let me know
-#'
+#'
#' @export
#' @param projection projection to use, see
#' \code{\link[mapproj]{mapproject}} for list
#' @param ... other arguments passed on to
#' \code{\link[mapproj]{mapproject}}
-#' @param orientation projection orientation, which defaults to
+#' @param orientation projection orientation, which defaults to
#' \code{c(90, 0, mean(range(x)))}. This is not optimal for many
#' projections, so you will have to supply your own. See
#' \code{\link[mapproj]{mapproject}} for more information.
@@ -32,7 +32,7 @@
#' # Other projections
#' nzmap + coord_map("cylindrical")
#' nzmap + coord_map("azequalarea",orientation=c(-36.92,174.6,0))
-#'
+#'
#' states <- map_data("state")
#' usamap <- ggplot(states, aes(x=long, y=lat, group=group)) +
#' geom_polygon(fill="white", colour="black")
@@ -67,10 +67,10 @@
#' # Centered on New York (currently has issues with closing polygons)
#' worldmap + coord_map("ortho", orientation=c(41, -74, 0))
#' }
-coord_map <- function(projection="mercator", ..., orientation = NULL, xlim = NULL, ylim = NULL) {
+coord_map <- function(projection="mercator", ..., orientation = NULL, xlim = NULL, ylim = NULL) {
try_require("mapproj")
coord(
- projection = projection,
+ projection = projection,
orientation = orientation,
limits = list(x = xlim, y = ylim),
params = list(...),
@@ -78,44 +78,44 @@ coord_map <- function(projection="mercator", ..., orientation = NULL, xlim = NUL
)
}
-#' @S3method coord_transform map
+#' @export
coord_transform.map <- function(coord, data, details) {
trans <- mproject(coord, data$x, data$y, details$orientation)
out <- cunion(trans[c("x", "y")], data)
-
+
out$x <- rescale(out$x, 0:1, details$x.proj)
out$y <- rescale(out$y, 0:1, details$y.proj)
out
}
-mproject <- function(coord, x, y, orientation) {
+mproject <- function(coord, x, y, orientation) {
suppressWarnings(mapproject(x, y,
- projection = coord$projection,
- parameters = coord$params,
+ projection = coord$projection,
+ parameters = coord$params,
orientation = orientation
))
}
-#' @S3method coord_distance map
+#' @export
coord_distance.map <- function(coord, x, y, details) {
max_dist <- dist_central_angle(details$x.range, details$y.range)
dist_central_angle(x, y) / max_dist
}
-#' @S3method coord_aspect map
+#' @export
coord_aspect.map <- function(coord, ranges) {
diff(ranges$y.proj) / diff(ranges$x.proj)
}
-#' @S3method coord_train map
+#' @export
coord_train.map <- function(coord, scales) {
# range in scale
ranges <- list()
for (n in c("x", "y")) {
-
+
scale <- scales[[n]]
limits <- coord$limits[[n]]
-
+
if (is.null(limits)) {
expand <- coord_expand_defaults(coord, scale, n)
range <- scale_dimension(scale, expand)
@@ -124,7 +124,7 @@ coord_train.map <- function(coord, scales) {
}
ranges[[n]] <- range
}
-
+
orientation <- coord$orientation %||% c(90, 0, mean(ranges$x))
# Increase chances of creating valid boundary region
@@ -139,7 +139,7 @@ coord_train.map <- function(coord, scales) {
proj <- mproject(coord, grid$x, grid$y, orientation)$range
ret$x$proj <- proj[1:2]
ret$y$proj <- proj[3:4]
-
+
for (n in c("x", "y")) {
out <- scale_break_info(scales[[n]], ranges[[n]])
ret[[n]]$range <- out$range
@@ -158,8 +158,8 @@ coord_train.map <- function(coord, scales) {
details
}
-#' @S3method coord_render_bg map
-coord_render_bg.map <- function(coord, details, theme) {
+#' @export
+coord_render_bg.map <- function(coord, details, theme) {
xrange <- expand_range(details$x.range, 0.2)
yrange <- expand_range(details$y.range, 0.2)
@@ -176,10 +176,10 @@ coord_render_bg.map <- function(coord, details, theme) {
x = x.major
))
ygrid <- with(details, expand.grid(
- x = c(seq(xrange[1], xrange[2], len = 50), NA),
+ x = c(seq(xrange[1], xrange[2], len = 50), NA),
y = y.major
))
-
+
xlines <- coord_transform(coord, xgrid, details)
ylines <- coord_transform(coord, ygrid, details)
@@ -205,9 +205,9 @@ coord_render_bg.map <- function(coord, details, theme) {
element_render(theme, "panel.background"),
grob.xlines, grob.ylines
))
-}
+}
-#' @S3method coord_render_axis_h map
+#' @export
coord_render_axis_h.map <- function(coord, details, theme) {
if (is.null(details$x.major)) return(zeroGrob())
@@ -219,15 +219,15 @@ coord_render_axis_h.map <- function(coord, details, theme) {
guide_axis(pos$x, details$x.labels, "bottom", theme)
}
-#' @S3method coord_render_axis_v map
+#' @export
coord_render_axis_v.map <- function(coord, details, theme) {
if (is.null(details$y.major)) return(zeroGrob())
-
+
x_intercept <- with(details, data.frame(
x = x.range[1],
y = y.major
))
pos <- coord_transform(coord, x_intercept, details)
-
+
guide_axis(pos$y, details$y.labels, "left", theme)
}
diff --git a/R/coord-munch.r b/R/coord-munch.r
index 1f127d5..50523d7 100644
--- a/R/coord-munch.r
+++ b/R/coord-munch.r
@@ -1,39 +1,39 @@
coord_munch <- function(coord, data, range, segment_length = 0.01) {
if (is.linear(coord)) return(coord_transform(coord, data, range))
-
+
# range has theta and r values; get corresponding x and y values
ranges <- coord_range(coord, range)
# Convert any infinite locations into max/min
- # Only need to work with x and y because for munching, those are the
+ # Only need to work with x and y because for munching, those are the
# only position aesthetics that are transformed
data$x[data$x == -Inf] <- ranges$x[1]
data$x[data$x == Inf] <- ranges$x[2]
data$y[data$y == -Inf] <- ranges$y[1]
data$y[data$y == Inf] <- ranges$y[2]
-
+
# Calculate distances using coord distance metric
dist <- coord_distance(coord, data$x, data$y, range)
dist[data$group[-1] != data$group[-nrow(data)]] <- NA
-
+
# Munch and then transform result
munched <- munch_data(data, dist, segment_length)
coord_transform(coord, munched, range)
}
-# For munching, only grobs are lines and polygons: everything else is
-# transfomed into those special cases by the geom.
+# For munching, only grobs are lines and polygons: everything else is
+# transfomed into those special cases by the geom.
#
# @param dist distance, scaled from 0 to 1 (maximum distance on plot)
# @keyword internal
munch_data <- function(data, dist = NULL, segment_length = 0.01) {
n <- nrow(data)
-
+
if (is.null(dist)) {
data <- add_group(data)
dist <- dist_euclidean(data$x, data$y)
}
-
+
# How many pieces for each old segment
extra <- floor(dist / segment_length) + 1
extra[is.na(extra)] <- 1
@@ -45,7 +45,7 @@ munch_data <- function(data, dist = NULL, segment_length = 0.01) {
# Replicate other aesthetics: defined by start point
id <- rep(seq_len(nrow(data) - 1), extra)
aes_df <- data[id, setdiff(names(data), c("x", "y"))]
-
+
unrowname(data.frame(x = x, y = y, aes_df))
}
@@ -72,10 +72,10 @@ dist_central_angle <- function(lon, lat) {
# Convert to radians
lat <- lat * pi / 180
lon <- lon * pi / 180
-
+
hav <- function(x) sin(x / 2) ^ 2
ahav <- function(x) 2 * asin(x)
-
+
n <- length(lat)
ahav(sqrt(hav(diff(lat)) + cos(lat[-n]) * cos(lat[-1]) * hav(diff(lon))))
}
diff --git a/R/coord-polar.r b/R/coord-polar.r
index e8b5975..e6e0dc2 100644
--- a/R/coord-polar.r
+++ b/R/coord-polar.r
@@ -1,26 +1,26 @@
#' Polar coordinates.
-#'
-#' The polar coordinate system is most commonly used for pie charts, which
+#'
+#' The polar coordinate system is most commonly used for pie charts, which
#' are a stacked bar chart in polar coordinates.
#'
#' @param theta variable to map angle to (\code{x} or \code{y})
#' @param start offset of starting point from 12 o'clock in radians
#' @param direction 1, clockwise; -1, anticlockwise
#' @export
-#' @examples
+#' @examples
#' \donttest{
#' # NOTE: Use these plots with caution - polar coordinates has
-#' # major perceptual problems. The main point of these examples is
+#' # major perceptual problems. The main point of these examples is
#' # to demonstrate how these common plots can be described in the
#' # grammar. Use with EXTREME caution.
#'
#' # A coxcomb plot = bar chart + polar coordinates
-#' cxc <- ggplot(mtcars, aes(x = factor(cyl))) +
+#' cxc <- ggplot(mtcars, aes(x = factor(cyl))) +
#' geom_bar(width = 1, colour = "black")
#' cxc + coord_polar()
#' # A new type of plot?
#' cxc + coord_polar(theta = "y")
-#'
+#'
#' # A pie chart = stacked bar chart + polar coordinates
#' pie <- ggplot(mtcars, aes(x = factor(1), fill = factor(cyl))) +
#' geom_bar(width = 1)
@@ -28,24 +28,24 @@
#'
#' # The bullseye chart
#' pie + coord_polar()
-#'
+#'
#' # Hadley's favourite pie chart
#' df <- data.frame(
#' variable = c("resembles", "does not resemble"),
#' value = c(80, 20)
#' )
-#' ggplot(df, aes(x = "", y = value, fill = variable)) +
+#' ggplot(df, aes(x = "", y = value, fill = variable)) +
#' geom_bar(width = 1, stat = "identity") +
-#' scale_fill_manual(values = c("red", "yellow")) +
+#' scale_fill_manual(values = c("red", "yellow")) +
#' coord_polar("y", start = pi / 3) +
#' labs(title = "Pac man")
-#'
+#'
#' # Windrose + doughnut plot
#' movies$rrating <- cut_interval(movies$rating, length = 1)
#' movies$budgetq <- cut_number(movies$budget, 4)
-#'
+#'
#' doh <- ggplot(movies, aes(x = rrating, fill = budgetq))
-#'
+#'
#' # Wind rose
#' doh + geom_bar(width = 1) + coord_polar()
#' # Race track plot
@@ -54,18 +54,18 @@
coord_polar <- function(theta = "x", start = 0, direction = 1) {
theta <- match.arg(theta, c("x", "y"))
r <- if (theta == "x") "y" else "x"
-
+
coord(
- theta = theta, r = r,
+ theta = theta, r = r,
start = start, direction = sign(direction),
subclass = "polar"
)
}
-#' @S3method coord_aspect polar
+#' @export
coord_aspect.polar <- function(coord, details) 1
-#' @S3method coord_distance polar
+#' @export
coord_distance.polar <- function(coord, x, y, details) {
if (coord$theta == "x") {
r <- rescale(y, from = details$r.range)
@@ -78,12 +78,12 @@ coord_distance.polar <- function(coord, x, y, details) {
dist_polar(r, theta)
}
-#' @S3method coord_range polar
+#' @export
coord_range.polar <- function(coord, scales) {
setNames(list(scales$theta.range, scales$r.range), c(coord$theta, coord$r))
}
-#' @S3method coord_train polar
+#' @export
coord_train.polar <- function(coord, scales) {
ret <- list(x = list(), y = list())
@@ -91,7 +91,7 @@ coord_train.polar <- function(coord, scales) {
scale <- scales[[n]]
limits <- coord$limits[[n]]
-
+
if (is.null(limits)) {
expand <- coord_expand_defaults(coord, scale, n)
range <- scale_dimension(scale, expand)
@@ -107,7 +107,7 @@ coord_train.polar <- function(coord, scales) {
}
details <- list(
- x.range = ret$x$range, y.range = ret$y$range,
+ x.range = ret$x$range, y.range = ret$y$range,
x.major = ret$x$major, x.minor = ret$x$minor, x.labels = ret$x$labels,
y.major = ret$y$major, y.minor = ret$y$minor, y.labels = ret$y$labels
)
@@ -116,7 +116,7 @@ coord_train.polar <- function(coord, scales) {
names(details) <- gsub("x\\.", "r.", names(details))
names(details) <- gsub("y\\.", "theta.", names(details))
} else {
- names(details) <- gsub("x\\.", "theta.", names(details))
+ names(details) <- gsub("x\\.", "theta.", names(details))
names(details) <- gsub("y\\.", "r.", names(details))
}
@@ -140,12 +140,12 @@ theta_rescale <- function(coord, x, details) {
rotate <- function(x) (x + coord$start) %% (2 * pi) * coord$direction
rotate(rescale(x, c(0, 2 * pi), details$theta.range))
}
-
+
r_rescale <- function(coord, x, details) {
rescale(x, c(0, 0.4), details$r.range)
}
-#' @S3method coord_expand_defaults polar
+#' @export
coord_expand_defaults.polar <- function(coord, scale, aesthetic) {
if (coord$theta == aesthetic) {
expand_default(scale, c(0, 0.5), c(0, 0))
@@ -154,35 +154,35 @@ coord_expand_defaults.polar <- function(coord, scale, aesthetic) {
}
}
-#' @S3method coord_transform polar
+#' @export
coord_transform.polar <- function(coord, data, details) {
data <- rename_data(coord, data)
-
+
data$r <- r_rescale(coord, data$r, details)
data$theta <- theta_rescale(coord, data$theta, details)
data$x <- data$r * sin(data$theta) + 0.5
data$y <- data$r * cos(data$theta) + 0.5
-
+
data
}
-#' @S3method coord_render_axis_v polar
+#' @export
coord_render_axis_v.polar <- function(coord, details, theme) {
x <- r_rescale(coord,details$r.major, details) + 0.5
guide_axis(x, details$r.labels, "left", theme)
}
-#' @S3method coord_render_axis_h polar
+#' @export
coord_render_axis_h.polar <- function(coord, details, theme) {
guide_axis(NA, "", "bottom", theme)
}
-#' @S3method coord_render_bg polar
+#' @export
coord_render_bg.polar <- function(coord, details, theme) {
details <- rename_data(coord, details)
-
+
theta <- if (length(details$theta.major) > 0) theta_rescale(coord, details$theta.major, details)
thetamin <- if (length(details$theta.minor) > 0) theta_rescale(coord, details$theta.minor, details)
- thetafine <- seq(0, 2 * pi, length=100)
+ thetafine <- seq(0, 2 * pi, length=100)
r <- 0.4
rfine <- c(r_rescale(coord, details$r.major, details), 0.45)
@@ -197,22 +197,22 @@ coord_render_bg.polar <- function(coord, details, theme) {
element_render(theme, "panel.background"),
if (length(theta) > 0) element_render(
theme, majortheta, name = "angle",
- x = c(rbind(0, 0.45 * sin(theta))) + 0.5,
+ x = c(rbind(0, 0.45 * sin(theta))) + 0.5,
y = c(rbind(0, 0.45 * cos(theta))) + 0.5,
- id.lengths = rep(2, length(theta)),
+ id.lengths = rep(2, length(theta)),
default.units="native"
),
if (length(thetamin) > 0) element_render(
theme, minortheta, name = "angle",
- x = c(rbind(0, 0.45 * sin(thetamin))) + 0.5,
+ x = c(rbind(0, 0.45 * sin(thetamin))) + 0.5,
y = c(rbind(0, 0.45 * cos(thetamin))) + 0.5,
- id.lengths = rep(2, length(thetamin)),
+ id.lengths = rep(2, length(thetamin)),
default.units="native"
),
-
+
element_render(
theme, majorr, name = "radius",
- x = rep(rfine, each=length(thetafine)) * sin(thetafine) + 0.5,
+ x = rep(rfine, each=length(thetafine)) * sin(thetafine) + 0.5,
y = rep(rfine, each=length(thetafine)) * cos(thetafine) + 0.5,
id.lengths = rep(length(thetafine), length(rfine)),
default.units="native"
@@ -220,12 +220,12 @@ coord_render_bg.polar <- function(coord, details, theme) {
))
}
-#' @S3method coord_render_fg polar
+#' @export
coord_render_fg.polar <- function(coord, details, theme) {
if (is.null(details$theta.major)) {
return(element_render(theme, "panel.border"))
}
-
+
theta <- theta_rescale(coord, details$theta.major, details)
labels <- details$theta.labels
@@ -235,7 +235,7 @@ coord_render_fg.polar <- function(coord, details, theme) {
if (ends_apart < 0.05) {
n <- length(labels)
if (is.expression(labels)) {
- combined <- substitute(paste(a, "/", b),
+ combined <- substitute(paste(a, "/", b),
list(a = labels[[1]], b = labels[[n]]))
} else {
combined <- paste(labels[1], labels[n], sep="/")
@@ -244,19 +244,19 @@ coord_render_fg.polar <- function(coord, details, theme) {
labels <- labels[-1]
theta <- theta[-1]
}
-
+
grobTree(
if (length(labels) > 0) element_render(
- theme, "axis.text.x",
+ theme, "axis.text.x",
labels, 0.45 * sin(theta) + 0.5, 0.45 * cos(theta) + 0.5,
hjust = 0.5, vjust = 0.5,
default.units="native"
- ),
+ ),
element_render(theme, "panel.border")
)
-}
+}
-#' @S3method coord_labels polar
+#' @export
coord_labels.polar <- function(coord, scales) {
if (coord$theta == "y") {
list(x = scales$y, y = scales$x)
diff --git a/R/coord-quickmap.R b/R/coord-quickmap.R
new file mode 100644
index 0000000..48bdfb7
--- /dev/null
+++ b/R/coord-quickmap.R
@@ -0,0 +1,65 @@
+#' Cartesian coordinates with an aspect ratio approximating Mercator projection.
+#'
+#' The represenation of a portion of the earth, wich is approximately spherical,
+#' onto a flat 2D plane requires a projection. This is what
+#' \code{\link{coord_map}} does. These projections account for the fact that the
+#' actual length (in km) of one degree of longitude varies between the equator
+#' and the pole. Near the equator, the ratio between the lengths of one degree
+#' of latitude and one degree of longitude is approximately 1. Near the pole, it
+#' is tends towards infinity because the length of one degree of longitude tends
+#' towards 0. For regions that span only a few degrees and are not too close to
+#' the poles, setting the aspect ratio of the plot to the appropriate lat/lon
+#' ratio approximates the usual mercator projection. This is what
+#' \code{coord_quickmap} does. With \code{\link{coord_map}} all elements of the
+#' graphic have to be projected which is not the case here. So
+#' \code{\link{coord_quickmap}} has the advantage of being much faster, in
+#' particular for complex plots such as those using with
+#' \code{\link{geom_tile}}, at the expense of correctedness in the projection.
+#'
+#' @export
+#' @inheritParams coord_cartesian
+#' @examples
+#' # ensures that the ranges of axes are equal to the specified ratio by
+#' # adjusting the plot aspect ratio
+#'
+#' if (require("maps")) {
+#' # Create a lat-long dataframe from the maps package
+#' nz <- map_data("nz")
+#' # Prepare a plot of the map
+#' nzmap <- ggplot(nz, aes(x = long, y = lat, group = group)) +
+#' geom_polygon(fill = "white", colour = "black")
+#'
+#' # Plot it in cartesian coordinates
+#' nzmap
+#' # With correct mercator projection
+#' nzmap + coord_map()
+#' # With the aspect ratio approximation
+#' nzmap + coord_quickmap()
+#' }
+#'
+#' # Resize the plot to see that the specified aspect ratio is maintained
+coord_quickmap <- function(xlim = NULL, ylim = NULL) {
+ coord(limits = list(x = xlim, y = ylim),
+ subclass = c("quickmap", "cartesian"))
+}
+
+#' @export
+coord_aspect.quickmap <- function(coord, ranges) {
+ # compute coordinates of center point of map
+ x.center <- sum(ranges$x.range) / 2
+ y.center <- sum(ranges$y.range) / 2
+
+ # compute distance corresponding to 1 degree in either direction
+ # from the center
+ x.dist <- dist_central_angle(x.center + c(-0.5, 0.5), rep(y.center, 2))
+ y.dist <- dist_central_angle(rep(x.center, 2), y.center+c(-0.5, 0.5))
+ # NB: this makes the projection correct in the center of the plot and
+ # increasingly less correct towards the edges. For regions of reasonnable
+ # size, this seems to give better results than computing this ratio from
+ # the total lat and lon span.
+
+ # scale the plot with this aspect ratio
+ ratio <- y.dist / x.dist
+
+ diff(ranges$y.range) / diff(ranges$x.range) * ratio
+}
diff --git a/R/coord-transform.r b/R/coord-transform.r
index 5ee335a..7496f06 100644
--- a/R/coord-transform.r
+++ b/R/coord-transform.r
@@ -1,11 +1,11 @@
#' Transformed cartesian coordinate system.
-#'
-#' \code{coord_trans} is different to scale transformations in that it occurs after
+#'
+#' \code{coord_trans} is different to scale transformations in that it occurs after
#' statistical transformation and will affect the visual appearance of geoms - there is
#' no guarantee that straight lines will continue to be straight.
#'
-#' All current transformations only work with continuous values - see
-#' \code{\link[scales]{trans_new}} for list of transformations, and instructions on
+#' All current transformations only work with continuous values - see
+#' \code{\link[scales]{trans_new}} for list of transformations, and instructions on
#' how to create your own.
#'
#' @param xtrans,ytrans transformers for x and y axes
@@ -15,7 +15,7 @@
#' @examples
#' \donttest{
#' # See ?geom_boxplot for other examples
-#'
+#'
#' # Three ways of doing transformating in ggplot:
#' # * by transforming the data
#' qplot(log10(carat), log10(price), data=diamonds)
@@ -28,33 +28,33 @@
#' # The difference between transforming the scales and
#' # transforming the coordinate system is that scale
#' # transformation occurs BEFORE statistics, and coordinate
-#' # transformation afterwards. Coordinate transformation also
+#' # transformation afterwards. Coordinate transformation also
#' # changes the shape of geoms:
-#'
+#'
#' d <- subset(diamonds, carat > 0.5)
-#' qplot(carat, price, data = d, log="xy") +
+#' qplot(carat, price, data = d, log="xy") +
#' geom_smooth(method="lm")
-#' qplot(carat, price, data = d) +
+#' qplot(carat, price, data = d) +
#' geom_smooth(method="lm") +
#' coord_trans(x = "log10", y = "log10")
-#'
+#'
#' # Here I used a subset of diamonds so that the smoothed line didn't
#' # drop below zero, which obviously causes problems on the log-transformed
#' # scale
-#'
+#'
#' # With a combination of scale and coordinate transformation, it's
#' # possible to do back-transformations:
#' library(scales)
-#' qplot(carat, price, data=diamonds, log="xy") +
-#' geom_smooth(method="lm") +
+#' qplot(carat, price, data=diamonds, log="xy") +
+#' geom_smooth(method="lm") +
#' coord_trans(x = exp_trans(10), y = exp_trans(10))
#' # cf.
#' qplot(carat, price, data=diamonds) + geom_smooth(method = "lm")
#'
#' # Also works with discrete scales
#' df <- data.frame(a = abs(rnorm(26)),letters)
-#' plot <- ggplot(df,aes(a,letters)) + geom_point()
-#'
+#' plot <- ggplot(df,aes(a,letters)) + geom_point()
+#'
#' plot + coord_trans(x = "log10")
#' plot + coord_trans(x = "sqrt")
#' }
@@ -71,17 +71,17 @@ coord_trans <- function(xtrans = "identity", ytrans = "identity", limx = NULL, l
coord(trans = list(x = xtrans, y = ytrans), limits = list(x = limx, y = limy), subclass = "trans")
}
-#' @S3method coord_distance trans
+#' @export
coord_distance.trans <- function(coord, x, y, details) {
max_dist <- dist_euclidean(details$x.range, details$y.range)
dist_euclidean(coord$trans$x$transform(x), coord$trans$y$transform(y)) / max_dist
-}
+}
-#' @S3method coord_transform trans
+#' @export
coord_transform.trans <- function(coord, data, details) {
trans_x <- function(data) transform_value(coord$trans$x, data, details$x.range)
trans_y <- function(data) transform_value(coord$trans$y, data, details$y.range)
-
+
data <- transform_position(data, trans_x, trans_y)
transform_position(data, squish_infinite, squish_infinite)
}
@@ -89,7 +89,7 @@ transform_value <- function(trans, value, range) {
rescale(trans$transform(value), 0:1, range)
}
-#' @S3method coord_train trans
+#' @export
coord_train.trans <- function(coord, scales) {
c(train_trans(scales$x, coord$limits$x, coord$trans$x, "x"),
train_trans(scales$y, coord$limits$y, coord$trans$y, "y"))
@@ -109,17 +109,17 @@ train_trans <- function(scale, limits, trans, name) {
}
# breaks on data space
- out <- scale_break_info(scale, range)
+ out <- scale_break_info(scale, range)
# trans'd range
out$range <- trans$transform(out$range)
-
+
# expansion if limits are not specified
if (is.null(limits)) {
expand <- coord_expand_defaults(coord, scale)
out$range <- expand_range(out$range, expand[1], expand[2])
}
-
+
# major and minor values in plot space
out$major_source <- transform_value(trans, out$major_source, out$range)
out$minor_source <- transform_value(trans, out$minor_source, out$range)
diff --git a/R/facet-.r b/R/facet-.r
index 727ee37..029ec06 100644
--- a/R/facet-.r
+++ b/R/facet-.r
@@ -18,15 +18,15 @@ facet <- function(..., shrink = TRUE, subclass = c()) {
is.facet <- function(x) inherits(x, "facet")
-# Figure out layout from data from plot and all layers.
-#
+# Figure out layout from data from plot and all layers.
+#
# This creates the layout data frame which maps from data values to
# panel coordinates: ROW, COL and PANEL. It also records the panels that
# contribute to each x and y scale.
-#
+#
# @param data a list of data frames (one for the plot and one for each
# layer)
-facet_train_layout <- function(facet, data)
+facet_train_layout <- function(facet, data)
UseMethod("facet_train_layout")
facet_map_layout <- function(facet, data, layout)
@@ -35,12 +35,12 @@ facet_map_layout <- function(facet, data, layout)
facet_render <- function(facet, panels_grob, coord, theme, geom_grobs)
UseMethod("facet_render")
-facet_strips <- function(facet, panel, theme)
+facet_strips <- function(facet, panel, theme)
UseMethod("facet_strips")
facet_panels <- function(facet, panel, coord, theme, geom_grobs)
UseMethod("facet_panels")
-
+
facet_axes <- function(facet, panel, coord, theme)
UseMethod("facet_axes")
@@ -49,14 +49,14 @@ facet_vars <- function(facet)
UseMethod("facet_vars")
-#' @S3method format facet
+#' @export
format.facet <- function(x, ...) {
name <- paste(rev(class(x)), collapse = "_")
paste(name, "(", facet_vars(x), ")", sep = "")
}
-#' @S3method print facet
+#' @export
print.facet <- function(x, ...) {
cat(format(x, ...), "\n")
}
diff --git a/R/facet-grid-.r b/R/facet-grid-.r
index c338707..350a6db 100644
--- a/R/facet-grid-.r
+++ b/R/facet-grid-.r
@@ -17,15 +17,15 @@
#' columns (\code{"free_y"}), or both rows and columns (\code{"free"})
#' @param space If \code{"fixed"}, the default, all panels have the same size.
#' If \code{"free_y"} their height will be proportional to the length of the
-#' y scale; if \code{"free_x"} their width will be proportional to the
-#' length of the x scale; or if \code{"free"} both height and width will
+#' y scale; if \code{"free_x"} their width will be proportional to the
+#' length of the x scale; or if \code{"free"} both height and width will
#' vary. This setting has no effect unless the appropriate scales also vary.
-#' @param labeller A function that takes two arguments (\code{variable} and
+#' @param labeller A function that takes two arguments (\code{variable} and
#' \code{value}) and returns a string suitable for display in the facet
#' strip. See \code{\link{label_value}} for more details and pointers
#' to other options.
#' @param as.table If \code{TRUE}, the default, the facets are laid out like
-#' a table with highest values at the bottom-right. If \code{FALSE}, the
+#' a table with highest values at the bottom-right. If \code{FALSE}, the
#' facets are laid out like a plot with the highest value at the top-right.
#' @param shrink If \code{TRUE}, will shrink scales to fit output of
#' statistics, not raw data. If \code{FALSE}, will be range of raw data
@@ -34,82 +34,82 @@
#' data will automatically be dropped. If \code{FALSE}, all factor levels
#' will be shown, regardless of whether or not they appear in the data.
#' @export
-#' @examples
+#' @examples
#' \donttest{
#' p <- ggplot(mtcars, aes(mpg, wt)) + geom_point()
#' # With one variable
#' p + facet_grid(. ~ cyl)
#' p + facet_grid(cyl ~ .)
-#'
+#'
#' # With two variables
#' p + facet_grid(vs ~ am)
#' p + facet_grid(am ~ vs)
#' p + facet_grid(vs ~ am, margins=TRUE)
-#'
+#'
#' # To change plot order of facet grid,
#' # change the order of variable levels with factor()
#'
#' set.seed(6809)
#' diamonds <- diamonds[sample(nrow(diamonds), 1000), ]
-#' diamonds$cut <- factor(diamonds$cut,
+#' diamonds$cut <- factor(diamonds$cut,
#' levels = c("Ideal", "Very Good", "Fair", "Good", "Premium"))
#'
#' # Repeat first example with new order
#' p <- ggplot(diamonds, aes(carat, ..density..)) +
#' geom_histogram(binwidth = 1)
#' p + facet_grid(. ~ cut)
-#'
+#'
#' qplot(mpg, wt, data=mtcars, facets = . ~ vs + am)
#' qplot(mpg, wt, data=mtcars, facets = vs + am ~ . )
-#'
+#'
#' # You can also use strings, which makes it a little easier
#' # when writing functions that generate faceting specifications
#' # p + facet_grid("cut ~ .")
-#'
+#'
#' # see also ?plotmatrix for the scatterplot matrix
-#'
+#'
#' # If there isn't any data for a given combination, that panel
#' # will be empty
#' qplot(mpg, wt, data=mtcars) + facet_grid(cyl ~ vs)
-#'
+#'
# If you combine a facetted dataset with a dataset that lacks those
# facetting variables, the data will be repeated across the missing
# combinations:
#' p <- qplot(mpg, wt, data=mtcars, facets = vs ~ cyl)
-#'
+#'
#' df <- data.frame(mpg = 22, wt = 3)
#' p + geom_point(data = df, colour="red", size = 2)
-#'
+#'
#' df2 <- data.frame(mpg = c(19, 22), wt = c(2,4), vs = c(0, 1))
#' p + geom_point(data = df2, colour="red", size = 2)
-#'
+#'
#' df3 <- data.frame(mpg = c(19, 22), wt = c(2,4), vs = c(1, 1))
#' p + geom_point(data = df3, colour="red", size = 2)
-#'
-#'
+#'
+#'
#' # You can also choose whether the scales should be constant
#' # across all panels (the default), or whether they should be allowed
#' # to vary
#' mt <- ggplot(mtcars, aes(mpg, wt, colour = factor(cyl))) + geom_point()
-#'
+#'
#' mt + facet_grid(. ~ cyl, scales = "free")
#' # If scales and space are free, then the mapping between position
#' # and values in the data will be the same across all panels
#' mt + facet_grid(. ~ cyl, scales = "free", space = "free")
-#'
+#'
#' mt + facet_grid(vs ~ am, scales = "free")
#' mt + facet_grid(vs ~ am, scales = "free_x")
#' mt + facet_grid(vs ~ am, scales = "free_y")
#' mt + facet_grid(vs ~ am, scales = "free", space="free")
#' mt + facet_grid(vs ~ am, scales = "free", space="free_x")
#' mt + facet_grid(vs ~ am, scales = "free", space="free_y")
-#'
+#'
#' # You may need to set your own breaks for consistent display:
#' mt + facet_grid(. ~ cyl, scales = "free_x", space="free") +
#' scale_x_continuous(breaks = seq(10, 36, by = 2))
#' # Adding scale limits override free scales:
#' last_plot() + xlim(10, 15)
-#'
+#'
#' # Free scales are particularly useful for categorical variables
#' qplot(cty, model, data=mpg) +
#' facet_grid(manufacturer ~ ., scales = "free", space = "free")
@@ -119,12 +119,12 @@
#' manufacturer <- reorder(manufacturer, cty)
#' })
#' last_plot() %+% mpg + theme(strip.text.y = element_text())
-#'
+#'
#' # Use as.table to to control direction of horizontal facets, TRUE by default
#' h <- ggplot(mtcars, aes(x = mpg, y = wt)) + geom_point()
#' h + facet_grid(cyl ~ vs)
#' h + facet_grid(cyl ~ vs, as.table = FALSE)
-#'
+#'
#' # Use labeller to control facet labels, label_value is default
#' h + facet_grid(cyl ~ vs, labeller = label_both)
#' # Using label_parsed, see ?plotmath for more options
@@ -135,7 +135,7 @@
#' # For label_bquote the label value is x.
#' p <- qplot(wt, mpg, data = mtcars)
#' p + facet_grid(. ~ vs, labeller = label_bquote(alpha ^ .(x)))
-#' p + facet_grid(. ~ vs, labeller = label_bquote(.(x) ^ .(x)))
+#' p + facet_grid(. ~ vs, labeller = label_bquote(.(x) ^ .(x)))
#'
#' # Margins can be specified by logically (all yes or all no) or by specific
#' # variables as (character) variable names
@@ -156,13 +156,13 @@ facet_grid <- function(facets, margins = FALSE, scales = "fixed", space = "fixed
x = any(scales %in% c("free_x", "free")),
y = any(scales %in% c("free_y", "free"))
)
-
+
space <- match.arg(space, c("fixed", "free_x", "free_y", "free"))
space_free <- list(
x = any(space %in% c("free_x", "free")),
y = any(space %in% c("free_y", "free"))
)
-
+
# Facets can either be a formula, a string, or a list of things to be
# convert to quoted
if (is.character(facets)) {
@@ -171,7 +171,7 @@ facet_grid <- function(facets, margins = FALSE, scales = "fixed", space = "fixed
if (is.formula(facets)) {
lhs <- function(x) if(length(x) == 2) NULL else x[-3]
rhs <- function(x) if(length(x) == 2) x else x[-2]
-
+
rows <- as.quoted(lhs(facets))
rows <- rows[!sapply(rows, identical, as.name("."))]
cols <- as.quoted(rhs(facets))
@@ -184,35 +184,35 @@ facet_grid <- function(facets, margins = FALSE, scales = "fixed", space = "fixed
if (length(rows) + length(cols) == 0) {
stop("Must specify at least one variable to facet by", call. = FALSE)
}
-
+
facet(
rows = rows, cols = cols, margins = margins, shrink = shrink,
- free = free, space_free = space_free,
+ free = free, space_free = space_free,
labeller = labeller, as.table = as.table, drop = drop,
subclass = "grid"
)
}
-#' @S3method facet_train_layout grid
-facet_train_layout.grid <- function(facet, data) {
+#' @export
+facet_train_layout.grid <- function(facet, data) {
layout <- layout_grid(data, facet$rows, facet$cols, facet$margins,
drop = facet$drop, as.table = facet$as.table)
-
+
# Relax constraints, if necessary
layout$SCALE_X <- if (facet$free$x) layout$COL else 1L
layout$SCALE_Y <- if (facet$free$y) layout$ROW else 1L
-
+
layout
}
-#' @S3method facet_map_layout grid
+#' @export
facet_map_layout.grid <- function(facet, data, layout) {
locate_grid(data, layout, facet$rows, facet$cols, facet$margins)
}
-#' @S3method facet_render grid
+#' @export
facet_render.grid <- function(facet, panel, coord, theme, geom_grobs) {
axes <- facet_axes(facet, panel, coord, theme)
strips <- facet_strips(facet, panel, theme)
@@ -221,16 +221,16 @@ facet_render.grid <- function(facet, panel, coord, theme, geom_grobs) {
# adjust the size of axes to the size of panel
axes$l$heights <- panels$heights
axes$b$widths <- panels$widths
-
+
# adjust the size of the strips to the size of the panels
strips$r$heights <- panels$heights
strips$t$widths <- panels$widths
-
+
# Combine components into complete plot
top <- strips$t
top <- gtable_add_cols(top, strips$r$widths)
top <- gtable_add_cols(top, axes$l$widths, pos = 0)
-
+
center <- cbind(axes$l, panels, strips$r, z = c(2, 1, 3))
bottom <- axes$b
bottom <- gtable_add_cols(bottom, strips$r$widths)
@@ -240,11 +240,11 @@ facet_render.grid <- function(facet, panel, coord, theme, geom_grobs) {
complete$respect <- panels$respect
complete$name <- "layout"
bottom <- axes$b
-
+
complete
}
-#' @S3method facet_strips grid
+#' @export
facet_strips.grid <- function(facet, panel, theme) {
col_vars <- unique(panel$layout[names(facet$cols)])
row_vars <- unique(panel$layout[names(facet$rows)])
@@ -259,7 +259,7 @@ build_strip <- function(panel, label_df, labeller, theme, side = "right") {
side <- match.arg(side, c("top", "left", "bottom", "right"))
horizontal <- side %in% c("top", "bottom")
labeller <- match.fun(labeller)
-
+
# No labelling data, so return empty row/col
if (empty(label_df)) {
if (horizontal) {
@@ -270,22 +270,22 @@ build_strip <- function(panel, label_df, labeller, theme, side = "right") {
return(gtable_col_spacer(heights))
}
}
-
+
# Create matrix of labels
labels <- matrix(list(), nrow = nrow(label_df), ncol = ncol(label_df))
for (i in seq_len(ncol(label_df))) {
labels[, i] <- labeller(names(label_df)[i], label_df[, i])
}
-
+
# Render as grobs
grobs <- apply(labels, c(1,2), ggstrip, theme = theme,
horizontal = horizontal)
-
+
# Create layout
name <- paste("strip", side, sep = "-")
if (horizontal) {
grobs <- t(grobs)
-
+
# Each row is as high as the highest and as a wide as the panel
row_height <- function(row) max(laply(row, height_cm))
heights <- unit(apply(grobs, 1, row_height), "cm")
@@ -297,38 +297,38 @@ build_strip <- function(panel, label_df, labeller, theme, side = "right") {
heights <- unit(rep(1, nrow(grobs)), "null")
}
strips <- gtable_matrix(name, grobs, heights = heights, widths = widths)
-
+
if (horizontal) {
- gtable_add_col_space(strips, theme$panel.margin)
+ gtable_add_col_space(strips, theme$panel.margin.x %||% theme$panel.margin)
} else {
- gtable_add_row_space(strips, theme$panel.margin)
+ gtable_add_row_space(strips, theme$panel.margin.y %||% theme$panel.margin)
}
}
-#' @S3method facet_axes grid
+#' @export
facet_axes.grid <- function(facet, panel, coord, theme) {
axes <- list()
# Horizontal axes
cols <- which(panel$layout$ROW == 1)
- grobs <- lapply(panel$ranges[cols], coord_render_axis_h,
+ grobs <- lapply(panel$ranges[cols], coord_render_axis_h,
coord = coord, theme = theme)
axes$b <- gtable_add_col_space(gtable_row("axis-b", grobs),
- theme$panel.margin)
+ theme$panel.margin.x %||% theme$panel.margin)
# Vertical axes
rows <- which(panel$layout$COL == 1)
- grobs <- lapply(panel$ranges[rows], coord_render_axis_v,
+ grobs <- lapply(panel$ranges[rows], coord_render_axis_v,
coord = coord, theme = theme)
axes$l <- gtable_add_row_space(gtable_col("axis-l", grobs),
- theme$panel.margin)
+ theme$panel.margin.y %||% theme$panel.margin)
axes
}
-#' @S3method facet_panels grid
+#' @export
facet_panels.grid <- function(facet, panel, coord, theme, geom_grobs) {
-
+
# If user hasn't set aspect ratio, and we have fixed scales, then
# ask the coordinate system if it wants to specify one
aspect_ratio <- theme$aspect.ratio
@@ -341,22 +341,22 @@ facet_panels.grid <- function(facet, panel, coord, theme, geom_grobs) {
} else {
respect <- TRUE
}
-
+
# Add background and foreground to panels
- panels <- panel$layout$PANEL
+ panels <- panel$layout$PANEL
ncol <- max(panel$layout$COL)
nrow <- max(panel$layout$ROW)
-
+
panel_grobs <- lapply(panels, function(i) {
fg <- coord_render_fg(coord, panel$range[[i]], theme)
bg <- coord_render_bg(coord, panel$range[[i]], theme)
-
+
geom_grobs <- lapply(geom_grobs, "[[", i)
panel_grobs <- c(list(bg), geom_grobs, list(fg))
-
- gTree(children = do.call("gList", panel_grobs))
+
+ gTree(children = do.call("gList", panel_grobs))
})
-
+
panel_matrix <- matrix(panel_grobs, nrow = nrow, ncol = ncol, byrow = TRUE)
# @kohske
@@ -379,17 +379,17 @@ facet_panels.grid <- function(facet, panel, coord, theme, geom_grobs) {
} else {
panel_heights <- rep(unit(1 * aspect_ratio, "null"), nrow)
}
-
+
panels <- gtable_matrix("panel", panel_matrix,
panel_widths, panel_heights, respect = respect)
- panels <- gtable_add_col_space(panels, theme$panel.margin)
- panels <- gtable_add_row_space(panels, theme$panel.margin)
-
+ panels <- gtable_add_col_space(panels, theme$panel.margin.x %||% theme$panel.margin)
+ panels <- gtable_add_row_space(panels, theme$panel.margin.y %||% theme$panel.margin)
+
panels
}
-#' @S3method facet_vars grid
+#' @export
facet_vars.grid <- function(facet) {
- paste(lapply(list(facet$rows, facet$cols), paste, collapse = ", "),
+ paste(lapply(list(facet$rows, facet$cols), paste, collapse = ", "),
collapse = " ~ ")
}
diff --git a/R/facet-labels.r b/R/facet-labels.r
index c5a58b2..190247a 100644
--- a/R/facet-labels.r
+++ b/R/facet-labels.r
@@ -1,6 +1,6 @@
#' Label facets with their value.
#' This is the default labelling scheme.
-#'
+#'
#' @param variable variable name passed in by facetter
#' @param value variable value passed in by facetter
#' @family facet labellers
@@ -12,7 +12,7 @@
label_value <- function(variable, value) as.character(value)
#' Label facets with value and variable.
-#'
+#'
#' @param variable variable name passed in by facetter
#' @param value variable value passed in by facetter
#' @family facet labellers
@@ -24,7 +24,7 @@ label_value <- function(variable, value) as.character(value)
label_both <- function(variable, value) paste(variable, value, sep = ": ")
#' Label facets with parsed label.
-#'
+#'
#' @seealso \code{\link{plotmath}}
#' @param variable variable name passed in by facetter
#' @param value variable value passed in by facetter
@@ -33,17 +33,17 @@ label_both <- function(variable, value) paste(variable, value, sep = ": ")
#' @examples
#' mtcars$cyl2 <- factor(mtcars$cyl, labels = c("alpha", "beta", "gamma"))
#' qplot(wt, mpg, data = mtcars) + facet_grid(. ~ cyl2)
-#' qplot(wt, mpg, data = mtcars) + facet_grid(. ~ cyl2,
+#' qplot(wt, mpg, data = mtcars) + facet_grid(. ~ cyl2,
#' labeller = label_parsed)
label_parsed <- function(variable, value) {
llply(as.character(value), function(x) parse(text = x))
}
#' Label facet with 'bquoted' expressions
-#'
+#'
#' See \code{\link{bquote}} for details on the syntax of the argument. The
-#' label value is x.
-#'
+#' label value is x.
+#'
#' @param expr labelling expression to use
#' @family facet labellers
#' @seealso \code{\link{plotmath}}
@@ -54,13 +54,129 @@ label_parsed <- function(variable, value) {
#' p + facet_grid(. ~ vs, labeller = label_bquote(.(x) ^ .(x)))
label_bquote <- function(expr = beta ^ .(x)) {
quoted <- substitute(expr)
-
+
function(variable, value) {
value <- as.character(value)
lapply(value, function(x)
eval(substitute(bquote(expr, list(x = x)), list(expr = quoted))))
}
}
+globalVariables("x")
+
+
+#' Label facets with a word wrapped label.
+#'
+#' Uses \code{\link[base]{strwrap}} for line wrapping.
+#' @param width integer, target column width for output.
+#' @export
+#' @seealso , \code{\link{labeller}}
+label_wrap_gen <- function(width = 25) {
+ function(variable, values) {
+ vapply(strwrap(as.character(values), width = width, simplify = FALSE),
+ paste, vector('character', 1), collapse = "\n")
+ }
+}
+
+#' Generic labeller function for facets
+#'
+#' One-step function for providing methods or named character vectors
+#' for displaying labels in facets.
+#'
+#' The provided methods are checked for number of arguments.
+#' If the provided method takes less than two
+#' (e.g. \code{\link[Hmisc]{capitalize}}),
+#' the method is passed \code{values}.
+#' Else (e.g. \code{\link{label_both}}),
+#' it is passed \code{variable} and \code{values} (in that order).
+#' If you want to be certain, use e.g. an anonymous function.
+#' If errors are returned such as ``argument ".." is missing, with no default''
+#' or ``unused argument (variable)'', matching the method's arguments does not
+#' work as expected; make a wrapper function.
+#'
+#'
+#' @param ... Named arguments of the form \code{variable=values},
+#' where \code{values} could be a vector or method.
+#' @param keep.as.numeric logical, default TRUE. When FALSE, converts numeric
+#' values supplied as margins to the facet to characters.
+#' @family facet labeller
+#' @return Function to supply to
+#' \code{\link{facet_grid}} for the argument \code{labeller}.
+#' @export
+#' @examples
+#' \donttest{
+#' p1 <- ggplot(mpg, aes(cty, hwy)) + geom_point()
+#' p1 + facet_grid(cyl ~ class, labeller=label_both)
+#' p1 + facet_grid(cyl ~ class, labeller=labeller(cyl=label_both))
+#'
+#' ggplot(mtcars, aes(x = mpg, y = wt)) + geom_point() +
+#' facet_grid(vs + am ~ gear, margins=TRUE,
+#' labeller=labeller(vs=label_both, am=label_both))
+#'
+#' capitalize <- function(string) {
+#' substr(string, 1, 1) <- toupper(substr(string, 1, 1))
+#' string
+#' }
+#' conservation_status <- c('cd'='Conservation Dependent',
+#' 'en'='Endangered',
+#' 'lc'='Least concern',
+#' 'nt'='Near Threatened',
+#' 'vu'='Vulnerable',
+#' 'domesticated'='Domesticated')
+#' ## Source: http://en.wikipedia.org/wiki/Wikipedia:Conservation_status
+#'
+#' p2 <- ggplot(msleep, aes(x=sleep_total, y=awake)) + geom_point()
+#' p2 + facet_grid(vore ~ conservation, labeller = labeller(vore = capitalize))
+#'
+#' p2 + facet_grid(vore ~ conservation,
+#' labeller=labeller(vore = capitalize, conservation = conservation_status ))
+#'
+#' # We could of course have renamed the levels;
+#' # then we can apply another nifty function
+#' msleep$conservation2 <- plyr::revalue(msleep$conservation, conservation_status)
+#'
+#' p2 %+% msleep +
+#' facet_grid(vore ~ conservation2, labeller = labeller(vore = capitalize))
+#' p2 %+% msleep +
+#' facet_grid(vore ~ conservation2, labeller = labeller(conservation2 =
+#' label_wrap_gen(10)))
+#' }
+labeller <- function(..., keep.as.numeric=FALSE) {
+ args <- list(...)
+
+ function(variable, values) {
+ if (is.logical(values)) {
+ values <- as.integer(values) + 1
+ } else if (is.factor(values)) {
+ values <- as.character(values)
+ } else if (is.numeric(values) & !keep.as.numeric) {
+ values <- as.character(values)
+ }
+
+ res <- args[[variable]]
+
+ if (is.null(res)) {
+ # If the facetting margin (i.e. `variable`) was not specified when calling
+ # labeller, default to use the actual values.
+ result <- values
+
+ } else if (is.function(res)) {
+ # How should `variable` and `values` be passed to a function? ------------
+ arguments <- length(formals(res))
+ if (arguments < 2) {
+ result <- res(values)
+ } else {
+ result <- res(variable, values)
+ }
+
+ } else {
+ result <- res[values]
+ }
+
+ return(result)
+ }
+}
+
+
# Grob for strip labels
ggstrip <- function(text, horizontal=TRUE, theme) {
diff --git a/R/facet-layout.r b/R/facet-layout.r
index 25979c4..0f551de 100644
--- a/R/facet-layout.r
+++ b/R/facet-layout.r
@@ -1,16 +1,16 @@
# Layout panels in a 2d grid.
-#
+#
# @params data list of data frames, one for each layer
# @params rows variables that form the rows
# @params cols variables that form the columns
# @return a data frame with columns \code{PANEL}, \code{ROW} and \code{COL},
-# that match the facetting variable values up with their position in the
+# that match the facetting variable values up with their position in the
# grid
layout_grid <- function(data, rows = NULL, cols = NULL, margins = NULL, drop = TRUE, as.table = TRUE) {
if (length(rows) == 0 && length(cols) == 0) return(layout_null())
rows <- as.quoted(rows)
cols <- as.quoted(cols)
-
+
base_rows <- layout_base(data, rows, drop = drop)
if (!as.table) {
rev_order <- function(x) factor(x, levels = rev(ulevels(x)))
@@ -18,7 +18,7 @@ layout_grid <- function(data, rows = NULL, cols = NULL, margins = NULL, drop = T
}
base_cols <- layout_base(data, cols, drop = drop)
base <- df.grid(base_rows, base_cols)
-
+
# Add margins
base <- add_margins(base, list(names(rows), names(cols)), margins)
# Work around bug in reshape2
@@ -27,12 +27,14 @@ layout_grid <- function(data, rows = NULL, cols = NULL, margins = NULL, drop = T
# Create panel info dataset
panel <- id(base, drop = TRUE)
panel <- factor(panel, levels = seq_len(attr(panel, "n")))
-
+
rows <- if (is.null(names(rows))) 1L else id(base[names(rows)], drop = TRUE)
cols <- if (is.null(names(cols))) 1L else id(base[names(cols)], drop = TRUE)
-
+
panels <- data.frame(PANEL = panel, ROW = rows, COL = cols, base)
- arrange(panels, PANEL)
+ panels <- panels[order(panels$PANEL), , drop = FALSE]
+ rownames(panels) <- NULL
+ panels
}
# Layout out panels in a 1d ribbon.
@@ -47,22 +49,24 @@ layout_wrap <- function(data, vars = NULL, nrow = NULL, ncol = NULL, as.table =
id <- id(base, drop = TRUE)
n <- attr(id, "n")
-
+
dims <- wrap_dims(n, nrow, ncol)
layout <- data.frame(PANEL = factor(id, levels = seq_len(n)))
-
+
if (as.table) {
layout$ROW <- as.integer((id - 1L) %/% dims[2] + 1L)
} else {
layout$ROW <- as.integer(dims[1] - (id - 1L) %/% dims[2])
}
layout$COL <- as.integer((id - 1L) %% dims[2] + 1L)
-
+
panels <- cbind(layout, unrowname(base))
- panels[order(panels$PANEL), ]
+ panels <- panels[order(panels$PANEL), , drop = FALSE]
+ rownames(panels) <- NULL
+ panels
}
-layout_null <- function(data) {
+layout_null <- function(data) {
data.frame(PANEL = 1, ROW = 1, COL = 1)
}
@@ -85,22 +89,22 @@ layout_base <- function(data, vars = NULL, drop = TRUE) {
if (!any(has_all)) {
stop("At least one layer must contain all variables used for facetting")
}
-
- base <- unique(ldply(values[has_all]))
+
+ base <- unique(ldply(values[has_all]))
if (!drop) {
base <- unique_combs(base)
}
-
+
# Systematically add on missing combinations
for (value in values[!has_all]) {
if (empty(value)) next;
-
+
old <- base[setdiff(names(base), names(value))]
- new <- unique(value[intersect(names(base), names(value))])
+ new <- unique(value[intersect(names(base), names(value))])
if (drop) {
new <- unique_combs(new)
}
-
+
base <- rbind(base, df.grid(old, new))
}
@@ -122,22 +126,22 @@ ulevels <- function(x) {
unique_combs <- function(df) {
if (length(df) == 0) return()
-
+
unique_values <- llply(df, ulevels)
- rev(expand.grid(rev(unique_values), stringsAsFactors = FALSE,
+ rev(expand.grid(rev(unique_values), stringsAsFactors = FALSE,
KEEP.OUT.ATTRS = TRUE))
}
df.grid <- function(a, b) {
if (nrow(a) == 0) return(b)
if (nrow(b) == 0) return(a)
-
+
indexes <- expand.grid(
- i_a = seq_len(nrow(a)),
+ i_a = seq_len(nrow(a)),
i_b = seq_len(nrow(b))
)
unrowname(cbind(
- a[indexes$i_a, , drop = FALSE],
+ a[indexes$i_a, , drop = FALSE],
b[indexes$i_b, , drop = FALSE]
))
}
@@ -159,6 +163,6 @@ wrap_dims <- function(n, nrow = NULL, ncol = NULL) {
nrow <- ceiling(n / ncol)
}
stopifnot(nrow * ncol >= n)
-
+
c(nrow, ncol)
}
diff --git a/R/facet-locate.r b/R/facet-locate.r
index 29bf24a..6255bc1 100644
--- a/R/facet-locate.r
+++ b/R/facet-locate.r
@@ -11,29 +11,29 @@ locate_grid <- function(data, panels, rows = NULL, cols = NULL, margins = FALSE)
rows <- as.quoted(rows)
cols <- as.quoted(cols)
vars <- c(names(rows), names(cols))
-
+
# Compute facetting values and add margins
margin_vars <- list(intersect(names(rows), names(data)),
intersect(names(cols), names(data)))
data <- add_margins(data, margin_vars, margins)
-
+
facet_vals <- quoted_df(data, c(rows, cols))
- # If any facetting variables are missing, add them in by
+ # If any facetting variables are missing, add them in by
# duplicating the data
missing_facets <- setdiff(vars, names(facet_vals))
if (length(missing_facets) > 0) {
to_add <- unique(panels[missing_facets])
-
+
data_rep <- rep.int(1:nrow(data), nrow(to_add))
facet_rep <- rep(1:nrow(to_add), each = nrow(data))
-
+
data <- unrowname(data[data_rep, , drop = FALSE])
facet_vals <- unrowname(cbind(
- facet_vals[data_rep, , drop = FALSE],
+ facet_vals[data_rep, , drop = FALSE],
to_add[facet_rep, , drop = FALSE]))
}
-
+
# Add PANEL variable
if (nrow(facet_vals) == 0) {
# Special case of no facetting
@@ -41,13 +41,13 @@ locate_grid <- function(data, panels, rows = NULL, cols = NULL, margins = FALSE)
} else {
facet_vals[] <- lapply(facet_vals[], as.factor)
facet_vals[] <- lapply(facet_vals[], addNA, ifany = TRUE)
-
+
keys <- join.keys(facet_vals, panels, by = vars)
data$PANEL <- panels$PANEL[match(keys$x, keys$y)]
}
-
- arrange(data, PANEL)
+
+ data[order(data$PANEL), , drop = FALSE]
}
locate_wrap <- function(data, panels, vars) {
@@ -55,26 +55,26 @@ locate_wrap <- function(data, panels, vars) {
return(cbind(data, PANEL = integer(0)))
}
vars <- as.quoted(vars)
-
+
facet_vals <- quoted_df(data, vars)
facet_vals[] <- lapply(facet_vals[], as.factor)
-
+
missing_facets <- setdiff(names(vars), names(facet_vals))
if (length(missing_facets) > 0) {
-
+
to_add <- unique(panels[missing_facets])
-
+
data_rep <- rep.int(1:nrow(data), nrow(to_add))
facet_rep <- rep(1:nrow(to_add), each = nrow(data))
-
+
data <- unrowname(data[data_rep, , drop = FALSE])
facet_vals <- unrowname(cbind(
- facet_vals[data_rep, , drop = FALSE],
+ facet_vals[data_rep, , drop = FALSE],
to_add[facet_rep, , drop = FALSE]))
}
-
+
keys <- join.keys(facet_vals, panels, by = names(vars))
-
+
data$PANEL <- panels$PANEL[match(keys$x, keys$y)]
data[order(data$PANEL), ]
}
diff --git a/R/facet-null.r b/R/facet-null.r
index 27299a4..0b310a8 100644
--- a/R/facet-null.r
+++ b/R/facet-null.r
@@ -3,7 +3,7 @@
#' @inheritParams facet_grid
#' @export
#' @examples
-#' # facet_null is the default facetting specification if you
+#' # facet_null is the default facetting specification if you
#' # don't override it with facet_grid or facet_wrap
#' ggplot(mtcars, aes(mpg, wt)) + geom_point()
#' qplot(mpg, wt, data = mtcars)
@@ -11,14 +11,14 @@ facet_null <- function(shrink = TRUE) {
facet(shrink = shrink, subclass = "null")
}
-#' @S3method facet_train_layout null
-facet_train_layout.null <- function(facet, data) {
+#' @export
+facet_train_layout.null <- function(facet, data) {
data.frame(
- PANEL = 1L, ROW = 1L, COL = 1L,
+ PANEL = 1L, ROW = 1L, COL = 1L,
SCALE_X = 1L, SCALE_Y = 1L)
}
-#' @S3method facet_map_layout null
+#' @export
facet_map_layout.null <- function(facet, data, layout) {
# Need the is.waive check for special case where no data, but aesthetics
# are mapped to vectors, like qplot(1:5, 1:5)
@@ -28,10 +28,10 @@ facet_map_layout.null <- function(facet, data, layout) {
data
}
-#' @S3method facet_render null
+#' @export
facet_render.null <- function(facet, panel, coord, theme, geom_grobs) {
range <- panel$ranges[[1]]
-
+
# Figure out aspect ratio
aspect_ratio <- theme$aspect.ratio %||% coord_aspect(coord, range)
if (is.null(aspect_ratio)) {
@@ -40,23 +40,23 @@ facet_render.null <- function(facet, panel, coord, theme, geom_grobs) {
} else {
respect <- TRUE
}
-
+
fg <- coord_render_fg(coord, range, theme)
bg <- coord_render_bg(coord, range, theme)
# Flatten layers - we know there's only one panel
geom_grobs <- lapply(geom_grobs, "[[", 1)
panel_grobs <- c(list(bg), geom_grobs, list(fg))
-
- panel_grob <- gTree(children = do.call("gList", panel_grobs))
+
+ panel_grob <- gTree(children = do.call("gList", panel_grobs))
axis_h <- coord_render_axis_h(coord, range, theme)
axis_v <- coord_render_axis_v(coord, range, theme)
-
+
all <- matrix(list(
axis_v, panel_grob,
zeroGrob(), axis_h
), ncol = 2, byrow = TRUE)
-
+
layout <- gtable_matrix("layout", all,
widths = unit.c(grobWidth(axis_v), unit(1, "null")),
heights = unit.c(unit(aspect_ratio, "null"), grobHeight(axis_h)),
@@ -64,9 +64,9 @@ facet_render.null <- function(facet, panel, coord, theme, geom_grobs) {
z = matrix(c(3, 2, 1, 4), ncol = 2, byrow = TRUE)
)
layout$layout$name <- c("axis-l", "spacer", "panel", "axis-b")
-
+
layout
}
-#' @S3method facet_vars null
+#' @export
facet_vars.null <- function(facet) ""
diff --git a/R/facet-viewports.r b/R/facet-viewports.r
index dfa3183..70e97ae 100644
--- a/R/facet-viewports.r
+++ b/R/facet-viewports.r
@@ -1,35 +1,35 @@
# Assign viewports to a matrix of grobs
-#
+#
# Uses the structure (and names) of the matrix of grobs, to automatically
# assign each grob to the appropriate viewport
assign_viewports <- function(grobs) {
make_grid <- function(type) {
data.frame(
- type = type,
- x = c(row(grobs[[type]])),
+ type = type,
+ x = c(row(grobs[[type]])),
y = c(col(grobs[[type]]))
)
}
-
+
assign_vp <- function(type, x, y) {
ggname(type, editGrob(grobs[[type]][[x, y]], vp = vp_path(x, y, type)))
}
-
+
grid <- ldply(names(grobs), make_grid)
mlply(grid, assign_vp)
}
-# Setup matrix of viewports for a layout with given parameters
+# Setup matrix of viewports for a layout with given parameters
setup_viewports <- function(type, data, offset = c(0,0), clip = "on") {
rows <- nrow(data)
cols <- ncol(data)
-
+
vp <- function(x,y) {
# cat(vp_name(x, y, type), ": ", x + offset[1], ", ", y + offset[2], "\n", sep="")
viewport(
- name = vp_name(x, y, type),
- layout.pos.row = x + offset[1],
- layout.pos.col = y + offset[2],
+ name = vp_name(x, y, type),
+ layout.pos.row = x + offset[1],
+ layout.pos.col = y + offset[2],
clip=clip
)
}
diff --git a/R/facet-wrap.r b/R/facet-wrap.r
index 16fcb19..9f1213c 100644
--- a/R/facet-wrap.r
+++ b/R/facet-wrap.r
@@ -1,32 +1,32 @@
#' Wrap a 1d ribbon of panels into 2d.
-#'
+#'
#' @param nrow number of rows
#' @param ncol number of columns
#' @param facets formula specifying variables to facet by
-#' @param scales should scales be fixed (\code{"fixed"}, the default),
+#' @param scales should scales be fixed (\code{"fixed"}, the default),
#' free (\code{"free"}), or free in one dimension (\code{"free_x"},
#' \code{"free_y"})
#' @inheritParams facet_grid
#' @export
#' @examples
#' \donttest{
-#' d <- ggplot(diamonds, aes(carat, price, fill = ..density..)) +
+#' d <- ggplot(diamonds, aes(carat, price, fill = ..density..)) +
#' xlim(0, 2) + stat_binhex(na.rm = TRUE) + theme(aspect.ratio = 1)
#' d + facet_wrap(~ color)
#' d + facet_wrap(~ color, ncol = 1)
#' d + facet_wrap(~ color, ncol = 4)
#' d + facet_wrap(~ color, nrow = 1)
#' d + facet_wrap(~ color, nrow = 3)
-#'
-#' # Using multiple variables continues to wrap the long ribbon of
+#'
+#' # Using multiple variables continues to wrap the long ribbon of
#' # plots into 2d - the ribbon just gets longer
#' # d + facet_wrap(~ color + cut)
-#'
-#' # To change plot order of facet wrap,
+#'
+#' # To change plot order of facet wrap,
#' # change the order of varible levels with factor()
#' diamonds$color <- factor(diamonds$color, levels = c("G", "J", "D", "E", "I", "F", "H"))
#' # Repeat first example with new order
-#' d <- ggplot(diamonds, aes(carat, price, fill = ..density..)) +
+#' d <- ggplot(diamonds, aes(carat, price, fill = ..density..)) +
#' xlim(0, 2) + stat_binhex(na.rm = TRUE) + theme(aspect.ratio = 1)
#' d + facet_wrap(~ color)
#'
@@ -35,7 +35,7 @@
#' p <- qplot(price, data = diamonds, geom = "histogram", binwidth = 1000)
#' p + facet_wrap(~ color)
#' p + facet_wrap(~ color, scales = "free_y")
-#'
+#'
#' p <- qplot(displ, hwy, data = mpg)
#' p + facet_wrap(~ cyl)
#' p + facet_wrap(~ cyl, scales = "free")
@@ -45,11 +45,11 @@
#'
#' # Add data that does not contain all levels of the faceting variables
#' cyl6 <- subset(mpg, cyl == 6)
-#' p + geom_point(data = cyl6, colour = "red", size = 1) +
+#' p + geom_point(data = cyl6, colour = "red", size = 1) +
#' facet_wrap(~ cyl)
-#' p + geom_point(data = transform(cyl6, cyl = 7), colour = "red") +
+#' p + geom_point(data = transform(cyl6, cyl = 7), colour = "red") +
#' facet_wrap(~ cyl)
-#' p + geom_point(data = transform(cyl6, cyl = NULL), colour = "red") +
+#' p + geom_point(data = transform(cyl6, cyl = NULL), colour = "red") +
#' facet_wrap(~ cyl)
#' }
facet_wrap <- function(facets, nrow = NULL, ncol = NULL, scales = "fixed", shrink = TRUE, as.table = TRUE, drop = TRUE) {
@@ -58,35 +58,35 @@ facet_wrap <- function(facets, nrow = NULL, ncol = NULL, scales = "fixed", shrin
x = any(scales %in% c("free_x", "free")),
y = any(scales %in% c("free_y", "free"))
)
-
+
facet(
facets = as.quoted(facets), free = free, shrink = shrink,
as.table = as.table, drop = drop,
- ncol = ncol, nrow = nrow,
+ ncol = ncol, nrow = nrow,
subclass = "wrap"
)
}
-#' @S3method facet_train_layout wrap
-facet_train_layout.wrap <- function(facet, data) {
+#' @export
+facet_train_layout.wrap <- function(facet, data) {
panels <- layout_wrap(data, facet$facets, facet$nrow, facet$ncol,
facet$as.table, facet$drop)
-
+
n <- nrow(panels)
nrow <- max(panels$ROW)
-
+
# Add scale identification
panels$SCALE_X <- if (facet$free$x) seq_len(n) else 1L
panels$SCALE_Y <- if (facet$free$y) seq_len(n) else 1L
-
+
# Figure out where axes should go
panels$AXIS_X <- if (facet$free$x) TRUE else panels$ROW == nrow
panels$AXIS_Y <- if (facet$free$y) TRUE else panels$COL == 1
-
+
panels
}
-#' @S3method facet_map_layout wrap
+#' @export
facet_map_layout.wrap <- function(facet, data, layout) {
locate_wrap(data, layout, facet$facets)
}
@@ -98,9 +98,9 @@ facet_map_layout.wrap <- function(facet, data, layout) {
# * combine panels, strips and axes, then wrap into 2d
# * finally: add title, labels and legend
#
-#' @S3method facet_render wrap
+#' @export
facet_render.wrap <- function(facet, panel, coord, theme, geom_grobs) {
-
+
# If coord is (non-cartesian or flip) and (x is free or y is free)
# then print a warning
if ((!inherits(coord, "cartesian") || inherits(coord, "flip")) &&
@@ -114,14 +114,14 @@ facet_render.wrap <- function(facet, panel, coord, theme, geom_grobs) {
if (is.null(aspect_ratio) && !facet$free$x && !facet$free$y) {
aspect_ratio <- coord_aspect(coord, panel$ranges[[1]])
}
-
+
if (is.null(aspect_ratio)) {
aspect_ratio <- 1
respect <- FALSE
} else {
respect <- TRUE
}
-
+
layout <- panel$layout
ncol <- max(layout$COL)
nrow <- max(layout$ROW)
@@ -154,25 +154,25 @@ facet_render.wrap <- function(facet, panel, coord, theme, geom_grobs) {
axis_l = axes$l,
axis_b = axes$b
)
-
+
info <- ldply(locs, find_pos, layout = layout, size = c(3, 4))
names(info)[1] <- "type"
info$clip <- ifelse(info$type == "panel", "on", "off")
info$name <- paste(info$type, info$id, sep = "-")
-
+
# Bare numbers are taken as cm
# If not listed, assume is unit(1, "null")
widths <- list(
axis_l = width_cm(grobs$axis_l),
- vspace = ifelse(layout$COL == ncol, 0, height_cm(theme$panel.margin))
+ vspace = ifelse(layout$COL == ncol, 0, width_cm(theme$panel.margin.x %||% theme$panel.margin))
)
heights <- list(
panel = unit(aspect_ratio, "null"),
strip_t = height_cm(grobs$strip_t),
axis_b = height_cm(grobs$axis_b),
- hspace = ifelse(layout$ROW == nrow, 0, height_cm(theme$panel.margin))
+ hspace = ifelse(layout$ROW == nrow, 0, height_cm(theme$panel.margin.y %||% theme$panel.margin))
)
-
+
col_widths <- compute_grob_widths(info, widths)
row_heights <- compute_grob_heights(info, heights)
@@ -189,58 +189,58 @@ facet_render.wrap <- function(facet, panel, coord, theme, geom_grobs) {
gt
}
-#' @S3method facet_panels wrap
+#' @export
facet_panels.wrap <- function(facet, panel, coord, theme, geom_grobs) {
panels <- panel$layout$PANEL
lapply(panels, function(i) {
fg <- coord_render_fg(coord, panel$range[[i]], theme)
bg <- coord_render_bg(coord, panel$range[[i]], theme)
-
+
geom_grobs <- lapply(geom_grobs, "[[", i)
panel_grobs <- c(list(bg), geom_grobs, list(fg))
-
- ggname(paste("panel", i, sep = "-"),
+
+ ggname(paste("panel", i, sep = "-"),
gTree(children = do.call("gList", panel_grobs)))
})
}
-#' @S3method facet_strips wrap
+#' @export
facet_strips.wrap <- function(facet, panel, theme) {
labels_df <- panel$layout[names(facet$facets)]
labels_df[] <- llply(labels_df, format, justify = "none")
-
+
labels <- apply(labels_df, 1, paste, collapse=", ")
list(t = llply(labels, ggstrip, theme = theme))
}
-#' @S3method facet_axes wrap
+#' @export
facet_axes.wrap <- function(facet, panel, coord, theme) {
panels <- panel$layout$PANEL
-
+
axes <- list()
axes$b <- lapply(panels, function(i) {
if (panel$layout$AXIS_X[i]) {
- grob <- coord_render_axis_h(coord, panel$range[[i]], theme)
+ grob <- coord_render_axis_h(coord, panel$range[[i]], theme)
} else {
grob <- zeroGrob()
}
ggname(paste("axis-b-", i, sep = ""), grob)
})
-
+
axes$l <- lapply(panels, function(i) {
if (panel$layout$AXIS_Y[i]) {
- grob <- coord_render_axis_v(coord, panel$range[[i]], theme)
+ grob <- coord_render_axis_v(coord, panel$range[[i]], theme)
} else {
grob <- zeroGrob()
}
ggname(paste("axis-l-", i, sep = ""), grob)
})
axes
-
+
}
-#' @S3method facet_vars wrap
+#' @export
facet_vars.wrap <- function(facet) {
paste(lapply(facet$facets, paste, collapse = ", "), collapse = " ~ ")
}
diff --git a/R/fortify-lm.r b/R/fortify-lm.r
index 850a516..4d1ebca 100644
--- a/R/fortify-lm.r
+++ b/R/fortify-lm.r
@@ -1,9 +1,9 @@
#' Supplement the data fitted to a linear model with model fit statistics.
#'
-#' If you have missing values in your model data, you may need to refit
+#' If you have missing values in your model data, you may need to refit
#' the model with \code{na.action = na.exclude}.
-#'
-#'
+#'
+#'
#' @return The original data with extra columns:
#' \item{.hat}{Diagonal of the hat matrix}
#' \item{.sigma}{Estimate of residual standard deviation when
@@ -15,56 +15,55 @@
#' @param model linear model
#' @param data data set, defaults to data used to fit model
#' @param ... not used by this method
-#' @method fortify lm
-#' @S3method fortify lm
+#' @export
#' @examples
#'
#' mod <- lm(mpg ~ wt, data = mtcars)
#' head(fortify(mod))
#' head(fortify(mod, mtcars))
-#'
+#'
#' plot(mod, which = 1)
-#' qplot(.fitted, .resid, data = mod) +
-#' geom_hline(yintercept = 0) +
+#' qplot(.fitted, .resid, data = mod) +
+#' geom_hline(yintercept = 0) +
#' geom_smooth(se = FALSE)
-#' qplot(.fitted, .stdresid, data = mod) +
+#' qplot(.fitted, .stdresid, data = mod) +
#' geom_hline(yintercept = 0) +
#' geom_smooth(se = FALSE)
-#' qplot(.fitted, .stdresid, data = fortify(mod, mtcars),
+#' qplot(.fitted, .stdresid, data = fortify(mod, mtcars),
#' colour = factor(cyl))
#' qplot(mpg, .stdresid, data = fortify(mod, mtcars), colour = factor(cyl))
-#'
+#'
#' plot(mod, which = 2)
#' # qplot(sample =.stdresid, data = mod, stat = "qq") + geom_abline()
-#'
+#'
#' plot(mod, which = 3)
#' qplot(.fitted, sqrt(abs(.stdresid)), data = mod) + geom_smooth(se = FALSE)
-#'
+#'
#' plot(mod, which = 4)
#' qplot(seq_along(.cooksd), .cooksd, data = mod, geom = "bar",
#' stat="identity")
-#'
+#'
#' plot(mod, which = 5)
#' qplot(.hat, .stdresid, data = mod) + geom_smooth(se = FALSE)
-#' ggplot(mod, aes(.hat, .stdresid)) +
+#' ggplot(mod, aes(.hat, .stdresid)) +
#' geom_vline(size = 2, colour = "white", xintercept = 0) +
#' geom_hline(size = 2, colour = "white", yintercept = 0) +
#' geom_point() + geom_smooth(se = FALSE)
-#'
-#' qplot(.hat, .stdresid, data = mod, size = .cooksd) +
+#'
+#' qplot(.hat, .stdresid, data = mod, size = .cooksd) +
#' geom_smooth(se = FALSE, size = 0.5)
-#'
+#'
#' plot(mod, which = 6)
-#' ggplot(mod, aes(.hat, .cooksd)) +
-#' geom_vline(xintercept = 0, colour = NA) +
+#' ggplot(mod, aes(.hat, .cooksd)) +
+#' geom_vline(xintercept = 0, colour = NA) +
#' geom_abline(slope = seq(0, 3, by = 0.5), colour = "white") +
-#' geom_smooth(se = FALSE) +
+#' geom_smooth(se = FALSE) +
#' geom_point()
-#' qplot(.hat, .cooksd, size = .cooksd / .hat, data = mod) + scale_area()
+#' qplot(.hat, .cooksd, size = .cooksd / .hat, data = mod) + scale_size_area()
fortify.lm <- function(model, data = model$model, ...) {
infl <- influence(model, do.coef = FALSE)
data$.hat <- infl$hat
- data$.sigma <- infl$sigma
+ data$.sigma <- infl$sigma
data$.cooksd <- cooks.distance(model, infl)
data$.fitted <- predict(model)
diff --git a/R/fortify-map.r b/R/fortify-map.r
index 73e0bd3..aa9a0db 100644
--- a/R/fortify-map.r
+++ b/R/fortify-map.r
@@ -1,10 +1,9 @@
#' Fortify method for map objects.
-#'
+#'
#' This function turns a map into a data frame that can more easily be
#' plotted with ggplot2.
-#'
-#' @method fortify map
-#' @S3method fortify map
+#'
+#' @export
#' @seealso \code{\link{map_data}} and \code{\link{borders}}
#' @param model map object
#' @param data not used by this method
@@ -17,7 +16,7 @@
#'
#' tx <- map("county", "texas", plot = FALSE, fill = TRUE)
#' head(fortify(tx))
-#' qplot(long, lat, data = tx, geom = "polygon", group = group,
+#' qplot(long, lat, data = tx, geom = "polygon", group = group,
#' colour = I("white"))
#' }
fortify.map <- function(model, data, ...) {
@@ -25,7 +24,7 @@ fortify.map <- function(model, data, ...) {
names(df) <- c("long", "lat")
df$group <- cumsum(is.na(df$long) & is.na(df$lat)) + 1
df$order <- 1:nrow(df)
-
+
names <- do.call("rbind", lapply(strsplit(model$names, "[:,]"), "[", 1:2))
df$region <- names[df$group, 1]
df$subregion <- names[df$group, 2]
@@ -33,11 +32,11 @@ fortify.map <- function(model, data, ...) {
}
#' Create a data frame of map data.
-#'
-#' @param map name of map provided by the \pkg{maps} package. These
+#'
+#' @param map name of map provided by the \pkg{maps} package. These
#' include \code{\link[maps]{county}}, \code{\link[maps]{france}},
-#' \code{\link[maps]{italy}}, \code{\link[maps]{nz}},
-#' \code{\link[maps]{state}}, \code{\link[maps]{usa}},
+#' \code{\link[maps]{italy}}, \code{\link[maps]{nz}},
+#' \code{\link[maps]{state}}, \code{\link[maps]{usa}},
#' \code{\link[maps]{world}}, \code{\link[maps]{world2}}.
#' @param region name of subregions to include. Defaults to \code{.} which
#' includes all subregion. See documentation for \code{\link[maps]{map}}
@@ -52,7 +51,7 @@ fortify.map <- function(model, data, ...) {
#' arrests <- USArrests
#' names(arrests) <- tolower(names(arrests))
#' arrests$region <- tolower(rownames(USArrests))
-#'
+#'
#' choro <- merge(states, arrests, sort = FALSE, by = "region")
#' choro <- choro[order(choro$order), ]
#' qplot(long, lat, data = choro, group = group, fill = assault,
@@ -66,7 +65,7 @@ map_data <- function(map, region = ".", exact = FALSE, ...) {
}
#' Create a layer of map borders.
-#'
+#'
#' @param database map data, see \code{\link[maps]{map}} for details
#' @param regions map region
#' @param fill fill colour
@@ -89,11 +88,11 @@ map_data <- function(map, region = ".", exact = FALSE, ...) {
#' ggplot(capitals, aes(long, lat)) +
#' borders("state") +
#' geom_point(aes(size = pop)) +
-#' scale_area()
+#' scale_size_area()
#'
#' }
borders <- function(database = "world", regions = ".", fill = NA, colour = "grey50", ...) {
df <- map_data(database, regions)
- geom_polygon(aes(long, lat, group = group), data = df,
+ geom_polygon(aes_q(quote(long), quote(lat), group = quote(group)), data = df,
fill = fill, colour = colour, ...)
}
diff --git a/R/fortify-multcomp.r b/R/fortify-multcomp.r
index 0d77f71..5a690ec 100644
--- a/R/fortify-multcomp.r
+++ b/R/fortify-multcomp.r
@@ -19,8 +19,8 @@
#'
#' fortify(summary(wht))
#' ggplot(mapping = aes(lhs, estimate)) +
-#' geom_linerange(aes(ymin = lwr, ymax = upr), data = CI) +
-#' geom_point(aes(size = p), data = summary(wht)) +
+#' geom_linerange(aes(ymin = lwr, ymax = upr), data = CI) +
+#' geom_point(aes(size = p), data = summary(wht)) +
#' scale_size(trans = "reverse")
#'
#' cld <- cld(wht)
@@ -35,8 +35,8 @@ fortify.glht <- function(model, data, ...) {
unrowname(data.frame(
lhs = rownames(model$linfct),
rhs = model$rhs,
- estimate = coef(model),
- check.names = FALSE,
+ estimate = coef(model),
+ check.names = FALSE,
stringsAsFactors = FALSE))
}
@@ -46,12 +46,12 @@ fortify.glht <- function(model, data, ...) {
fortify.confint.glht <- function(model, data, ...) {
coef <- model$confint
colnames(coef) <- tolower(colnames(coef))
-
+
unrowname(data.frame(
lhs = rownames(coef),
rhs = model$rhs,
coef,
- check.names = FALSE,
+ check.names = FALSE,
stringsAsFactors = FALSE))
}
@@ -62,12 +62,12 @@ fortify.summary.glht <- function(model, data, ...) {
coef <- as.data.frame(
model$test[c("coefficients", "sigma", "tstat", "pvalues")])
names(coef) <- c("estimate", "se", "t", "p")
-
+
unrowname(data.frame(
lhs = rownames(coef),
rhs = model$rhs,
coef,
- check.names = FALSE,
+ check.names = FALSE,
stringsAsFactors = FALSE))
}
@@ -79,6 +79,6 @@ fortify.cld <- function(model, data, ...) {
unrowname(data.frame(
lhs = names(model$mcletters$Letters),
letters = model$mcletters$Letters,
- check.names = FALSE,
+ check.names = FALSE,
stringsAsFactors = FALSE))
}
diff --git a/R/fortify-spatial.r b/R/fortify-spatial.r
index 31f823e..9aaed2d 100644
--- a/R/fortify-spatial.r
+++ b/R/fortify-spatial.r
@@ -1,8 +1,8 @@
#' Fortify method for classes from the sp package.
-#'
-#' To figure out the correct variable name for region, inspect
+#'
+#' To figure out the correct variable name for region, inspect
#' \code{as.data.frame(model)}.
-#'
+#'
#' @param model \code{SpatialPolygonsDataFrame} to convert into a dataframe.
#' @param data not used by this method
#' @param region name of variable used to split up regions
@@ -11,9 +11,9 @@
#' @examples
#' if (require("maptools")) {
#' sids <- system.file("shapes/sids.shp", package="maptools")
-#' nc1 <- readShapePoly(sids,
+#' nc1 <- readShapePoly(sids,
#' proj4string = CRS("+proj=longlat +datum=NAD27"))
-#' nc1_df <- fortify(nc1)
+#' nc1_df <- fortify(nc1)
#' }
NULL
@@ -27,7 +27,7 @@ fortify.SpatialPolygonsDataFrame <- function(model, data, region = NULL, ...) {
coords <- ldply(model at polygons,fortify)
message("Regions defined for each Polygons")
} else {
- cp <- polygons(model)
+ cp <- sp::polygons(model)
try_require("maptools")
# Union together all polygons that make up a region
@@ -55,7 +55,7 @@ fortify.Polygons <- function(model, data, ...) {
df$piece <- i
df
})
-
+
within(pieces,{
order <- 1:nrow(pieces)
id <- model at ID
@@ -92,7 +92,7 @@ fortify.Lines <- function(model, data, ...) {
df$piece <- i
df
})
-
+
within(pieces,{
order <- 1:nrow(pieces)
id <- model at ID
@@ -108,5 +108,5 @@ fortify.Line <- function(model, data, ...) {
df <- as.data.frame(model at coords)
names(df) <- c("long", "lat")
df$order <- 1:nrow(df)
- df
+ df
}
diff --git a/R/fortify.r b/R/fortify.r
index 1366ccc..aefe91d 100644
--- a/R/fortify.r
+++ b/R/fortify.r
@@ -1,22 +1,22 @@
#' Fortify a model with data.
#'
-#' Method to convert a generic R object into a data frame useful for plotting.
+#' Method to convert a generic R object into a data frame useful for plotting.
#' Takes its name from the idea of fortifying the original data with model fit
#' statistics, and vice versa.
-#'
+#'
#' @seealso \code{\link{fortify.lm}}
-#' @S3method fortify data.frame
-#' @S3method fortify NULL
-#' @S3method fortify default
#' @param model model or other R object to convert to data frame
#' @param data original dataset, if needed
#' @param ... other arguments passed to methods
-#' @export
+#' @export
fortify <- function(model, data, ...) UseMethod("fortify")
+#' @export
fortify.data.frame <- function(model, data, ...) model
+#' @export
fortify.NULL <- function(model, data, ...) waiver()
+#' @export
fortify.default <- function(model, data, ...) {
-
+
stop("ggplot2 doesn't know how to deal with data of class ", class(model), call. = FALSE)
}
diff --git a/R/geom-.r b/R/geom-.r
index e1e74d3..ef8be8c 100644
--- a/R/geom-.r
+++ b/R/geom-.r
@@ -4,14 +4,14 @@ Geom <- proto(TopLevel, expr={
parameters <- function(.) {
params <- formals(get("draw", .))
params <- params[setdiff(names(params), c(".","data","scales", "coordinates", "..."))]
-
+
required <- rep(NA, length(.$required_aes))
names(required) <- .$required_aes
aesthetics <- c(.$default_aes(), required)
-
+
c(params, aesthetics[setdiff(names(aesthetics), names(params))])
}
-
+
required_aes <- c()
default_aes <- function(.) {}
default_pos <- function(.) PositionIdentity
@@ -21,28 +21,28 @@ Geom <- proto(TopLevel, expr={
draw <- function(...) {}
draw_groups <- function(., data, scales, coordinates, ...) {
if (empty(data)) return(zeroGrob())
-
+
groups <- split(data, factor(data$group))
grobs <- lapply(groups, function(group) .$draw(group, scales, coordinates, ...))
-
+
ggname(paste(.$objname, "s", sep=""), gTree(
children = do.call("gList", grobs)
))
}
-
+
new <- function(., mapping=NULL, data=NULL, stat=NULL, position=NULL, ...){
do.call("layer", list(mapping=mapping, data=data, stat=stat, geom=., position=position, ...))
}
-
+
pprint <- function(., newline=TRUE) {
cat("geom_", .$objname, ": ", sep="") # , clist(.$parameters())
if (newline) cat("\n")
}
-
+
reparameterise <- function(., data, params) data
-
+
# Html documentation ----------------------------------
-
-
+
+
})
diff --git a/R/geom-abline.r b/R/geom-abline.r
index 9d2ba9e..fc0cde2 100644
--- a/R/geom-abline.r
+++ b/R/geom-abline.r
@@ -1,17 +1,17 @@
#' Line specified by slope and intercept.
-#'
+#'
#' The abline geom adds a line with specified slope and intercept to the
#' plot.
-#'
+#'
#' With its siblings \code{geom_hline} and \code{geom_vline}, it's useful for
-#' annotating plots. You can supply the parameters for geom_abline,
+#' annotating plots. You can supply the parameters for geom_abline,
#' intercept and slope, in two ways: either explicitly as fixed values, or
#' in a data frame. If you specify the fixed values
#' (\code{geom_abline(intercept=0, slope=1)}) then the line will be the same
-#' in all panels. If the intercept and slope are stored in the data, then
+#' in all panels. If the intercept and slope are stored in the data, then
#' they can vary from panel to panel. See the examples for more ideas.
#'
-#' @section Aesthetics:
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "abline")}
#'
#' @seealso \code{\link{stat_smooth}} to add lines derived from the data,
@@ -32,10 +32,10 @@
#' coef(lm(mpg ~ wt, data = mtcars))
#' p + geom_abline(intercept = 37, slope = -5)
#' p + geom_abline(intercept = 10, colour = "red", size = 2)
-#'
+#'
#' # See ?stat_smooth for fitting smooth models to data
#' p + stat_smooth(method="lm", se=FALSE)
-#'
+#'
#' # Slopes and intercepts as data
#' p <- ggplot(mtcars, aes(x = wt, y=mpg), . ~ cyl) + geom_point()
#' df <- data.frame(a=rnorm(10, 25), b=rnorm(10, 0))
@@ -43,21 +43,21 @@
#'
#' # Slopes and intercepts from linear model
#' library(plyr)
-#' coefs <- ddply(mtcars, .(cyl), function(df) {
+#' coefs <- ddply(mtcars, .(cyl), function(df) {
#' m <- lm(mpg ~ wt, data=df)
-#' data.frame(a = coef(m)[1], b = coef(m)[2])
+#' data.frame(a = coef(m)[1], b = coef(m)[2])
#' })
#' str(coefs)
#' p + geom_abline(data=coefs, aes(intercept=a, slope=b))
-#'
+#'
#' # It's actually a bit easier to do this with stat_smooth
#' p + geom_smooth(aes(group=cyl), method="lm")
#' p + geom_smooth(aes(group=cyl), method="lm", fullrange=TRUE)
-#'
+#'
#' # With coordinate transforms
#' p + geom_abline(intercept = 37, slope = -5) + coord_flip()
#' p + geom_abline(intercept = 37, slope = -5) + coord_polar()
-geom_abline <- function (mapping = NULL, data = NULL, stat = "abline", position = "identity", show_guide = FALSE, ...) {
+geom_abline <- function (mapping = NULL, data = NULL, stat = "abline", position = "identity", show_guide = FALSE, ...) {
GeomAbline$new(mapping = mapping, data = data, stat = stat, position = position, show_guide = show_guide, ...)
}
@@ -69,7 +69,7 @@ GeomAbline <- proto(Geom, {
class(mapping) <- "uneval"
.super$new(., ..., mapping = mapping, inherit.aes = FALSE)
}
-
+
draw <- function(., data, scales, coordinates, ...) {
ranges <- coord_range(coordinates, scales)
@@ -85,11 +85,11 @@ GeomAbline <- proto(Geom, {
default_stat <- function(.) StatAbline
default_aes <- function(.) aes(colour="black", size=0.5, linetype=1, alpha = NA)
-
+
draw_legend <- function(., data, ...) {
data <- aesdefaults(data, .$default_aes(), list(...))
- with(data,
+ with(data,
ggname(.$my_name(), segmentsGrob(0, 0, 1, 1, default.units="npc",
gp=gpar(col=alpha(colour, alpha), lwd=size * .pt, lty=linetype,
lineend="butt")))
diff --git a/R/geom-bar-.r b/R/geom-bar-.r
index be2b0e0..b771b6d 100644
--- a/R/geom-bar-.r
+++ b/R/geom-bar-.r
@@ -1,7 +1,7 @@
#' Bars, rectangles with bases on x-axis
-#'
+#'
#' The bar geom is used to produce 1d area plots: bar charts for categorical
-#' x, and histograms for continuous y. stat_bin explains the details of
+#' x, and histograms for continuous y. stat_bin explains the details of
#' these summaries in more detail. In particular, you can use the
#' \code{weight} aesthetic to create weighted histograms and barcharts where
#' the height of the bar no longer represent a count of observations, but a
@@ -18,27 +18,27 @@
#'
#' By default, multiple x's occuring in the same place will be stacked a top
#' one another by position_stack. If you want them to be dodged from
-#' side-to-side, see \code{\link{position_dodge}}. Finally,
+#' side-to-side, see \code{\link{position_dodge}}. Finally,
#' \code{\link{position_fill}} shows relative propotions at each x by stacking
#' the bars and then stretching or squashing to the same height.
#'
-#' Sometimes, bar charts are used not as a distributional summary, but
+#' Sometimes, bar charts are used not as a distributional summary, but
#' instead of a dotplot. Generally, it's preferable to use a dotplot (see
#' \code{geom_point}) as it has a better data-ink ratio. However, if you do
#' want to create this type of plot, you can set y to the value you have
#' calculated, and use \code{stat='identity'}
#'
#' A bar chart maps the height of the bar to a variable, and so the base of
-#' the bar must always been shown to produce a valid visual comparison.
+#' the bar must always been shown to produce a valid visual comparison.
#' Naomi Robbins has a nice
-#' \href{http://www.b-eye-network.com/view/index.php?cid=2468}{article on this topic}.
+#' \href{http://www.b-eye-network.com/view/index.php?cid=2468}{article on this topic}.
#' This is the reason it doesn't make sense to use a log-scaled y axis with a bar chart
#'
-#' @section Aesthetics:
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "bar")}
#'
-#' @seealso \code{\link{stat_bin}} for more details of the binning alogirithm,
-#' \code{\link{position_dodge}} for creating side-by-side barcharts,
+#' @seealso \code{\link{stat_bin}} for more details of the binning alogirithm,
+#' \code{\link{position_dodge}} for creating side-by-side barcharts,
#' \code{\link{position_stack}} for more info on stacking,
#' @export
#' @inheritParams geom_point
@@ -46,50 +46,50 @@
#' \donttest{
#' # Generate data
#' c <- ggplot(mtcars, aes(factor(cyl)))
-#'
+#'
#' # By default, uses stat="bin", which gives the count in each category
#' c + geom_bar()
#' c + geom_bar(width=.5)
#' c + geom_bar() + coord_flip()
#' c + geom_bar(fill="white", colour="darkgreen")
-#'
+#'
#' # Use qplot
#' qplot(factor(cyl), data=mtcars, geom="bar")
#' qplot(factor(cyl), data=mtcars, geom="bar", fill=factor(cyl))
-#'
+#'
#' # When the data contains y values in a column, use stat="identity"
#' library(plyr)
#' # Calculate the mean mpg for each level of cyl
#' mm <- ddply(mtcars, "cyl", summarise, mmpg = mean(mpg))
#' ggplot(mm, aes(x = factor(cyl), y = mmpg)) + geom_bar(stat = "identity")
#'
-#' # Stacked bar charts
+#' # Stacked bar charts
#' qplot(factor(cyl), data=mtcars, geom="bar", fill=factor(vs))
#' qplot(factor(cyl), data=mtcars, geom="bar", fill=factor(gear))
-#'
-#' # Stacked bar charts are easy in ggplot2, but not effective visually,
+#'
+#' # Stacked bar charts are easy in ggplot2, but not effective visually,
#' # particularly when there are many different things being stacked
#' ggplot(diamonds, aes(clarity, fill=cut)) + geom_bar()
#' ggplot(diamonds, aes(color, fill=cut)) + geom_bar() + coord_flip()
-#'
+#'
#' # Faceting is a good alternative:
-#' ggplot(diamonds, aes(clarity)) + geom_bar() +
+#' ggplot(diamonds, aes(clarity)) + geom_bar() +
#' facet_wrap(~ cut)
#' # If the x axis is ordered, using a line instead of bars is another
#' # possibility:
-#' ggplot(diamonds, aes(clarity)) +
+#' ggplot(diamonds, aes(clarity)) +
#' geom_freqpoly(aes(group = cut, colour = cut))
-#'
-#' # Dodged bar charts
+#'
+#' # Dodged bar charts
#' ggplot(diamonds, aes(clarity, fill=cut)) + geom_bar(position="dodge")
-#' # compare with
-#' ggplot(diamonds, aes(cut, fill=cut)) + geom_bar() +
+#' # compare with
+#' ggplot(diamonds, aes(cut, fill=cut)) + geom_bar() +
#' facet_grid(. ~ clarity)
-#'
+#'
#' # But again, probably better to use frequency polygons instead:
-#' ggplot(diamonds, aes(clarity, colour=cut)) +
+#' ggplot(diamonds, aes(clarity, colour=cut)) +
#' geom_freqpoly(aes(group = cut))
-#'
+#'
#' # Often we don't want the height of the bar to represent the
#' # count of observations, but the sum of some other variable.
#' # For example, the following plot shows the number of diamonds
@@ -98,7 +98,7 @@
#' # If, however, we want to see the total number of carats in each colour
#' # we need to weight by the carat variable
#' qplot(color, data=diamonds, geom="bar", weight=carat, ylab="carat")
-#'
+#'
#' # A bar chart used to display means
#' meanprice <- tapply(diamonds$price, diamonds$cut, mean)
#' cut <- factor(levels(diamonds$cut), levels = levels(diamonds$cut))
@@ -115,7 +115,7 @@
#'
#' # To change plot order of class varible
#' # use factor() to change order of levels
-#' mpg$class <- factor(mpg$class, levels = c("midsize", "minivan",
+#' mpg$class <- factor(mpg$class, levels = c("midsize", "minivan",
#' "suv", "compact", "2seater", "subcompact", "pickup"))
#' m <- ggplot(mpg, aes(manufacturer, fill=class))
#' m + geom_bar()
@@ -126,22 +126,22 @@ geom_bar <- function (mapping = NULL, data = NULL, stat = "bin", position = "sta
GeomBar <- proto(Geom, {
objname <- "bar"
-
+
default_stat <- function(.) StatBin
default_pos <- function(.) PositionStack
default_aes <- function(.) aes(colour=NA, fill="grey20", size=0.5, linetype=1, weight = 1, alpha = NA)
-
+
required_aes <- c("x")
-
+
reparameterise <- function(., df, params) {
- df$width <- df$width %||%
+ df$width <- df$width %||%
params$width %||% (resolution(df$x, FALSE) * 0.9)
transform(df,
ymin = pmin(y, 0), ymax = pmax(y, 0),
xmin = x - width / 2, xmax = x + width / 2, width = NULL
)
}
-
+
draw_groups <- function(., data, scales, coordinates, ...) {
GeomRect$draw_groups(data, scales, coordinates, ...)
}
diff --git a/R/geom-bar-histogram.r b/R/geom-bar-histogram.r
index e253648..b0e05e1 100644
--- a/R/geom-bar-histogram.r
+++ b/R/geom-bar-histogram.r
@@ -1,17 +1,17 @@
#' Histogram
#'
-#' \code{geom_histogram} is an alias for \code{\link{geom_bar}} plus
+#' \code{geom_histogram} is an alias for \code{\link{geom_bar}} plus
#' \code{\link{stat_bin}} so you will need to look at the documentation for
#' those objects to get more information about the parameters.
-#'
+#'
#' By default, \code{stat_bin} uses 30 bins - this is not a good default,
#' but the idea is to get you experimenting with different binwidths. You
#' may need to look at a few to uncover the full story behind your data.
#'
-#' @section Aesthetics:
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "histogram")}
#'
-#' @export
+#' @export
#' @inheritParams geom_point
#' @examples
#' \donttest{
@@ -22,7 +22,7 @@
#' qplot(rating, data=movies, weight=votes, geom="histogram")
#' qplot(rating, data=movies, weight=votes, geom="histogram", binwidth=1)
#' qplot(rating, data=movies, weight=votes, geom="histogram", binwidth=0.1)
-#'
+#'
#' # More complex
#' m <- ggplot(movies, aes(x=rating))
#' m + geom_histogram()
@@ -31,14 +31,14 @@
#' m + geom_histogram(binwidth = 1)
#' m + geom_histogram(binwidth = 0.5)
#' m + geom_histogram(binwidth = 0.1)
-#'
+#'
#' # Add aesthetic mappings
#' m + geom_histogram(aes(weight = votes))
#' m + geom_histogram(aes(y = ..count..))
#' m + geom_histogram(aes(fill = ..count..))
#'
#' # Change scales
-#' m + geom_histogram(aes(fill = ..count..)) +
+#' m + geom_histogram(aes(fill = ..count..)) +
#' scale_fill_gradient("Count", low = "green", high = "red")
#'
#' # Often we don't want the height of the bar to represent the
@@ -50,7 +50,7 @@
#' # category, we need to weight by the votes variable
#' qplot(rating, data=movies, geom="bar", binwidth = 0.1,
#' weight=votes, ylab = "votes")
-#'
+#'
#' m <- ggplot(movies, aes(x = votes))
#' # For transformed scales, binwidth applies to the transformed data.
#' # The bins have constant width on the transformed scale.
@@ -59,7 +59,7 @@
#' m + geom_histogram() + scale_x_sqrt()
#' m + geom_histogram(binwidth = 10) + scale_x_sqrt()
#'
-#' # For transformed coordinate systems, the binwidth applies to the
+#' # For transformed coordinate systems, the binwidth applies to the
#' # raw data. The bins have constant width on the original scale.
#'
#' # Using log scales does not work here, because the first
@@ -70,35 +70,35 @@
#' # Use origin = 0, to make sure we don't take sqrt of negative values
#' m + geom_histogram(origin = 0) + coord_trans(x = "sqrt")
#' m + geom_histogram(origin = 0, binwidth = 1000) + coord_trans(x = "sqrt")
-#'
+#'
#' # You can also transform the y axis. Remember that the base of the bars
-#' # has value 0, so log transformations are not appropriate
+#' # has value 0, so log transformations are not appropriate
#' m <- ggplot(movies, aes(x = rating))
#' m + geom_histogram(binwidth = 0.5) + scale_y_sqrt()
#' m + geom_histogram(binwidth = 0.5) + scale_y_reverse()
-#'
+#'
#' # Set aesthetics to fixed value
#' m + geom_histogram(colour = "darkgreen", fill = "white", binwidth = 0.5)
-#'
+#'
#' # Use facets
#' m <- m + geom_histogram(binwidth = 0.5)
#' m + facet_grid(Action ~ Comedy)
-#'
+#'
#' # Often more useful to use density on the y axis when facetting
#' m <- m + aes(y = ..density..)
#' m + facet_grid(Action ~ Comedy)
#' m + facet_wrap(~ mpaa)
#'
#' # Multiple histograms on the same graph
-#' # see ?position, ?position_fill, etc for more details.
+#' # see ?position, ?position_fill, etc for more details.
#' set.seed(6298)
-#' diamonds_small <- diamonds[sample(nrow(diamonds), 1000), ]
+#' diamonds_small <- diamonds[sample(nrow(diamonds), 1000), ]
#' ggplot(diamonds_small, aes(x=price)) + geom_bar()
#' hist_cut <- ggplot(diamonds_small, aes(x=price, fill=cut))
#' hist_cut + geom_bar() # defaults to stacking
#' hist_cut + geom_bar(position="fill")
#' hist_cut + geom_bar(position="dodge")
-#'
+#'
#' # This is easy in ggplot2, but not visually effective. It's better
#' # to use a frequency polygon or density plot. Like this:
#' ggplot(diamonds_small, aes(price, ..density.., colour = cut)) +
@@ -113,7 +113,8 @@
#' ggplot(diamonds_small, aes(depth, fill = cut)) +
#' geom_density(alpha = 0.2) + xlim(55, 70)
#' }
-geom_histogram <- function (mapping = NULL, data = NULL, stat = "bin", position = "stack", ...) {
+#' rm(movies)
+geom_histogram <- function (mapping = NULL, data = NULL, stat = "bin", position = "stack", ...) {
GeomHistogram$new(mapping = mapping, data = data, stat = stat, position = position, ...)
}
diff --git a/R/geom-bin2d.r b/R/geom-bin2d.r
index 5fdf602..0e3678e 100644
--- a/R/geom-bin2d.r
+++ b/R/geom-bin2d.r
@@ -1,6 +1,6 @@
#' Add heatmap of 2d bin counts.
#'
-#' @section Aesthetics:
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "bin2d")}
#'
#' @export
@@ -10,8 +10,8 @@
#' d + geom_bin2d()
#' d + geom_bin2d(binwidth = c(0.1, 0.1))
#'
-#' # See ?stat_bin2d for more examples
-geom_bin2d <- function (mapping = NULL, data = NULL, stat = "bin2d", position = "identity", ...) {
+#' # See ?stat_bin2d for more examples
+geom_bin2d <- function (mapping = NULL, data = NULL, stat = "bin2d", position = "identity", ...) {
GeomBin2d$new(mapping = mapping, data = data, stat = stat, position = position, ...)
}
@@ -21,9 +21,9 @@ GeomBin2d <- proto(Geom, {
}
objname <- "bin2d"
-
+
guide_geom <- function(.) "polygon"
-
+
default_stat <- function(.) StatBin2d
required_aes <- c("xmin", "xmax", "ymin", "ymax")
default_aes <- function(.) {
diff --git a/R/geom-blank.r b/R/geom-blank.r
index 742bb4d..bb0117a 100644
--- a/R/geom-blank.r
+++ b/R/geom-blank.r
@@ -1,5 +1,5 @@
#' Blank, draws nothing.
-#'
+#'
#' The blank geom draws nothing, but can be a useful way of ensuring common
#' scales between different plots.
#'
@@ -12,7 +12,7 @@
#' # Take the following scatter plot
#' a <- ggplot(mtcars, aes(x = wt, y = mpg), . ~ cyl) + geom_point()
#' # Add to that some lines with geom_abline()
-#' df <- data.frame(a = rnorm(10, 25), b = rnorm(10, 0))
+#' df <- data.frame(a = rnorm(10, 25), b = rnorm(10, 0))
#' a + geom_abline(aes(intercept = a, slope = b), data = df)
#' # Suppose you then wanted to remove the geom_point layer
#' # If you just remove geom_point, you will get an error
@@ -21,7 +21,7 @@
#' # Switching to geom_blank() gets the desired plot
#' c <- ggplot(mtcars, aes(x = wt, y = mpg)) + geom_blank()
#' c + geom_abline(aes(intercept = a, slope = b), data = df)
-geom_blank <- function (mapping = NULL, data = NULL, stat = "identity", position = "identity", ...) {
+geom_blank <- function (mapping = NULL, data = NULL, stat = "identity", position = "identity", ...) {
GeomBlank$new(mapping = mapping, data = data, stat = stat, position = position, ...)
}
@@ -34,5 +34,5 @@ GeomBlank <- proto(Geom, {
draw_legend <- function(., data, ...) {
zeroGrob()
}
-
+
})
diff --git a/R/geom-boxplot.r b/R/geom-boxplot.r
index b08629e..53d4807 100644
--- a/R/geom-boxplot.r
+++ b/R/geom-boxplot.r
@@ -16,22 +16,26 @@
#' This gives a roughly 95% confidence interval for comparing medians.
#' See McGill et al. (1978) for more details.
#'
-#' @section Aesthetics:
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "boxplot")}
#'
#' @seealso \code{\link{stat_quantile}} to view quantiles conditioned on a
-#' continuous variable, \code{\link{geom_jitter}} for another way to look
+#' continuous variable, \code{\link{geom_jitter}} for another way to look
#' at conditional distributions"
#' @inheritParams geom_point
-#' @param outlier.colour colour for outlying points
-#' @param outlier.shape shape of outlying points
-#' @param outlier.size size of outlying points
+#' @param outlier.colour colour for outlying points. Uses the default from geom_point().
+#' @param outlier.shape shape of outlying points. Uses the default from geom_point().
+#' @param outlier.size size of outlying points. Uses the default from geom_point().
#' @param notch if \code{FALSE} (default) make a standard box plot. If
#' \code{TRUE}, make a notched box plot. Notches are used to compare groups;
-#' if the notches of two boxes do not overlap, this is strong evidence that
+#' if the notches of two boxes do not overlap, this is strong evidence that
#' the medians differ.
#' @param notchwidth for a notched box plot, width of the notch relative to
#' the body (default 0.5)
+#' @param varwidth if \code{FALSE} (default) make a standard box plot. If
+#' \code{TRUE}, boxes are drawn with widths proportional to the
+#' square-roots of the number of observations in the groups (possibly
+#' weighted, using the \code{weight} aesthetic).
#' @export
#'
#' @references McGill, R., Tukey, J. W. and Larsen, W. A. (1978) Variations of
@@ -40,10 +44,10 @@
#' @examples
#' \donttest{
#' p <- ggplot(mtcars, aes(factor(cyl), mpg))
-#'
+#'
#' p + geom_boxplot()
#' qplot(factor(cyl), mpg, data = mtcars, geom = "boxplot")
-#'
+#'
#' p + geom_boxplot() + geom_jitter()
#' p + geom_boxplot() + coord_flip()
#' qplot(factor(cyl), mpg, data = mtcars, geom = "boxplot") +
@@ -51,22 +55,22 @@
#'
#' p + geom_boxplot(notch = TRUE)
#' p + geom_boxplot(notch = TRUE, notchwidth = .3)
-#'
+#'
#' p + geom_boxplot(outlier.colour = "green", outlier.size = 3)
-#'
+#'
#' # Add aesthetic mappings
-#' # Note that boxplots are automatically dodged when any aesthetic is
+#' # Note that boxplots are automatically dodged when any aesthetic is
#' # a factor
#' p + geom_boxplot(aes(fill = cyl))
#' p + geom_boxplot(aes(fill = factor(cyl)))
#' p + geom_boxplot(aes(fill = factor(vs)))
#' p + geom_boxplot(aes(fill = factor(am)))
-#'
+#'
#' # Set aesthetics to fixed value
#' p + geom_boxplot(fill = "grey80", colour = "#3366FF")
-#' qplot(factor(cyl), mpg, data = mtcars, geom = "boxplot",
+#' qplot(factor(cyl), mpg, data = mtcars, geom = "boxplot",
#' colour = I("#3366FF"))
-#'
+#'
#' # Scales vs. coordinate transforms -------
#' # Scale transformations occur before the boxplot statistics are computed.
#' # Coordinate transformations occur afterwards. Observe the effect on the
@@ -78,34 +82,57 @@
#' m + geom_boxplot() + scale_y_log10()
#' m + geom_boxplot() + coord_trans(y = "log10")
#' m + geom_boxplot() + scale_y_log10() + coord_trans(y = "log10")
-#'
+#'
#' # Boxplots with continuous x:
#' # Use the group aesthetic to group observations in boxplots
#' qplot(year, budget, data = movies, geom = "boxplot")
-#' qplot(year, budget, data = movies, geom = "boxplot",
+#' qplot(year, budget, data = movies, geom = "boxplot",
#' group = round_any(year, 10, floor))
#'
#' # Using precomputed statistics
#' # generate sample data
#' abc <- adply(matrix(rnorm(100), ncol = 5), 2, quantile, c(0, .25, .5, .75, 1))
-#' b <- ggplot(abc, aes(x = X1, ymin = `0%`, lower = `25%`, middle = `50%`, upper = `75%`, ymax = `100%`))
+#' b <- ggplot(abc, aes(x = X1, ymin = `0%`, lower = `25%`,
+#' middle = `50%`, upper = `75%`, ymax = `100%`))
#' b + geom_boxplot(stat = "identity")
#' b + geom_boxplot(stat = "identity") + coord_flip()
#' b + geom_boxplot(aes(fill = X1), stat = "identity")
+#'
+#' # Using varwidth
+#' p + geom_boxplot(varwidth = TRUE)
+#' qplot(factor(cyl), mpg, data = mtcars, geom = "boxplot", varwidth = TRUE)
+#'
+#' # Update the defaults for the outliers by changing the defaults for geom_point
+#'
+#' p <- ggplot(mtcars, aes(factor(cyl), mpg))
+#' p + geom_boxplot()
+#'
+#' update_geom_defaults("point", list(shape = 1, colour = "red", size = 5))
+#' p + geom_boxplot()
#' }
-geom_boxplot <- function (mapping = NULL, data = NULL, stat = "boxplot", position = "dodge",
-outlier.colour = "black", outlier.shape = 16, outlier.size = 2,
-notch = FALSE, notchwidth = .5, ...) {
- GeomBoxplot$new(mapping = mapping, data = data, stat = stat,
- position = position, outlier.colour = outlier.colour, outlier.shape = outlier.shape,
- outlier.size = outlier.size, notch = notch, notchwidth = notchwidth, ...)
+geom_boxplot <- function (mapping = NULL, data = NULL, stat = "boxplot",
+ position = "dodge", outlier.colour = NULL,
+ outlier.shape = NULL, outlier.size = NULL,
+ notch = FALSE, notchwidth = .5, varwidth = FALSE,
+ ...) {
+
+ outlier_defaults <- Geom$find('point')$default_aes()
+
+ outlier.colour <- outlier.colour %||% outlier_defaults$colour
+ outlier.shape <- outlier.shape %||% outlier_defaults$shape
+ outlier.size <- outlier.size %||% outlier_defaults$size
+
+ GeomBoxplot$new(mapping = mapping, data = data, stat = stat,
+ position = position, outlier.colour = outlier.colour,
+ outlier.shape = outlier.shape, outlier.size = outlier.size, notch = notch,
+ notchwidth = notchwidth, varwidth = varwidth, ...)
}
GeomBoxplot <- proto(Geom, {
objname <- "boxplot"
reparameterise <- function(., df, params) {
- df$width <- df$width %||%
+ df$width <- df$width %||%
params$width %||% (resolution(df$x, FALSE) * 0.9)
if (!is.null(df$outliers)) {
@@ -113,48 +140,58 @@ GeomBoxplot <- proto(Geom, {
out_min <- vapply(df$outliers, min, numeric(1))
out_max <- vapply(df$outliers, max, numeric(1))
})
-
+
df$ymin_final <- pmin(out_min, df$ymin)
df$ymax_final <- pmax(out_max, df$ymax)
- }
-
- transform(df,
- xmin = x - width / 2, xmax = x + width / 2, width = NULL
- )
+ }
+ # if `varwidth` not requested or not available, don't use it
+ if (is.null(params) || is.null(params$varwidth) || !params$varwidth || is.null(df$relvarwidth)) {
+ df$xmin <- df$x - df$width / 2
+ df$xmax <- df$x + df$width / 2
+ } else {
+ # make `relvarwidth` relative to the size of the largest group
+ df$relvarwidth <- df$relvarwidth / max(df$relvarwidth)
+ df$xmin <- df$x - df$relvarwidth * df$width / 2
+ df$xmax <- df$x + df$relvarwidth * df$width / 2
+ }
+ df$width <- NULL
+ if (!is.null(df$relvarwidth)) df$relvarwidth <- NULL
+
+ df
}
-
+
draw <- function(., data, ..., fatten = 2, outlier.colour = NULL, outlier.shape = NULL, outlier.size = 2,
- notch = FALSE, notchwidth = .5) {
+ notch = FALSE, notchwidth = .5, varwidth = FALSE) {
common <- data.frame(
- colour = data$colour,
- size = data$size,
+ colour = data$colour,
+ size = data$size,
linetype = data$linetype,
- fill = alpha(data$fill, data$alpha),
+ fill = alpha(data$fill, data$alpha),
group = data$group,
stringsAsFactors = FALSE
)
whiskers <- data.frame(
x = data$x,
- xend = data$x,
- y = c(data$upper, data$lower),
+ xend = data$x,
+ y = c(data$upper, data$lower),
yend = c(data$ymax, data$ymin),
alpha = NA,
common)
box <- data.frame(
- xmin = data$xmin,
- xmax = data$xmax,
- ymin = data$lower,
- y = data$middle,
+ xmin = data$xmin,
+ xmax = data$xmax,
+ ymin = data$lower,
+ y = data$middle,
ymax = data$upper,
ynotchlower = ifelse(notch, data$notchlower, NA),
ynotchupper = ifelse(notch, data$notchupper, NA),
notchwidth = notchwidth,
- alpha = data$alpha,
+ alpha = data$alpha,
common)
-
+
if (!is.null(data$outliers) && length(data$outliers[[1]] >= 1)) {
outliers <- data.frame(
y = data$outliers[[1]],
@@ -169,7 +206,7 @@ GeomBoxplot <- proto(Geom, {
} else {
outliers_grob <- NULL
}
-
+
ggname(.$my_name(), grobTree(
outliers_grob,
GeomSegment$draw(whiskers, ...),
@@ -177,7 +214,7 @@ GeomBoxplot <- proto(Geom, {
))
}
- guide_geom <- function(.) "boxplot"
+ guide_geom <- function(.) "boxplot"
draw_legend <- function(., data, ...) {
data <- aesdefaults(data, .$default_aes(), list(...))
gp <- with(data, gpar(col=colour, fill=alpha(fill, alpha), lwd=size * .pt, lty = linetype))
@@ -188,7 +225,7 @@ GeomBoxplot <- proto(Geom, {
linesGrob(c(0.125, 0.875), 0.5)
))
}
-
+
default_stat <- function(.) StatBoxplot
default_pos <- function(.) PositionDodge
default_aes <- function(.) aes(weight=1, colour="grey20", fill="white", size=0.5, alpha = NA, shape = 16, linetype = "solid")
diff --git a/R/geom-crossbar.r b/R/geom-crossbar.r
index 9a76656..bb6db95 100644
--- a/R/geom-crossbar.r
+++ b/R/geom-crossbar.r
@@ -1,6 +1,6 @@
#' Hollow bar with middle indicated by horizontal line.
#'
-#' @section Aesthetics:
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "crossbar")}
#'
#' @inheritParams geom_point
@@ -12,15 +12,15 @@
#' @export
#' @examples
#' # See geom_linerange for examples
-geom_crossbar <- function (mapping = NULL, data = NULL, stat = "identity", position = "identity",
-fatten = 2, ...) {
- GeomCrossbar$new(mapping = mapping, data = data, stat = stat,
+geom_crossbar <- function (mapping = NULL, data = NULL, stat = "identity", position = "identity",
+fatten = 2, ...) {
+ GeomCrossbar$new(mapping = mapping, data = data, stat = stat,
position = position, fatten = fatten, ...)
}
GeomCrossbar <- proto(Geom, {
objname <- "crossbar"
-
+
reparameterise <- function(., df, params) {
GeomErrorbar$reparameterise(df, params)
}
@@ -38,11 +38,11 @@ GeomCrossbar <- proto(Geom, {
linesGrob(c(0.125, 0.875), 0.5)
))
}
-
+
draw <- function(., data, scales, coordinates, fatten = 2, width = NULL, ...) {
middle <- transform(data, x = xmin, xend = xmax, yend = y, size = size * fatten, alpha = NA)
- has_notch <- !is.null(data$ynotchlower) && !is.null(data$ynotchupper) &&
+ has_notch <- !is.null(data$ynotchlower) && !is.null(data$ynotchupper) &&
!is.na(data$ynotchlower) && !is.na(data$ynotchupper)
if (has_notch) {
diff --git a/R/geom-defaults.r b/R/geom-defaults.r
index 514aeec..f21f247 100644
--- a/R/geom-defaults.r
+++ b/R/geom-defaults.r
@@ -1,5 +1,5 @@
#' Modify geom/stat aesthetic defaults for future plots
-#'
+#'
#' @param stat,geom name of geom/stat to modify
#' @param new named list of aesthetics
#' @export
@@ -11,9 +11,9 @@
update_geom_defaults <- function(geom, new) {
g <- Geom$find(geom)
old <- g$default_aes()
-
+
aes <- defaults(new, old)
-
+
g$default_aes <- eval(substitute(function(.) aes, list(aes = aes)))
}
@@ -22,7 +22,7 @@ update_geom_defaults <- function(geom, new) {
update_stat_defaults <- function(stat, new) {
g <- Stat$find(stat)
old <- g$default_aes()
-
+
aes <- defaults(new, old)
g$default_aes <- eval(substitute(function(.) aes, list(aes = aes)))
}
diff --git a/R/geom-dotplot.r b/R/geom-dotplot.r
index c9ac0dd..9cda82c 100644
--- a/R/geom-dotplot.r
+++ b/R/geom-dotplot.r
@@ -16,7 +16,7 @@
#' hide the y axis, as in one of the examples, or manually scale it
#' to match the number of dots.
#'
-#' @section Aesthetics:
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "dotplot")}
#'
#' @inheritParams geom_point
@@ -30,7 +30,7 @@
#' determines positions of the bins for each group separately. "all" determines
#' positions of the bins with all the data taken together; this is used for
#' aligning dot stacks across multiple groups.
-#' @param stackdir which direction to stack the dots. "up" (default),
+#' @param stackdir which direction to stack the dots. "up" (default),
#' "down", "center", "centerwhole" (centered, but with dots aligned)
#' @param stackratio how close to stack the dots. Default is 1, where dots just
#' just touch. Use smaller values for closer, overlapping dots.
@@ -49,7 +49,7 @@
#' ggplot(mtcars, aes(x = mpg)) + geom_dotplot(binwidth = 1.5)
#'
#' # Use fixed-width bins
-#' ggplot(mtcars, aes(x = mpg)) +
+#' ggplot(mtcars, aes(x = mpg)) +
#' geom_dotplot(method="histodot", binwidth = 1.5)
#'
#' # Some other stacking methods
@@ -59,8 +59,8 @@
#' geom_dotplot(binwidth = 1.5, stackdir = "centerwhole")
#'
#' # y axis isn't really meaningful, so hide it
-#' ggplot(mtcars, aes(x = mpg)) + geom_dotplot(binwidth = 1.5) +
-#' scale_y_continuous(name = "", breaks = NA)
+#' ggplot(mtcars, aes(x = mpg)) + geom_dotplot(binwidth = 1.5) +
+#' scale_y_continuous(name = "", breaks = NULL)
#'
#' # Overlap dots vertically
#' ggplot(mtcars, aes(x = mpg)) + geom_dotplot(binwidth = 1.5, stackratio = .7)
@@ -73,17 +73,17 @@
#' ggplot(mtcars, aes(x = 1, y = mpg)) +
#' geom_dotplot(binaxis = "y", stackdir = "center")
#'
-#' ggplot(mtcars, aes(x = factor(cyl), y = mpg)) +
+#' ggplot(mtcars, aes(x = factor(cyl), y = mpg)) +
#' geom_dotplot(binaxis = "y", stackdir = "center")
#'
-#' ggplot(mtcars, aes(x = factor(cyl), y = mpg)) +
+#' ggplot(mtcars, aes(x = factor(cyl), y = mpg)) +
#' geom_dotplot(binaxis = "y", stackdir = "centerwhole")
#'
-#' ggplot(mtcars, aes(x = factor(vs), fill = factor(cyl), y = mpg)) +
+#' ggplot(mtcars, aes(x = factor(vs), fill = factor(cyl), y = mpg)) +
#' geom_dotplot(binaxis = "y", stackdir = "center", position = "dodge")
#'
#' # binpositions="all" ensures that the bins are aligned between groups
-#' ggplot(mtcars, aes(x = factor(am), y = mpg)) +
+#' ggplot(mtcars, aes(x = factor(am), y = mpg)) +
#' geom_dotplot(binaxis = "y", stackdir = "center", binpositions="all")
#'
#' # Stacking multiple groups, with different fill
@@ -96,6 +96,9 @@
#' ggplot(mtcars, aes(x = 1, y = mpg, fill = factor(cyl))) +
#' geom_dotplot(binaxis = "y", stackgroups = TRUE, binwidth = 1, method = "histodot")
#'
+#' # Use qplot instead
+#' qplot(mpg, data = mtcars, geom = "dotplot")
+#'
geom_dotplot <- function (mapping = NULL, data = NULL, stat = "bindot", position = "identity",
na.rm = FALSE, binwidth = NULL, binaxis = "x", method="dotdensity", binpositions = "bygroup", stackdir = "up",
stackratio = 1, dotsize = 1, stackgroups = FALSE, ...) {
@@ -148,11 +151,11 @@ GeomDotplot <- proto(Geom, {
reparameterise <- function(., df, params) {
- df$width <- df$width %||%
+ df$width <- df$width %||%
params$width %||% (resolution(df$x, FALSE) * 0.9)
# Set up the stacking function and range
- if(params$stackdir == "up") {
+ if(is.null(params$stackdir) || params$stackdir == "up") {
stackdots <- function(a) a - .5
stackaxismin <- 0
stackaxismax <- 1
@@ -176,8 +179,9 @@ GeomDotplot <- proto(Geom, {
# Next part will set the position of each dot within each stack
# If stackgroups=TRUE, split only on x (or y) and panel; if not stacking, also split by group
- plyvars <- c(params$binaxis, "PANEL")
- if (!params$stackgroups)
+ plyvars <- params$binaxis %||% "x"
+ plyvars <- c(plyvars, "PANEL")
+ if (is.null(params$stackgroups) || !params$stackgroups)
plyvars <- c(plyvars, "group")
# Within each x, or x+group, set countidx=1,2,3, and set stackpos according to stack function
@@ -189,7 +193,7 @@ GeomDotplot <- proto(Geom, {
# Set the bounding boxes for the dots
- if (params$binaxis == "x") {
+ if (is.null(params$binaxis) || params$binaxis == "x") {
# ymin, ymax, xmin, and xmax define the bounding rectangle for each stack
# Can't do bounding box per dot, because y position isn't real.
# After position code is rewritten, each dot should have its own bounding box.
@@ -257,18 +261,18 @@ GeomDotplot <- proto(Geom, {
data$shape <- 21
data <- aesdefaults(data, .$default_aes(), list(...))
-
+
with(data,
pointsGrob(0.5, 0.5, size = unit(.5, "npc"), pch = shape,
gp = gpar(
- col = alpha(colour, alpha),
+ col = alpha(colour, alpha),
fill = alpha(fill, alpha))
)
)
}
-
+
default_stat <- function(.) StatBindot
required_aes <- c("x", "y")
default_aes <- function(.) aes(y=..count.., colour="black", fill = "black", alpha = NA)
-
+
})
diff --git a/R/geom-error.r b/R/geom-error.r
index d1d3a76..08f22c0 100644
--- a/R/geom-error.r
+++ b/R/geom-error.r
@@ -1,6 +1,6 @@
#' Error bars.
#'
-#' @section Aesthetics:
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "errorbar")}
#'
#' @seealso \code{\link{geom_pointrange}}: range indicated by straight line,
@@ -13,24 +13,24 @@
#' @examples
#' # Create a simple example dataset
#' df <- data.frame(
-#' trt = factor(c(1, 1, 2, 2)),
-#' resp = c(1, 5, 3, 4),
-#' group = factor(c(1, 2, 1, 2)),
+#' trt = factor(c(1, 1, 2, 2)),
+#' resp = c(1, 5, 3, 4),
+#' group = factor(c(1, 2, 1, 2)),
#' se = c(0.1, 0.3, 0.3, 0.2)
#' )
#' df2 <- df[c(1,3),]
-#'
+#'
#' # Define the top and bottom of the errorbars
#' limits <- aes(ymax = resp + se, ymin=resp - se)
-#'
+#'
#' p <- ggplot(df, aes(fill=group, y=resp, x=trt))
#' p + geom_bar(position="dodge", stat="identity")
-#'
+#'
#' # Because the bars and errorbars have different widths
#' # we need to specify how wide the objects we are dodging are
#' dodge <- position_dodge(width=0.9)
#' p + geom_bar(position=dodge) + geom_errorbar(limits, position=dodge, width=0.25)
-#'
+#'
#' p <- ggplot(df2, aes(fill=group, y=resp, x=trt))
#' p + geom_bar(position=dodge)
#' p + geom_bar(position=dodge) + geom_errorbar(limits, position=dodge, width=0.25)
@@ -41,40 +41,40 @@
#' p + geom_crossbar(limits, width=0.2)
#'
#' # If we want to draw lines, we need to manually set the
-#' # groups which define the lines - here the groups in the
+#' # groups which define the lines - here the groups in the
#' # original dataframe
-#' p + geom_line(aes(group=group)) + geom_errorbar(limits, width=0.2)
-geom_errorbar <- function (mapping = NULL, data = NULL, stat = "identity", position = "identity", ...) {
+#' p + geom_line(aes(group=group)) + geom_errorbar(limits, width=0.2)
+geom_errorbar <- function (mapping = NULL, data = NULL, stat = "identity", position = "identity", ...) {
GeomErrorbar$new(mapping = mapping, data = data, stat = stat, position = position, ...)
}
GeomErrorbar <- proto(Geom, {
objname <- "errorbar"
-
+
default_stat <- function(.) StatIdentity
default_aes <- function(.) aes(colour = "black", size=0.5, linetype=1, width=0.5, alpha = NA)
guide_geom <- function(.) "path"
required_aes <- c("x", "ymin", "ymax")
-
+
reparameterise <- function(., df, params) {
- df$width <- df$width %||%
+ df$width <- df$width %||%
params$width %||% (resolution(df$x, FALSE) * 0.9)
-
+
transform(df,
xmin = x - width / 2, xmax = x + width / 2, width = NULL
)
}
draw <- function(., data, scales, coordinates, width = NULL, ...) {
- GeomPath$draw(with(data, data.frame(
- x = as.vector(rbind(xmin, xmax, NA, x, x, NA, xmin, xmax)),
+ GeomPath$draw(with(data, data.frame(
+ x = as.vector(rbind(xmin, xmax, NA, x, x, NA, xmin, xmax)),
y = as.vector(rbind(ymax, ymax, NA, ymax, ymin, NA, ymin, ymin)),
colour = rep(colour, each = 8),
alpha = rep(alpha, each = 8),
size = rep(size, each = 8),
linetype = rep(linetype, each = 8),
group = rep(1:(nrow(data)), each = 8),
- stringsAsFactors = FALSE,
+ stringsAsFactors = FALSE,
row.names = 1:(nrow(data) * 8)
)), scales, coordinates, ...)
}
diff --git a/R/geom-errorh.r b/R/geom-errorh.r
index bafde1d..9953b6c 100644
--- a/R/geom-errorh.r
+++ b/R/geom-errorh.r
@@ -1,6 +1,6 @@
#' Horizontal error bars
#'
-#' @section Aesthetics:
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "errorbarh")}
#'
#' @seealso \code{\link{geom_errorbar}}: vertical error bars
@@ -8,52 +8,52 @@
#' @export
#' @examples
#' df <- data.frame(
-#' trt = factor(c(1, 1, 2, 2)),
-#' resp = c(1, 5, 3, 4),
-#' group = factor(c(1, 2, 1, 2)),
+#' trt = factor(c(1, 1, 2, 2)),
+#' resp = c(1, 5, 3, 4),
+#' group = factor(c(1, 2, 1, 2)),
#' se = c(0.1, 0.3, 0.3, 0.2)
#' )
-#'
+#'
#' # Define the top and bottom of the errorbars
-#'
+#'
#' p <- ggplot(df, aes(resp, trt, colour = group))
#' p + geom_point() +
#' geom_errorbarh(aes(xmax = resp + se, xmin = resp - se))
#' p + geom_point() +
#' geom_errorbarh(aes(xmax = resp + se, xmin = resp - se, height = .2))
-geom_errorbarh <- function (mapping = NULL, data = NULL, stat = "identity", position = "identity", ...) {
+geom_errorbarh <- function (mapping = NULL, data = NULL, stat = "identity", position = "identity", ...) {
GeomErrorbarh$new(mapping = mapping, data = data, stat = stat, position = position, ...)
}
GeomErrorbarh <- proto(Geom, {
objname <- "errorbarh"
-
+
default_stat <- function(.) StatIdentity
default_aes <- function(.) aes(colour = "black", size=0.5, linetype=1, height=0.5, alpha = NA)
guide_geom <- function(.) "path"
required_aes <- c("x", "xmin", "xmax", "y")
-
+
reparameterise <- function(., df, params) {
- df$height <- df$height %||%
+ df$height <- df$height %||%
params$height %||% (resolution(df$y, FALSE) * 0.9)
-
+
transform(df,
ymin = y - height / 2, ymax = y + height / 2, height = NULL
)
}
-
+
draw <- function(., data, scales, coordinates, height = NULL, ...) {
- GeomPath$draw(with(data, data.frame(
+ GeomPath$draw(with(data, data.frame(
x = as.vector(rbind(xmax, xmax, NA, xmax, xmin, NA, xmin, xmin)),
- y = as.vector(rbind(ymin, ymax, NA, y, y, NA, ymin, ymax)),
+ y = as.vector(rbind(ymin, ymax, NA, y, y, NA, ymin, ymax)),
colour = rep(colour, each = 8),
alpha = rep(alpha, each = 8),
size = rep(size, each = 8),
linetype = rep(linetype, each = 8),
group = rep(1:(nrow(data)), each = 8),
- stringsAsFactors = FALSE,
+ stringsAsFactors = FALSE,
row.names = 1:(nrow(data) * 8)
)), scales, coordinates, ...)
}
-
+
})
diff --git a/R/geom-freqpoly.r b/R/geom-freqpoly.r
index 74c40be..0f11912 100644
--- a/R/geom-freqpoly.r
+++ b/R/geom-freqpoly.r
@@ -1,6 +1,6 @@
#' Frequency polygon.
#'
-#' @section Aesthetics:
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "freqpoly")}
#'
#' @seealso \code{\link{geom_histogram}}: histograms
@@ -10,19 +10,19 @@
#' qplot(carat, data = diamonds, geom = "freqpoly")
#' qplot(carat, data = diamonds, geom = "freqpoly", binwidth = 0.1)
#' qplot(carat, data = diamonds, geom = "freqpoly", binwidth = 0.01)
-#'
+#'
#' qplot(price, data = diamonds, geom = "freqpoly", binwidth = 1000)
-#' qplot(price, data = diamonds, geom = "freqpoly", binwidth = 1000,
+#' qplot(price, data = diamonds, geom = "freqpoly", binwidth = 1000,
#' colour = color)
-#' qplot(price, ..density.., data = diamonds, geom = "freqpoly",
+#' qplot(price, ..density.., data = diamonds, geom = "freqpoly",
#' binwidth = 1000, colour = color)
-geom_freqpoly <- function (mapping = NULL, data = NULL, stat = "bin", position = "identity", ...) {
+geom_freqpoly <- function (mapping = NULL, data = NULL, stat = "bin", position = "identity", ...) {
GeomFreqpoly$new(mapping = mapping, data = data, stat = stat, position = position, ...)
}
GeomFreqpoly <- proto(Geom, {
objname <- "freqpoly"
-
+
default_aes <- function(.) GeomPath$default_aes()
default_stat <- function(.) StatBin
draw <- function(., ...) GeomPath$draw(...)
diff --git a/R/geom-hex.r b/R/geom-hex.r
index 481eb22..fa7d4c5 100644
--- a/R/geom-hex.r
+++ b/R/geom-hex.r
@@ -1,37 +1,37 @@
#' Hexagon bining.
#'
-#' @section Aesthetics:
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "hex")}
#'
#' @export
#' @inheritParams geom_point
#' @examples
-#' # See ?stat_binhex for examples
-geom_hex <- function (mapping = NULL, data = NULL, stat = "binhex", position = "identity", ...) {
+#' # See ?stat_binhex for examples
+geom_hex <- function (mapping = NULL, data = NULL, stat = "binhex", position = "identity", ...) {
GeomHex$new(mapping = mapping, data = data, stat = stat, position = position, ...)
}
GeomHex <- proto(Geom, {
objname <- "hex"
- draw <- function(., data, scales, coordinates, ...) {
- with(coord_transform(coordinates, data, scales),
- ggname(.$my_name(), hexGrob(x, y, col=colour,
+ draw <- function(., data, scales, coordinates, ...) {
+ with(coord_transform(coordinates, data, scales),
+ ggname(.$my_name(), hexGrob(x, y, col=colour,
fill = alpha(fill, alpha)))
)
}
-
+
required_aes <- c("x", "y")
default_aes <- function(.) aes(colour=NA, fill = "grey50", size=0.5, alpha = NA)
default_stat <- function(.) StatBinhex
guide_geom <- function(.) "polygon"
-
+
})
# Draw hexagon grob
# Modified from code by Nicholas Lewin-Koh and Martin Maechler
-#
+#
# @param x positions of hex centres
# @param y positions
# @param vector of hex sizes
@@ -40,12 +40,12 @@ GeomHex <- proto(Geom, {
# @keyword internal
hexGrob <- function(x, y, size = rep(1, length(x)), colour = "grey50", fill = "grey90") {
stopifnot(length(y) == length(x))
-
+
dx <- resolution(x, FALSE)
dy <- resolution(y, FALSE) / sqrt(3) / 2 * 1.15
-
+
hexC <- hexcoords(dx, dy, n = 1)
-
+
n <- length(x)
polygonGrob(
diff --git a/R/geom-hline.r b/R/geom-hline.r
index dd6c405..eb47ca5 100644
--- a/R/geom-hline.r
+++ b/R/geom-hline.r
@@ -4,16 +4,16 @@
#' \code{\link{geom_vline}} and \code{\link{geom_abline}} for other types of
#' lines).
#'
-#' There are two ways to use it. You can either specify the intercept of
+#' There are two ways to use it. You can either specify the intercept of
#' the line in the call to the geom, in which case the line will be in the
#' same position in every panel. Alternatively, you can supply a different
#' intercept for each panel using a data.frame. See the examples for the
#' differences
#'
-#' @section Aesthetics:
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "hline")}
#'
-#' @seealso \code{\link{geom_vline}} for vertical lines,
+#' @seealso \code{\link{geom_vline}} for vertical lines,
#' \code{\link{geom_abline}} for lines defined by a slope and intercept,
#' \code{\link{geom_segment}} for a more general approach
#' @export
@@ -21,23 +21,23 @@
#' @param show_guide should a legend be drawn? (defaults to \code{FALSE})
#' @examples
#' p <- ggplot(mtcars, aes(x = wt, y=mpg)) + geom_point()
-#'
+#'
#' p + geom_hline(aes(yintercept=mpg))
#' p + geom_hline(yintercept=20)
#' p + geom_hline(yintercept=seq(10, 30, by=5))
-#'
+#'
#' # With coordinate transforms
#' p + geom_hline(aes(yintercept=mpg)) + coord_equal()
#' p + geom_hline(aes(yintercept=mpg)) + coord_flip()
#' p + geom_hline(aes(yintercept=mpg)) + coord_polar()
-#'
-#' # To display different lines in different facets, you need to
+#'
+#' # To display different lines in different facets, you need to
#' # create a data frame.
#' p <- qplot(mpg, wt, data=mtcars, facets = vs ~ am)
-#'
+#'
#' hline.data <- data.frame(z = 1:4, vs = c(0,0,1,1), am = c(0,1,0,1))
#' p + geom_hline(aes(yintercept = z), hline.data)
-geom_hline <- function (mapping = NULL, data = NULL, stat = "hline", position = "identity", show_guide = FALSE, ...) {
+geom_hline <- function (mapping = NULL, data = NULL, stat = "hline", position = "identity", show_guide = FALSE, ...) {
GeomHline$new(mapping = mapping, data = data, stat = stat, position = position, show_guide = show_guide, ...)
}
@@ -50,7 +50,7 @@ GeomHline <- proto(Geom, {
yintercept <- NULL
mapping <- aes_all(names(data))
}
- .super$new(., data = data, mapping = mapping, inherit.aes = FALSE,
+ .super$new(., data = data, mapping = mapping, inherit.aes = FALSE,
yintercept = yintercept, ...)
}
@@ -59,7 +59,7 @@ GeomHline <- proto(Geom, {
data$x <- ranges$x[1]
data$xend <- ranges$x[2]
-
+
GeomSegment$draw(unique(data), scales, coordinates)
}
diff --git a/R/geom-linerange.r b/R/geom-linerange.r
index 15a879b..02e213e 100644
--- a/R/geom-linerange.r
+++ b/R/geom-linerange.r
@@ -1,6 +1,6 @@
#' An interval represented by a vertical line.
#'
-#' @section Aesthetics:
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "linerange")}
#'
#' @seealso \code{\link{geom_errorbar}}: error bars;
@@ -14,27 +14,28 @@
#' # Generate data: means and standard errors of means for prices
#' # for each type of cut
#' dmod <- lm(price ~ cut, data=diamonds)
-#' cuts <- data.frame(cut=unique(diamonds$cut), predict(dmod, data.frame(cut = unique(diamonds$cut)), se=TRUE)[c("fit","se.fit")])
-#'
+#' cuts <- data.frame(cut = unique(diamonds$cut),
+#' predict(dmod, data.frame(cut = unique(diamonds$cut)), se=TRUE)[c("fit","se.fit")])
+#'
#' qplot(cut, fit, data=cuts)
-#' # With a bar chart, we are comparing lengths, so the y-axis is
+#' # With a bar chart, we are comparing lengths, so the y-axis is
#' # automatically extended to include 0
#' qplot(cut, fit, data=cuts, geom="bar")
-#'
+#'
#' # Display estimates and standard errors in various ways
-#' se <- ggplot(cuts, aes(cut, fit,
+#' se <- ggplot(cuts, aes(cut, fit,
#' ymin = fit - se.fit, ymax=fit + se.fit, colour = cut))
#' se + geom_linerange()
#' se + geom_pointrange()
#' se + geom_errorbar(width = 0.5)
#' se + geom_crossbar(width = 0.5)
-#'
+#'
#' # Use coord_flip to flip the x and y axes
#' se + geom_linerange() + coord_flip()
-geom_linerange <- function (mapping = NULL, data = NULL, stat = "identity", position = "identity", ...) {
+geom_linerange <- function (mapping = NULL, data = NULL, stat = "identity", position = "identity", ...) {
GeomLinerange$new(mapping = mapping, data = data, stat = stat, position = position, ...)
}
-
+
GeomLinerange <- proto(Geom, {
objname <- "linerange"
@@ -47,5 +48,5 @@ GeomLinerange <- proto(Geom, {
munched <- coord_transform(coordinates, data, scales)
ggname(.$my_name(), GeomSegment$draw(transform(data, xend=x, y=ymin, yend=ymax), scales, coordinates, ...))
}
-
+
})
diff --git a/R/geom-map.r b/R/geom-map.r
index 02b7f77..89af85c 100644
--- a/R/geom-map.r
+++ b/R/geom-map.r
@@ -3,14 +3,14 @@ NULL
#' Polygons from a reference map.
#'
-#' Does not affect position scales.
-#'
-#' @section Aesthetics:
+#' Does not affect position scales.
+#'
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "map")}
#'
#' @export
-#' @param map Data frame that contains the map coordinates. This will
-#' typically be created using \code{\link{fortify}} on a spatial object.
+#' @param map Data frame that contains the map coordinates. This will
+#' typically be created using \code{\link{fortify}} on a spatial object.
#' It must contain columns \code{x} or \code{long}, \code{y} or
#' \code{lat}, and \code{region} or \code{id}.
#' @inheritParams geom_point
@@ -19,29 +19,29 @@ NULL
#' # one contains the coordinates of each polygon (positions), and the
#' # other the values associated with each polygon (values). An id
#' # variable links the two together
-#'
+#'
#' ids <- factor(c("1.1", "2.1", "1.2", "2.2", "1.3", "2.3"))
-#'
+#'
#' values <- data.frame(
-#' id = ids,
+#' id = ids,
#' value = c(3, 3.1, 3.1, 3.2, 3.15, 3.5)
#' )
-#'
+#'
#' positions <- data.frame(
#' id = rep(ids, each = 4),
-#' x = c(2, 1, 1.1, 2.2, 1, 0, 0.3, 1.1, 2.2, 1.1, 1.2, 2.5, 1.1, 0.3,
+#' x = c(2, 1, 1.1, 2.2, 1, 0, 0.3, 1.1, 2.2, 1.1, 1.2, 2.5, 1.1, 0.3,
#' 0.5, 1.2, 2.5, 1.2, 1.3, 2.7, 1.2, 0.5, 0.6, 1.3),
-#' y = c(-0.5, 0, 1, 0.5, 0, 0.5, 1.5, 1, 0.5, 1, 2.1, 1.7, 1, 1.5,
+#' y = c(-0.5, 0, 1, 0.5, 0, 0.5, 1.5, 1, 0.5, 1, 2.1, 1.7, 1, 1.5,
#' 2.2, 2.1, 1.7, 2.1, 3.2, 2.8, 2.1, 2.2, 3.3, 3.2)
#' )
-#'
-#' ggplot(values) + geom_map(aes(map_id = id), map = positions) +
+#'
+#' ggplot(values) + geom_map(aes(map_id = id), map = positions) +
#' expand_limits(positions)
-#' ggplot(values, aes(fill = value)) +
-#' geom_map(aes(map_id = id), map = positions) +
+#' ggplot(values, aes(fill = value)) +
+#' geom_map(aes(map_id = id), map = positions) +
#' expand_limits(positions)
-#' ggplot(values, aes(fill = value)) +
-#' geom_map(aes(map_id = id), map = positions) +
+#' ggplot(values, aes(fill = value)) +
+#' geom_map(aes(map_id = id), map = positions) +
#' expand_limits(positions) + ylim(0, 3)
#'
#' # Better example
@@ -50,11 +50,17 @@ NULL
#' crimesm <- melt(crimes, id = 1)
#' if (require(maps)) {
#' states_map <- map_data("state")
-#' ggplot(crimes, aes(map_id = state)) + geom_map(aes(fill = Murder), map = states_map) + expand_limits(x = states_map$long, y = states_map$lat)
+#' ggplot(crimes, aes(map_id = state)) +
+#' geom_map(aes(fill = Murder), map = states_map) +
+#' expand_limits(x = states_map$long, y = states_map$lat)
+#'
#' last_plot() + coord_map()
-#' ggplot(crimesm, aes(map_id = state)) + geom_map(aes(fill = value), map = states_map) + expand_limits(x = states_map$long, y = states_map$lat) + facet_wrap( ~ variable)
+#' ggplot(crimesm, aes(map_id = state)) +
+#' geom_map(aes(fill = value), map = states_map) +
+#' expand_limits(x = states_map$long, y = states_map$lat) +
+#' facet_wrap( ~ variable)
#' }
-geom_map <- function(mapping = NULL, data = NULL, map, stat = "identity", ...) {
+geom_map <- function(mapping = NULL, data = NULL, map, stat = "identity", ...) {
# Get map input into correct form
stopifnot(is.data.frame(map))
@@ -62,8 +68,8 @@ geom_map <- function(mapping = NULL, data = NULL, map, stat = "identity", ...) {
if (!is.null(map$long)) map$x <- map$long
if (!is.null(map$region)) map$id <- map$region
stopifnot(all(c("x", "y", "id") %in% names(map)))
-
- GeomMap$new(geom_params = list(map = map, ...), mapping = mapping,
+
+ GeomMap$new(geom_params = list(map = map, ...), mapping = mapping,
data = data, stat = stat, ...)
}
@@ -75,23 +81,23 @@ GeomMap <- proto(GeomPolygon, {
common <- intersect(data$map_id, map$id)
data <- data[data$map_id %in% common, , drop = FALSE]
map <- map[map$id %in% common, , drop = FALSE]
-
+
# Munch, then set up id variable for polygonGrob -
# must be sequential integers
coords <- coord_munch(coordinates, map, scales)
coords$group <- coords$group %||% coords$id
grob_id <- match(coords$group, unique(coords$group))
-
+
# Align data with map
data_rows <- match(coords$id[!duplicated(grob_id)], data$map_id)
data <- data[data_rows, , drop = FALSE]
-
+
polygonGrob(coords$x, coords$y, default.units = "native", id = grob_id,
gp = gpar(
- col = data$colour, fill = alpha(data$fill, data$alpha),
+ col = data$colour, fill = alpha(data$fill, data$alpha),
lwd = data$size * .pt))
}
-
+
required_aes <- c("map_id")
-
+
})
diff --git a/R/geom-path-.r b/R/geom-path-.r
index 2418796..72ef80d 100644
--- a/R/geom-path-.r
+++ b/R/geom-path-.r
@@ -1,6 +1,6 @@
#' Connect observations in original order
-#'
-#' @section Aesthetics:
+#'
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "path")}
#'
#' @inheritParams geom_point
@@ -8,8 +8,8 @@
#' @param linejoin Line join style (round, mitre, bevel)
#' @param linemitre Line mitre limit (number greater than 1)
#' @param arrow Arrow specification, as created by ?grid::arrow
-#' @seealso \code{\link{geom_line}}: Functional (ordered) lines;
-#' \code{\link{geom_polygon}}: Filled paths (polygons);
+#' @seealso \code{\link{geom_line}}: Functional (ordered) lines;
+#' \code{\link{geom_polygon}}: Filled paths (polygons);
#' \code{\link{geom_segment}}: Line segments
#' @export
#' @examples
@@ -19,43 +19,43 @@
#' myear <- ddply(movies, .(year), colwise(mean, .(length, rating)))
#' p <- ggplot(myear, aes(length, rating))
#' p + geom_path()
-#'
+#'
#' # Add aesthetic mappings
#' p + geom_path(aes(size = year))
#' p + geom_path(aes(colour = year))
-#'
+#'
#' # Change scale
#' p + geom_path(aes(size = year)) + scale_size(range = c(1, 3))
-#'
+#'
#' # Set aesthetics to fixed value
#' p + geom_path(colour = "green")
-#'
+#'
#' # Control line join parameters
#' df <- data.frame(x = 1:3, y = c(4, 1, 9))
#' base <- ggplot(df, aes(x, y))
#' base + geom_path(size = 10)
#' base + geom_path(size = 10, lineend = "round")
#' base + geom_path(size = 10, linejoin = "mitre", lineend = "butt")
-#'
+#'
#' # Use qplot instead
#' qplot(length, rating, data=myear, geom="path")
-#'
+#'
#' # Using economic data:
#' # How is unemployment and personal savings rate related?
#' qplot(unemploy/pop, psavert, data=economics)
#' qplot(unemploy/pop, psavert, data=economics, geom="path")
#' qplot(unemploy/pop, psavert, data=economics, geom="path", size=as.numeric(date))
-#'
+#'
#' # How is rate of unemployment and length of unemployment?
#' qplot(unemploy/pop, uempmed, data=economics)
#' qplot(unemploy/pop, uempmed, data=economics, geom="path")
#' qplot(unemploy/pop, uempmed, data=economics, geom="path") +
-#' geom_point(data=head(economics, 1), colour="red") +
+#' geom_point(data=head(economics, 1), colour="red") +
#' geom_point(data=tail(economics, 1), colour="blue")
#' qplot(unemploy/pop, uempmed, data=economics, geom="path") +
-#' geom_text(data=head(economics, 1), label="1967", colour="blue") +
+#' geom_text(data=head(economics, 1), label="1967", colour="blue") +
#' geom_text(data=tail(economics, 1), label="2007", colour="blue")
-#'
+#'
#' # geom_path removes missing values on the ends of a line.
#' # use na.rm = T to suppress the warning message
#' df <- data.frame(
@@ -68,34 +68,34 @@
#' qplot(x, y2, data = df, geom = c("point","line"))
#' qplot(x, y3, data = df, geom = c("point","line"))
#' qplot(x, y4, data = df, geom = c("point","line"))
-#'
+#'
#' # Setting line type vs colour/size
#' # Line type needs to be applied to a line as a whole, so it can
#' # not be used with colour or size that vary across a line
-#'
+#'
#' x <- seq(0.01, .99, length=100)
#' df <- data.frame(x = rep(x, 2), y = c(qlogis(x), 2 * qlogis(x)), group = rep(c("a","b"), each=100))
#' p <- ggplot(df, aes(x=x, y=y, group=group))
-#'
+#'
#' # Should work
#' p + geom_line(linetype = 2)
#' p + geom_line(aes(colour = group), linetype = 2)
#' p + geom_line(aes(colour = x))
-#'
+#'
#' # Should fail
#' should_stop(p + geom_line(aes(colour = x), linetype=2))
#'
#' # Use the arrow parameter to add an arrow to the line
#' # See ?grid::arrow for more details
#' library(grid)
-#' c <- ggplot(economics, aes(x = date, y = pop))
+#' c <- ggplot(economics, aes(x = date, y = pop))
#' # Arrow defaults to "last"
#' c + geom_path(arrow = arrow())
#' c + geom_path(arrow = arrow(angle = 15, ends = "both", length = unit(0.6, "inches")))
#' }
-geom_path <- function (mapping = NULL, data = NULL, stat = "identity", position = "identity",
-lineend = "butt", linejoin = "round", linemitre = 1, na.rm = FALSE, arrow = NULL, ...) {
- GeomPath$new(mapping = mapping, data = data, stat = stat, position = position,
+geom_path <- function (mapping = NULL, data = NULL, stat = "identity", position = "identity",
+lineend = "butt", linejoin = "round", linemitre = 1, na.rm = FALSE, arrow = NULL, ...) {
+ GeomPath$new(mapping = mapping, data = data, stat = stat, position = position,
lineend = lineend, linejoin = linejoin, linemitre = linemitre, na.rm = na.rm, arrow = arrow, ...)
}
@@ -114,11 +114,11 @@ GeomPath <- proto(Geom, {
first <- match(FALSE, x, nomatch = 1) - 1
last <- length(x) - match(FALSE, rev(x), nomatch = 1) + 1
c(
- rep(FALSE, first),
- rep(TRUE, last - first),
+ rep(FALSE, first),
+ rep(TRUE, last - first),
rep(FALSE, length(x) - last))
- }
- # Drop missing values at the start or end of a line - can't drop in the
+ }
+ # Drop missing values at the start or end of a line - can't drop in the
# middle since you expect those to be shown by a break in the line
missing <- !complete.cases(data[c("x", "y", "size", "colour",
"linetype")])
@@ -128,10 +128,10 @@ GeomPath <- proto(Geom, {
data <- arrange(data, group)
if (!all(kept) && !na.rm) {
- warning("Removed ", sum(!kept), " rows containing missing values",
+ warning("Removed ", sum(!kept), " rows containing missing values",
" (geom_path).", call. = FALSE)
}
-
+
munched <- coord_munch(coordinates, data, scales)
# Silently drop lines with less than two points, preserving order
@@ -149,38 +149,38 @@ GeomPath <- proto(Geom, {
solid_lines <- all(attr$solid)
constant <- all(attr$constant)
if (!solid_lines && !constant) {
- stop("geom_path: If you are using dotted or dashed lines",
+ stop("geom_path: If you are using dotted or dashed lines",
", colour, size and linetype must be constant over the line",
call.=FALSE)
}
-
+
# Work out grouping variables for grobs
n <- nrow(munched)
group_diff <- munched$group[-1] != munched$group[-n]
start <- c(TRUE, group_diff)
- end <- c(group_diff, TRUE)
-
+ end <- c(group_diff, TRUE)
+
if (!constant) {
- with(munched,
+ with(munched,
segmentsGrob(
x[!end], y[!end], x[!start], y[!start],
- default.units="native", arrow = arrow,
+ default.units="native", arrow = arrow,
gp = gpar(
col = alpha(colour, alpha)[!end], fill = alpha(colour, alpha)[!end],
- lwd = size[!end] * .pt, lty = linetype[!end],
+ lwd = size[!end] * .pt, lty = linetype[!end],
lineend = lineend, linejoin = linejoin, linemitre = linemitre
)
)
)
} else {
id <- match(munched$group, unique(munched$group))
- with(munched,
+ with(munched,
polylineGrob(
- x, y, id = id,
- default.units = "native", arrow = arrow,
+ x, y, id = id,
+ default.units = "native", arrow = arrow,
gp = gpar(
col = alpha(colour, alpha)[start], fill = alpha(colour, alpha)[start],
- lwd = size[start] * .pt, lty = linetype[start],
+ lwd = size[start] * .pt, lty = linetype[start],
lineend = lineend, linejoin = linejoin, linemitre = linemitre)
)
)
@@ -191,9 +191,9 @@ GeomPath <- proto(Geom, {
data$arrow <- NULL
data <- aesdefaults(data, .$default_aes(), list(...))
- with(data,
+ with(data,
ggname(.$my_name(), segmentsGrob(0.1, 0.5, 0.9, 0.5, default.units="npc",
- gp=gpar(col=alpha(colour, alpha), lwd=size * .pt,
+ gp=gpar(col=alpha(colour, alpha), lwd=size * .pt,
lty=linetype, lineend="butt")))
)
}
@@ -202,6 +202,6 @@ GeomPath <- proto(Geom, {
required_aes <- c("x", "y")
default_aes <- function(.) aes(colour="black", size=0.5, linetype=1, alpha = NA)
guide_geom <- function(.) "path"
-
+
})
diff --git a/R/geom-path-contour.r b/R/geom-path-contour.r
index 22b5932..4a555c8 100644
--- a/R/geom-path-contour.r
+++ b/R/geom-path-contour.r
@@ -1,6 +1,6 @@
#' Display contours of a 3d surface in 2d.
#'
-#' @section Aesthetics:
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "contour")}
#'
#' @inheritParams geom_point
@@ -9,8 +9,8 @@
#' @export
#' @examples
#' # See stat_contour for examples
-geom_contour <- function (mapping = NULL, data = NULL, stat = "contour", position = "identity",
-lineend = "butt", linejoin = "round", linemitre = 1, na.rm = FALSE, ...) {
+geom_contour <- function (mapping = NULL, data = NULL, stat = "contour", position = "identity",
+lineend = "butt", linejoin = "round", linemitre = 1, na.rm = FALSE, ...) {
GeomContour$new(mapping = mapping, data = data, stat = stat, position = position,
lineend = lineend, linejoin = linejoin, linemitre = linemitre, na.rm = na.rm, ...)
}
@@ -20,6 +20,6 @@ GeomContour <- proto(GeomPath, {
default_aes <- function(.) aes(weight=1, colour="#3366FF", size = 0.5, linetype = 1, alpha = NA)
- default_stat <- function(.) StatContour
+ default_stat <- function(.) StatContour
})
diff --git a/R/geom-path-density2d.r b/R/geom-path-density2d.r
index 35c4e69..7fff76e 100644
--- a/R/geom-path-density2d.r
+++ b/R/geom-path-density2d.r
@@ -2,25 +2,25 @@
#'
#' Perform a 2D kernel density estimatation using kde2d and display the
#' results with contours.
-#'
+#'
#' This can be useful for dealing with overplotting.
#'
-#' @section Aesthetics:
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "density2d")}
#'
-#' @seealso \code{\link{geom_contour}} for contour drawing geom,
+#' @seealso \code{\link{geom_contour}} for contour drawing geom,
#' \code{\link{stat_sum}} for another way of dealing with overplotting
#' @inheritParams geom_point
#' @inheritParams geom_path
#' @export
#' @examples
#' # See stat_density2d for examples
-geom_density2d <- function (mapping = NULL, data = NULL, stat = "density2d", position = "identity",
-lineend = "butt", linejoin = "round", linemitre = 1, na.rm = FALSE, ...) {
- GeomDensity2d$new(mapping = mapping, data = data, stat = stat, position = position,
+geom_density2d <- function (mapping = NULL, data = NULL, stat = "density2d", position = "identity",
+lineend = "butt", linejoin = "round", linemitre = 1, na.rm = FALSE, ...) {
+ GeomDensity2d$new(mapping = mapping, data = data, stat = stat, position = position,
lineend = lineend, linejoin = linejoin, linemitre = linemitre, na.rm = na.rm, ...)
}
-
+
GeomDensity2d <- proto(GeomPath, {
objname <- "density2d"
diff --git a/R/geom-path-line.r b/R/geom-path-line.r
index a60de2d..80149ec 100644
--- a/R/geom-path-line.r
+++ b/R/geom-path-line.r
@@ -1,46 +1,46 @@
#' Connect observations, ordered by x value.
#'
-#' @section Aesthetics:
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "line")}
#'
-#' @seealso \code{\link{geom_path}}: connect observations in data order,
+#' @seealso \code{\link{geom_path}}: connect observations in data order,
#' \code{\link{geom_segment}}: draw line segments,
#' \code{\link{geom_ribbon}}: fill between line and x-axis
#' @inheritParams geom_point
#' @export
#' @examples
#' # Summarise number of movie ratings by year of movie
-#' mry <- do.call(rbind, by(movies, round(movies$rating), function(df) {
+#' mry <- do.call(rbind, by(movies, round(movies$rating), function(df) {
#' nums <- tapply(df$length, df$year, length)
#' data.frame(rating=round(df$rating[1]), year = as.numeric(names(nums)), number=as.vector(nums))
#' }))
-#'
+#'
#' p <- ggplot(mry, aes(x=year, y=number, group=rating))
#' p + geom_line()
-#'
+#'
#' # Add aesthetic mappings
#' p + geom_line(aes(size = rating))
#' p + geom_line(aes(colour = rating))
-#'
+#'
#' # Change scale
#' p + geom_line(aes(colour = rating)) + scale_colour_gradient(low="red")
#' p + geom_line(aes(size = rating)) + scale_size(range = c(0.1, 3))
-#'
+#'
#' # Set aesthetics to fixed value
#' p + geom_line(colour = "red", size = 1)
-#'
+#'
#' # Use qplot instead
#' qplot(year, number, data=mry, group=rating, geom="line")
-#'
+#'
#' # Using a time series
#' qplot(date, pop, data=economics, geom="line")
#' qplot(date, pop, data=economics, geom="line", log="y")
#' qplot(date, pop, data=subset(economics, date > as.Date("2006-1-1")), geom="line")
#' qplot(date, pop, data=economics, size=unemploy/pop, geom="line")
-#'
+#'
#' # Use the arrow parameter to add an arrow to the line
#' # See ?grid::arrow for more details
-#' c <- ggplot(economics, aes(x = date, y = pop))
+#' c <- ggplot(economics, aes(x = date, y = pop))
#' # Arrow defaults to "last"
#' library(grid)
#' c + geom_line(arrow = arrow())
@@ -48,30 +48,30 @@
#'
#' # See scale_date for examples of plotting multiple times series on
#' # a single graph
-#'
+#'
#' # A simple pcp example
-#'
+#'
#' y2005 <- runif(300, 20, 120)
#' y2010 <- y2005 * runif(300, -1.05, 1.5)
#' group <- rep(LETTERS[1:3], each = 100)
-#'
+#'
#' df <- data.frame(id = seq_along(group), group, y2005, y2010)
#' library(reshape2) # for melt
#' dfm <- melt(df, id.var = c("id", "group"))
-#' ggplot(dfm, aes(variable, value, group = id, colour = group)) +
+#' ggplot(dfm, aes(variable, value, group = id, colour = group)) +
#' geom_path(alpha = 0.5)
-geom_line <- function (mapping = NULL, data = NULL, stat = "identity", position = "identity", ...) {
+geom_line <- function (mapping = NULL, data = NULL, stat = "identity", position = "identity", ...) {
GeomLine$new(mapping = mapping, data = data, stat = stat, position = position, ...)
}
GeomLine <- proto(GeomPath, {
objname <- "line"
-
+
draw <- function(., data, scales, coordinates, arrow = NULL, ...) {
data <- data[order(data$group, data$x), ]
GeomPath$draw(data, scales, coordinates, arrow, ...)
}
-
+
default_stat <- function(.) StatIdentity
-
+
})
diff --git a/R/geom-path-step.r b/R/geom-path-step.r
index a0f5be6..9705967 100644
--- a/R/geom-path-step.r
+++ b/R/geom-path-step.r
@@ -1,6 +1,6 @@
#' Connect observations by stairs.
#'
-#' @section Aesthetics:
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "step")}
#'
#' @inheritParams geom_point
@@ -11,23 +11,23 @@
#' # Simple quantiles/ECDF from examples(plot)
#' x <- sort(rnorm(47))
#' qplot(seq_along(x), x, geom="step")
-#'
+#'
#' # Steps go horizontally, then vertically (default)
#' qplot(seq_along(x), x, geom="step", direction = "hv")
#' plot(x, type = "s")
#' # Steps go vertically, then horizontally
#' qplot(seq_along(x), x, geom="step", direction = "vh")
#' plot(x, type = "S")
-#'
+#'
#' # Also works with other aesthetics
#' df <- data.frame(
#' x = sort(rnorm(50)),
#' trt = sample(c("a", "b"), 50, rep = TRUE)
#' )
#' qplot(seq_along(x), x, data = df, geom="step", colour = trt)
-geom_step <- function (mapping = NULL, data = NULL, stat = "identity", position = "identity",
+geom_step <- function (mapping = NULL, data = NULL, stat = "identity", position = "identity",
direction = "hv", ...) {
- GeomStep$new(mapping = mapping, data = data, stat = stat, position = position,
+ GeomStep$new(mapping = mapping, data = data, stat = stat, position = position,
direction = direction, ...)
}
@@ -37,7 +37,7 @@ GeomStep <- proto(Geom, {
details <- "Equivalent to plot(type='s')."
default_aes <- function(.) aes(colour="black", size=0.5, linetype=1, alpha = NA)
-
+
draw <- function(., data, scales, coordinates, direction = "hv", ...) {
data <- stairstep(data, direction)
GeomPath$draw(data, scales, coordinates, ...)
@@ -50,13 +50,13 @@ GeomStep <- proto(Geom, {
# Calculate stairsteps
# Used by \code{\link{geom_step}}
-#
+#
# @keyword internal
stairstep <- function(data, direction="hv") {
direction <- match.arg(direction, c("hv", "vh"))
data <- as.data.frame(data)[order(data$x), ]
n <- nrow(data)
-
+
if (direction == "vh") {
xs <- rep(1:n, each = 2)[-2*n]
ys <- c(1, rep(2:n, each=2))
@@ -64,10 +64,10 @@ stairstep <- function(data, direction="hv") {
ys <- rep(1:n, each = 2)[-2*n]
xs <- c(1, rep(2:n, each=2))
}
-
+
data.frame(
x = data$x[xs],
y = data$y[ys],
data[xs, setdiff(names(data), c("x", "y"))]
- )
+ )
}
diff --git a/R/geom-point-.r b/R/geom-point-.r
index b02cafb..27e3468 100644
--- a/R/geom-point-.r
+++ b/R/geom-point-.r
@@ -1,29 +1,29 @@
#' Points, as for a scatterplot
-#'
+#'
#' The point geom is used to create scatterplots.
#'
#' The scatterplot is useful for displaying the relationship between two
-#' continuous variables, although it can also be used with one continuous
+#' continuous variables, although it can also be used with one continuous
#' and one categorical variable, or two categorical variables. See
#' \code{\link{geom_jitter}} for possibilities.
#'
-#' The \emph{bubblechart} is a scatterplot with a third variable mapped to
+#' The \emph{bubblechart} is a scatterplot with a third variable mapped to
#' the size of points. There are no special names for scatterplots where
#' another variable is mapped to point shape or colour, however.
#'
#' The biggest potential problem with a scatterplot is overplotting: whenever
#' you have more than a few points, points may be plotted on top of one
-#' another. This can severely distort the visual appearance of the plot.
+#' another. This can severely distort the visual appearance of the plot.
#' There is no one solution to this problem, but there are some techniques
#' that can help. You can add additional information with
-#' \code{\link{stat_smooth}}, \code{\link{stat_quantile}} or
+#' \code{\link{stat_smooth}}, \code{\link{stat_quantile}} or
#' \code{\link{stat_density2d}}. If you have few unique x values,
#' \code{\link{geom_boxplot}} may also be useful. Alternatively, you can
#' summarise the number of points at each location and display that in some
#' way, using \code{\link{stat_sum}}. Another technique is to use transparent
#' points, \code{geom_point(alpha = 0.05)}.
#'
-#' @section Aesthetics:
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "point")}
#'
#' @seealso \code{\link{scale_size}} to see scale area of points, instead of
@@ -35,12 +35,12 @@
#' @param data A layer specific dataset - only needed if you want to override
#' the plot defaults.
#' @param stat The statistical transformation to use on the data for this
-#' layer.
-#' @param position The position adjustment to use for overlappling points
+#' layer.
+#' @param position The position adjustment to use for overlapping points
#' on this layer
#' @param na.rm If \code{FALSE} (the default), removes missing values with
#' a warning. If \code{TRUE} silently removes missing values.
-#' @param ... other arguments passed on to \code{\link{layer}}. This can
+#' @param ... other arguments passed on to \code{\link{layer}}. This can
#' include aesthetics whose values you want to set, not map. See
#' \code{\link{layer}} for more details.
#' @export
@@ -48,55 +48,55 @@
#' \donttest{
#' p <- ggplot(mtcars, aes(wt, mpg))
#' p + geom_point()
-#'
+#'
#' # Add aesthetic mappings
#' p + geom_point(aes(colour = qsec))
#' p + geom_point(aes(alpha = qsec))
#' p + geom_point(aes(colour = factor(cyl)))
#' p + geom_point(aes(shape = factor(cyl)))
#' p + geom_point(aes(size = qsec))
-#'
+#'
#' # Change scales
#' p + geom_point(aes(colour = cyl)) + scale_colour_gradient(low = "blue")
-#' p + geom_point(aes(size = qsec)) + scale_area()
+#' p + geom_point(aes(size = qsec)) + scale_size_area()
#' p + geom_point(aes(shape = factor(cyl))) + scale_shape(solid = FALSE)
-#'
+#'
#' # Set aesthetics to fixed value
#' p + geom_point(colour = "red", size = 3)
#' qplot(wt, mpg, data = mtcars, colour = I("red"), size = I(3))
-#'
+#'
#' # Varying alpha is useful for large datasets
#' d <- ggplot(diamonds, aes(carat, price))
#' d + geom_point(alpha = 1/10)
#' d + geom_point(alpha = 1/20)
#' d + geom_point(alpha = 1/100)
-#'
+#'
#' # You can create interesting shapes by layering multiple points of
#' # different sizes
#' p <- ggplot(mtcars, aes(mpg, wt))
-#' p + geom_point(colour="grey50", size = 4) + geom_point(aes(colour = cyl))
-#' p + aes(shape = factor(cyl)) +
+#' p + geom_point(colour="grey50", size = 4) + geom_point(aes(colour = cyl))
+#' p + aes(shape = factor(cyl)) +
#' geom_point(aes(colour = factor(cyl)), size = 4) +
#' geom_point(colour="grey90", size = 1.5)
-#' p + geom_point(colour="black", size = 4.5) +
-#' geom_point(colour="pink", size = 4) +
-#' geom_point(aes(shape = factor(cyl)))
-#'
+#' p + geom_point(colour="black", size = 4.5) +
+#' geom_point(colour="pink", size = 4) +
+#' geom_point(aes(shape = factor(cyl)))
+#'
#' # These extra layers don't usually appear in the legend, but we can
#' # force their inclusion
-#' p + geom_point(colour="black", size = 4.5, show_guide = TRUE) +
-#' geom_point(colour="pink", size = 4, show_guide = TRUE) +
-#' geom_point(aes(shape = factor(cyl)))
-#'
+#' p + geom_point(colour="black", size = 4.5, show_guide = TRUE) +
+#' geom_point(colour="pink", size = 4, show_guide = TRUE) +
+#' geom_point(aes(shape = factor(cyl)))
+#'
#' # Transparent points:
#' qplot(mpg, wt, data = mtcars, size = I(5), alpha = I(0.2))
-#'
+#'
#' # geom_point warns when missing values have been dropped from the data set
#' # and not plotted, you can turn this off by setting na.rm = TRUE
#' mtcars2 <- transform(mtcars, mpg = ifelse(runif(32) < 0.2, NA, mpg))
#' qplot(wt, mpg, data = mtcars2)
#' qplot(wt, mpg, data = mtcars2, na.rm = TRUE)
-#'
+#'
#' # Use qplot instead
#' qplot(wt, mpg, data = mtcars)
#' qplot(wt, mpg, data = mtcars, colour = factor(cyl))
@@ -104,33 +104,33 @@
#' }
geom_point <- function (mapping = NULL, data = NULL, stat = "identity", position = "identity",
na.rm = FALSE, ...) {
- GeomPoint$new(mapping = mapping, data = data, stat = stat, position = position,
+ GeomPoint$new(mapping = mapping, data = data, stat = stat, position = position,
na.rm = na.rm, ...)
}
-
+
GeomPoint <- proto(Geom, {
objname <- "point"
draw_groups <- function(., ...) .$draw(...)
- draw <- function(., data, scales, coordinates, na.rm = FALSE, ...) {
- data <- remove_missing(data, na.rm,
+ draw <- function(., data, scales, coordinates, na.rm = FALSE, ...) {
+ data <- remove_missing(data, na.rm,
c("x", "y", "size", "shape"), name = "geom_point")
if (empty(data)) return(zeroGrob())
-
- with(coord_transform(coordinates, data, scales),
- ggname(.$my_name(), pointsGrob(x, y, size=unit(size, "mm"), pch=shape,
+
+ with(coord_transform(coordinates, data, scales),
+ ggname(.$my_name(), pointsGrob(x, y, size=unit(size, "mm"), pch=shape,
gp=gpar(col=alpha(colour, alpha), fill = alpha(fill, alpha), fontsize = size * .pt)))
)
}
draw_legend <- function(., data, ...) {
data <- aesdefaults(data, .$default_aes(), list(...))
-
+
with(data,
- pointsGrob(0.5, 0.5, size=unit(size, "mm"), pch=shape,
+ pointsGrob(0.5, 0.5, size=unit(size, "mm"), pch=shape,
gp=gpar(
- col=alpha(colour, alpha),
- fill=alpha(fill, alpha),
+ col=alpha(colour, alpha),
+ fill=alpha(fill, alpha),
fontsize = size * .pt)
)
)
@@ -139,5 +139,5 @@ GeomPoint <- proto(Geom, {
default_stat <- function(.) StatIdentity
required_aes <- c("x", "y")
default_aes <- function(.) aes(shape=16, colour="black", size=2, fill = NA, alpha = NA)
-
+
})
diff --git a/R/geom-point-jitter.r b/R/geom-point-jitter.r
index fd08890..bd3f5b4 100644
--- a/R/geom-point-jitter.r
+++ b/R/geom-point-jitter.r
@@ -1,40 +1,40 @@
#' Points, jittered to reduce overplotting.
-#'
+#'
#' The jitter geom is a convenient default for geom_point with position =
-#' 'jitter'. See \code{\link{position_jitter}} to see how to adjust amount
+#' 'jitter'. See \code{\link{position_jitter}} to see how to adjust amount
#' of jittering.
-#'
-#' @section Aesthetics:
+#'
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "jitter")}
#'
#' @inheritParams geom_point
#' @seealso
-#' \code{\link{geom_point}} for regular, unjittered points,
+#' \code{\link{geom_point}} for regular, unjittered points,
#' \code{\link{geom_boxplot}} for another way of looking at the conditional
#' distribution of a variable,
#' \code{\link{position_jitter}} for examples of using jittering with other
#' geoms
#' @export
#' @examples
-#' p <- ggplot(mpg, aes(displ, hwy))
+#' p <- ggplot(mpg, aes(displ, hwy))
#' p + geom_point()
#' p + geom_point(position = "jitter")
-#'
+#'
#' # Add aesthetic mappings
#' p + geom_jitter(aes(colour = cyl))
-#'
+#'
#' # Vary parameters
#' p + geom_jitter(position = position_jitter(width = .5))
#' p + geom_jitter(position = position_jitter(height = .5))
-#'
+#'
#' # Use qplot instead
#' qplot(displ, hwy, data = mpg, geom = "jitter")
#' qplot(class, hwy, data = mpg, geom = "jitter")
#' qplot(class, hwy, data = mpg, geom = c("boxplot", "jitter"))
#' qplot(class, hwy, data = mpg, geom = c("jitter", "boxplot"))
-geom_jitter <- function (mapping = NULL, data = NULL, stat = "identity", position = "jitter",
-na.rm = FALSE, ...) {
- GeomJitter$new(mapping = mapping, data = data, stat = stat, position = position,
+geom_jitter <- function (mapping = NULL, data = NULL, stat = "identity", position = "jitter",
+na.rm = FALSE, ...) {
+ GeomJitter$new(mapping = mapping, data = data, stat = stat, position = position,
na.rm = na.rm, ...)
}
diff --git a/R/geom-pointrange.r b/R/geom-pointrange.r
index 2b9eec7..1d66bad 100644
--- a/R/geom-pointrange.r
+++ b/R/geom-pointrange.r
@@ -1,6 +1,6 @@
#' An interval represented by a vertical line, with a point in the middle.
-#'
-#' @section Aesthetics:
+#'
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "pointrange")}
#'
#' @inheritParams geom_point
@@ -13,7 +13,7 @@
#' @export
#' @examples
#' # See geom_linerange for examples
-geom_pointrange <- function (mapping = NULL, data = NULL, stat = "identity", position = "identity", ...) {
+geom_pointrange <- function (mapping = NULL, data = NULL, stat = "identity", position = "identity", ...) {
GeomPointrange$new(mapping = mapping, data = data, stat = stat, position = position, ...)
}
@@ -35,11 +35,11 @@ GeomPointrange <- proto(Geom, {
draw_legend <- function(., data, ...) {
data <- aesdefaults(data, .$default_aes(), list(...))
-
+
grobTree(
GeomPath$draw_legend(data, ...),
GeomPoint$draw_legend(transform(data, size = size * 4), ...)
)
}
-
+
})
diff --git a/R/geom-polygon.r b/R/geom-polygon.r
index 574fb90..5cc3366 100644
--- a/R/geom-polygon.r
+++ b/R/geom-polygon.r
@@ -1,9 +1,9 @@
#' Polygon, a filled path.
#'
-#' @section Aesthetics:
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "polygon")}
#'
-#' @seealso
+#' @seealso
#' \code{\link{geom_path}} for an unfilled polygon,
#' \code{\link{geom_ribbon}} for a polygon anchored on the x-axis
#' @export
@@ -13,40 +13,40 @@
#' # one contains the coordinates of each polygon (positions), and the
#' # other the values associated with each polygon (values). An id
#' # variable links the two together
-#'
+#'
#' ids <- factor(c("1.1", "2.1", "1.2", "2.2", "1.3", "2.3"))
-#'
+#'
#' values <- data.frame(
-#' id = ids,
+#' id = ids,
#' value = c(3, 3.1, 3.1, 3.2, 3.15, 3.5)
#' )
-#'
+#'
#' positions <- data.frame(
#' id = rep(ids, each = 4),
-#' x = c(2, 1, 1.1, 2.2, 1, 0, 0.3, 1.1, 2.2, 1.1, 1.2, 2.5, 1.1, 0.3,
+#' x = c(2, 1, 1.1, 2.2, 1, 0, 0.3, 1.1, 2.2, 1.1, 1.2, 2.5, 1.1, 0.3,
#' 0.5, 1.2, 2.5, 1.2, 1.3, 2.7, 1.2, 0.5, 0.6, 1.3),
-#' y = c(-0.5, 0, 1, 0.5, 0, 0.5, 1.5, 1, 0.5, 1, 2.1, 1.7, 1, 1.5,
+#' y = c(-0.5, 0, 1, 0.5, 0, 0.5, 1.5, 1, 0.5, 1, 2.1, 1.7, 1, 1.5,
#' 2.2, 2.1, 1.7, 2.1, 3.2, 2.8, 2.1, 2.2, 3.3, 3.2)
#' )
-#'
+#'
#' # Currently we need to manually merge the two together
#' datapoly <- merge(values, positions, by=c("id"))
-#'
+#'
#' (p <- ggplot(datapoly, aes(x=x, y=y)) + geom_polygon(aes(fill=value, group=id)))
-#'
-#' # Which seems like a lot of work, but then it's easy to add on
+#'
+#' # Which seems like a lot of work, but then it's easy to add on
#' # other features in this coordinate system, e.g.:
-#'
+#'
#' stream <- data.frame(
-#' x = cumsum(runif(50, max = 0.1)),
+#' x = cumsum(runif(50, max = 0.1)),
#' y = cumsum(runif(50,max = 0.1))
#' )
-#'
+#'
#' p + geom_line(data = stream, colour="grey30", size = 5)
-#'
+#'
#' # And if the positions are in longitude and latitude, you can use
#' # coord_map to produce different map projections.
-geom_polygon <- function (mapping = NULL, data = NULL, stat = "identity", position = "identity", ...) {
+geom_polygon <- function (mapping = NULL, data = NULL, stat = "identity", position = "identity", ...) {
GeomPolygon$new(mapping = mapping, data = data, stat = stat, position = position, ...)
}
@@ -63,7 +63,7 @@ GeomPolygon <- proto(Geom, {
# but is.numeric() will report FALSE because it actually checks something else)
if (mode(data$group) != "numeric")
data$group <- factor(data$group)
-
+
munched <- coord_munch(coordinates, data, scales)
# Sort by group to make sure that colors, fill, etc. come in same order
munched <- munched[order(munched$group), ]
@@ -94,7 +94,7 @@ GeomPolygon <- proto(Geom, {
draw_legend <- function(., data, ...) {
data <- aesdefaults(data, .$default_aes(), list(...))
-
+
with(data, grobTree(
rectGrob(gp = gpar(col = colour, fill = alpha(fill, alpha), lty = linetype)),
linesGrob(gp = gpar(col = colour, lwd = size * .pt, lineend="butt", lty = linetype))
diff --git a/R/geom-quantile.r b/R/geom-quantile.r
index d12c4de..70d94b4 100644
--- a/R/geom-quantile.r
+++ b/R/geom-quantile.r
@@ -1,8 +1,8 @@
#' Add quantile lines from a quantile regression.
#'
#' This can be used as a continuous analogue of a geom_boxplot.
-#'
-#' @section Aesthetics:
+#'
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "quantile")}
#'
#' @export
@@ -11,13 +11,13 @@
#' @seealso See \code{\link{stat_quantile}} for examples.
#' @examples
#' # See stat_quantile for examples
-geom_quantile <- function (mapping = NULL, data = NULL, stat = "quantile", position = "identity",
+geom_quantile <- function (mapping = NULL, data = NULL, stat = "quantile", position = "identity",
lineend = "butt", linejoin = "round", linemitre = 1, na.rm = FALSE, ...) {
GeomQuantile$new(mapping = mapping, data = data, stat = stat, position = position,
lineend = lineend, linejoin = linejoin, linemitre = linemitre, na.rm = na.rm, ...)
}
-GeomQuantile <- proto(GeomPath, {
+GeomQuantile <- proto(GeomPath, {
objname <- "quantile"
default_stat <- function(.) StatQuantile
diff --git a/R/geom-raster.r b/R/geom-raster.r
index dc47435..63c6bd1 100644
--- a/R/geom-raster.r
+++ b/R/geom-raster.r
@@ -12,14 +12,14 @@ NULL
#' If you want to manually set the padding (e.g. want zero-padding),
#' you can change the behavior by setting \code{hpad} and \code{vpad}.
#'
-#' @section Aesthetics:
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "raster")}
#'
#' @inheritParams geom_point
#' @param hjust,vjust horizontal and vertical justification of the grob. Each
-#' justification value should be a number between 0 and 1. Defaults to 0.5
+#' justification value should be a number between 0 and 1. Defaults to 0.5
#' for both, centering each pixel over its data location.
-#' @param interpolate If \code{TRUE} interpolate linearly, if \code{FALSE}
+#' @param interpolate If \code{TRUE} interpolate linearly, if \code{FALSE}
#' (the default) don't interpolate.
#' @export
#' @examples
@@ -33,7 +33,7 @@ NULL
#' df
#' }
#' qplot(x, y, data = pp(20), fill = z, geom = "raster")
-#' # Interpolation worsens the apperance of this plot, but can help when
+#' # Interpolation worsens the apperance of this plot, but can help when
#' # rendering images.
#' qplot(x, y, data = pp(20), fill = z, geom = "raster", interpolate = TRUE)
#'
@@ -52,58 +52,58 @@ NULL
#' # zero padding
#' ggplot(df, aes(x, y, fill = z)) + geom_raster(hjust = 0, vjust = 0)
#' }
-geom_raster <- function (mapping = NULL, data = NULL, stat = "identity", position = "identity", hjust = 0.5, vjust = 0.5, interpolate = FALSE, ...) {
+geom_raster <- function (mapping = NULL, data = NULL, stat = "identity", position = "identity", hjust = 0.5, vjust = 0.5, interpolate = FALSE, ...) {
stopifnot(is.numeric(hjust), length(hjust) == 1)
stopifnot(is.numeric(vjust), length(vjust) == 1)
-
+
GeomRaster$new(mapping = mapping, data = data, stat = stat, position = position, hjust = hjust, vjust = vjust, interpolate = interpolate, ...)
}
GeomRaster <- proto(Geom, {
objname <- "raster"
-
+
reparameterise <- function(., df, params) {
hjust <- params$hjust %||% 0.5
vjust <- params$vjust %||% 0.5
-
+
w <- resolution(df$x, FALSE)
h <- resolution(df$y, FALSE)
-
+
df$xmin <- df$x - w * (1 - hjust)
df$xmax <- df$x + w * hjust
df$ymin <- df$y - h * (1 - vjust)
df$ymax <- df$y + h * vjust
df
}
-
+
# This is a dummy function to make sure that vjust and hjust are recongised
# as parameters and are accessible to reparameterise.
draw <- function(vjust = 0.5, hjust = 0.5) {}
-
+
draw_groups <- function(., data, scales, coordinates, interpolate = FALSE, ...) {
if (!inherits(coordinates, "cartesian")) {
stop("geom_raster only works with Cartesian coordinates", call. = FALSE)
}
- data <- remove_missing(data, TRUE, c("x", "y", "fill"),
+ data <- remove_missing(data, TRUE, c("x", "y", "fill"),
name = "geom_raster")
data <- coord_transform(coordinates, data, scales)
# Convert vector of data to raster
x_pos <- as.integer((data$x - min(data$x)) / resolution(data$x, FALSE))
y_pos <- as.integer((data$y - min(data$y)) / resolution(data$y, FALSE))
-
+
nrow <- max(y_pos) + 1
ncol <- max(x_pos) + 1
raster <- matrix(NA_character_, nrow = nrow, ncol = ncol)
raster[cbind(nrow - y_pos, x_pos + 1)] <- alpha(data$fill, data$alpha)
-
+
# Figure out dimensions of raster on plot
x_rng <- c(min(data$xmin, na.rm = TRUE), max(data$xmax, na.rm = TRUE))
y_rng <- c(min(data$ymin, na.rm = TRUE), max(data$ymax, na.rm = TRUE))
-
- rasterGrob(raster, x = mean(x_rng), y = mean(y_rng),
- width = diff(x_rng), height = diff(y_rng),
+
+ rasterGrob(raster, x = mean(x_rng), y = mean(y_rng),
+ width = diff(x_rng), height = diff(y_rng),
default.units = "native", interpolate = interpolate)
}
diff --git a/R/geom-rect.r b/R/geom-rect.r
index 04eb9d9..6f58d68 100644
--- a/R/geom-rect.r
+++ b/R/geom-rect.r
@@ -1,6 +1,6 @@
#' 2d rectangles.
#'
-#' @section Aesthetics:
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "rect")}
#'
#' @inheritParams geom_point
@@ -12,17 +12,17 @@
#' )
#' ggplot(df, aes(xmin = x, xmax = x + 1, ymin = y, ymax = y + 2)) +
#' geom_rect()
-geom_rect <- function (mapping = NULL, data = NULL, stat = "identity", position = "identity", ...) {
+geom_rect <- function (mapping = NULL, data = NULL, stat = "identity", position = "identity", ...) {
GeomRect$new(mapping = mapping, data = data, stat = stat, position = position, ...)
}
GeomRect <- proto(Geom, {
objname <- "rect"
-
+
default_stat <- function(.) StatIdentity
default_pos <- function(.) PositionIdentity
default_aes <- function(.) aes(colour=NA, fill="grey20", size=0.5, linetype=1, alpha = NA)
-
+
required_aes <- c("xmin", "xmax", "ymin", "ymax")
draw <- draw_groups <- function(., data, scales, coordinates, ...) {
@@ -30,30 +30,30 @@ GeomRect <- proto(Geom, {
aesthetics <- setdiff(
names(data), c("x", "y", "xmin","xmax", "ymin", "ymax")
)
-
+
polys <- alply(data, 1, function(row) {
poly <- with(row, rect_to_poly(xmin, xmax, ymin, ymax))
- aes <- as.data.frame(row[aesthetics],
+ aes <- as.data.frame(row[aesthetics],
stringsAsFactors = FALSE)[rep(1,5), ]
-
+
GeomPolygon$draw(cbind(poly, aes), scales, coordinates)
})
-
+
ggname("bar",do.call("grobTree", polys))
} else {
- with(coord_transform(coordinates, data, scales),
+ with(coord_transform(coordinates, data, scales),
ggname(.$my_name(), rectGrob(
- xmin, ymax,
- width = xmax - xmin, height = ymax - ymin,
- default.units = "native", just = c("left", "top"),
+ xmin, ymax,
+ width = xmax - xmin, height = ymax - ymin,
+ default.units = "native", just = c("left", "top"),
gp=gpar(
- col=colour, fill=alpha(fill, alpha),
+ col=colour, fill=alpha(fill, alpha),
lwd=size * .pt, lty=linetype, lineend="butt"
)
))
)
}
-
+
}
guide_geom <- function(.) "polygon"
@@ -61,7 +61,7 @@ GeomRect <- proto(Geom, {
# Convert rectangle to polygon
# Useful for non-Cartesian coordinate systems where it's easy to work purely in terms of locations, rather than locations and dimensions.
-#
+#
# @keyword internal
rect_to_poly <- function(xmin, xmax, ymin, ymax) {
data.frame(
diff --git a/R/geom-ribbon-.r b/R/geom-ribbon-.r
index a34972b..13b69cb 100644
--- a/R/geom-ribbon-.r
+++ b/R/geom-ribbon-.r
@@ -1,6 +1,6 @@
#' Ribbons, y range with continuous x values.
#'
-#' @section Aesthetics:
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "ribbon")}
#'
#' @seealso
@@ -15,35 +15,35 @@
#' huron <- data.frame(year = 1875:1972, level = as.vector(LakeHuron))
#' library(plyr) # to access round_any
#' huron$decade <- round_any(huron$year, 10, floor)
-#'
+#'
#' h <- ggplot(huron, aes(x=year))
-#'
+#'
#' h + geom_ribbon(aes(ymin=0, ymax=level))
#' h + geom_area(aes(y = level))
-#'
+#'
#' # Add aesthetic mappings
#' h + geom_ribbon(aes(ymin=level-1, ymax=level+1))
#' h + geom_ribbon(aes(ymin=level-1, ymax=level+1)) + geom_line(aes(y=level))
-#'
+#'
#' # Take out some values in the middle for an example of NA handling
#' huron[huron$year > 1900 & huron$year < 1910, "level"] <- NA
#' h <- ggplot(huron, aes(x=year))
#' h + geom_ribbon(aes(ymin=level-1, ymax=level+1)) + geom_line(aes(y=level))
-#'
+#'
#' # Another data set, with multiple y's for each x
-#' m <- ggplot(movies, aes(y=votes, x=year))
+#' m <- ggplot(movies, aes(y=votes, x=year))
#' (m <- m + geom_point())
-#'
+#'
#' # The default summary isn't that useful
#' m + stat_summary(geom="ribbon", fun.ymin="min", fun.ymax="max")
#' m + stat_summary(geom="ribbon", fun.data="median_hilow")
-#'
+#'
#' # Use qplot instead
#' qplot(year, level, data=huron, geom=c("area", "line"))
#' }
-geom_ribbon <- function (mapping = NULL, data = NULL, stat = "identity", position = "identity",
-na.rm = FALSE, ...) {
- GeomRibbon$new(mapping = mapping, data = data, stat = stat, position = position,
+geom_ribbon <- function (mapping = NULL, data = NULL, stat = "identity", position = "identity",
+na.rm = FALSE, ...) {
+ GeomRibbon$new(mapping = mapping, data = data, stat = stat, position = position,
na.rm = na.rm, ...)
}
@@ -54,8 +54,8 @@ GeomRibbon <- proto(Geom, {
default_aes <- function(.) aes(colour=NA, fill="grey20", size=0.5, linetype=1, alpha = NA)
required_aes <- c("x", "ymin", "ymax")
guide_geom <- function(.) "polygon"
-
-
+
+
draw <- function(., data, scales, coordinates, na.rm = FALSE, ...) {
if (na.rm) data <- data[complete.cases(data[required_aes]), ]
data <- data[order(data$group, data$x), ]
@@ -78,7 +78,7 @@ GeomRibbon <- proto(Geom, {
ids <- cumsum(missing_pos) + 1
ids[missing_pos] <- NA
- positions <- summarise(data,
+ positions <- summarise(data,
x = c(x, rev(x)), y = c(ymax, rev(ymin)), id = c(ids, rev(ids)))
munched <- coord_munch(coordinates,positions, scales)
@@ -86,9 +86,9 @@ GeomRibbon <- proto(Geom, {
munched$x, munched$y, id = munched$id,
default.units = "native",
gp = gpar(
- fill = alpha(aes$fill, aes$alpha),
- col = aes$colour,
- lwd = aes$size * .pt,
+ fill = alpha(aes$fill, aes$alpha),
+ col = aes$colour,
+ lwd = aes$size * .pt,
lty = aes$linetype)
))
}
@@ -96,7 +96,7 @@ GeomRibbon <- proto(Geom, {
})
#' Area plot.
-#'
+#'
#' An area plot is the continuous analog of a stacked bar chart (see
#' \code{\link{geom_bar}}), and can be used to show how composition of the
#' whole varies over the range of x. Choosing the order in which different
@@ -104,16 +104,16 @@ GeomRibbon <- proto(Geom, {
#' see the individual pattern as you move up the stack.
#'
#' An area plot is a special case of \code{\link{geom_ribbon}}, where the
-#' minimum of the range is fixed to 0, and the position adjustment defaults
+#' minimum of the range is fixed to 0, and the position adjustment defaults
#' to position_stacked.
#'
#' @inheritParams geom_point
#' @export
#' @examples
#' # see geom_ribbon
-geom_area <- function (mapping = NULL, data = NULL, stat = "identity", position = "stack",
-na.rm = FALSE, ...) {
- GeomArea$new(mapping = mapping, data = data, stat = stat, position = position,
+geom_area <- function (mapping = NULL, data = NULL, stat = "identity", position = "stack",
+na.rm = FALSE, ...) {
+ GeomArea$new(mapping = mapping, data = data, stat = stat, position = position,
na.rm = na.rm, ...)
}
diff --git a/R/geom-ribbon-density.r b/R/geom-ribbon-density.r
index 218317d..9247913 100644
--- a/R/geom-ribbon-density.r
+++ b/R/geom-ribbon-density.r
@@ -2,7 +2,7 @@
#'
#' A smooth density estimate calculated by \code{\link{stat_density}}.
#'
-#' @section Aesthetics:
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "density")}
#'
#' @seealso \code{\link{geom_histogram}} for the histogram and
@@ -11,9 +11,9 @@
#' @export
#' @examples
#' # See stat_density for examples
-geom_density <- function (mapping = NULL, data = NULL, stat = "density", position = "identity",
+geom_density <- function (mapping = NULL, data = NULL, stat = "density", position = "identity",
na.rm = FALSE, ...) {
- GeomDensity$new(mapping = mapping, data = data, stat = stat, position = position,
+ GeomDensity$new(mapping = mapping, data = data, stat = stat, position = position,
na.rm = na.rm, ...)
}
@@ -22,6 +22,6 @@ GeomDensity <- proto(GeomArea, {
default_stat <- function(.) StatDensity
default_pos <- function(.) PositionIdentity
-
+
default_aes <- function(.) defaults(aes(fill=NA, weight=1, colour="black", alpha = NA), GeomArea$default_aes())
})
diff --git a/R/geom-rug.r b/R/geom-rug.r
index 0d9775e..c6c188f 100644
--- a/R/geom-rug.r
+++ b/R/geom-rug.r
@@ -1,6 +1,6 @@
#' Marginal rug plots.
#'
-#' @section Aesthetics:
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "rug")}
#'
#' @inheritParams geom_point
@@ -24,7 +24,7 @@ GeomRug <- proto(Geom, {
draw <- function(., data, scales, coordinates, sides, ...) {
rugs <- list()
- data <- coord_transform(coordinates, data, scales)
+ data <- coord_transform(coordinates, data, scales)
if (!is.null(data$x)) {
if(grepl("b", sides)) {
rugs$x_b <- segmentsGrob(
@@ -41,7 +41,7 @@ GeomRug <- proto(Geom, {
gp = gpar(col = alpha(data$colour, data$alpha), lty = data$linetype, lwd = data$size * .pt)
)
}
- }
+ }
if (!is.null(data$y)) {
if(grepl("l", sides)) {
@@ -59,11 +59,11 @@ GeomRug <- proto(Geom, {
gp = gpar(col = alpha(data$colour, data$alpha), lty = data$linetype, lwd = data$size * .pt)
)
}
- }
-
+ }
+
gTree(children = do.call("gList", rugs))
}
-
+
default_stat <- function(.) StatIdentity
default_aes <- function(.) aes(colour="black", size=0.5, linetype=1, alpha = NA)
guide_geom <- function(.) "path"
diff --git a/R/geom-segment.r b/R/geom-segment.r
index 45666bb..3afe1fd 100644
--- a/R/geom-segment.r
+++ b/R/geom-segment.r
@@ -1,6 +1,6 @@
#' Single line segments.
#'
-#' @section Aesthetics:
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "segment")}
#'
#' @inheritParams geom_point
@@ -12,10 +12,11 @@
#' @examples
#' library(grid) # needed for arrow function
#' p <- ggplot(seals, aes(x = long, y = lat))
-#' (p <- p + geom_segment(aes(xend = long + delta_long, yend = lat + delta_lat), arrow = arrow(length = unit(0.1,"cm"))))
-#'
+#' (p <- p + geom_segment(aes(xend = long + delta_long, yend = lat + delta_lat),
+#' arrow = arrow(length = unit(0.1,"cm"))))
+#'
#' if (require("maps")) {
-#'
+#'
#' xlim <- range(seals$long)
#' ylim <- range(seals$lat)
#' usamap <- data.frame(map("world", xlim = xlim, ylim = ylim, plot =
@@ -26,13 +27,13 @@
#'
#' p + geom_path(data = usamap) + scale_x_continuous(limits = xlim)
#' }
-#'
-#' # You can also use geom_segment to recreate plot(type = "h") :
+#'
+#' # You can also use geom_segment to recreate plot(type = "h") :
#' counts <- as.data.frame(table(x = rpois(100,5)))
#' counts$x <- as.numeric(as.character(counts$x))
#' with(counts, plot(x, Freq, type = "h", lwd = 10))
-#'
-#' qplot(x, Freq, data = counts, geom = "segment",
+#'
+#' qplot(x, Freq, data = counts, geom = "segment",
#' yend = 0, xend = x, size = I(10))
#'
#' # Adding line segments
@@ -40,7 +41,8 @@
#' b <- ggplot(mtcars, aes(wt, mpg)) + geom_point()
#' b + geom_segment(aes(x = 2, y = 15, xend = 2, yend = 25))
#' b + geom_segment(aes(x = 2, y = 15, xend = 3, yend = 15))
-#' b + geom_segment(aes(x = 5, y = 30, xend = 3.5, yend = 25), arrow = arrow(length = unit(0.5, "cm")))
+#' b + geom_segment(aes(x = 5, y = 30, xend = 3.5, yend = 25),
+#' arrow = arrow(length = unit(0.5, "cm")))
geom_segment <- function (mapping = NULL, data = NULL, stat = "identity",
position = "identity", arrow = NULL, lineend = "butt", na.rm = FALSE, ...) {
@@ -60,7 +62,7 @@ GeomSegment <- proto(Geom, {
if (empty(data)) return(zeroGrob())
if (is.linear(coordinates)) {
- return(with(coord_transform(coordinates, data, scales),
+ return(with(coord_transform(coordinates, data, scales),
segmentsGrob(x, y, xend, yend, default.units="native",
gp = gpar(col=alpha(colour, alpha), fill = alpha(colour, alpha),
lwd=size * .pt, lty=linetype, lineend = lineend),
@@ -72,14 +74,14 @@ GeomSegment <- proto(Geom, {
starts <- subset(data, select = c(-xend, -yend))
ends <- rename(subset(data, select = c(-x, -y)), c("xend" = "x", "yend" = "y"),
warn_missing = FALSE)
-
+
pieces <- rbind(starts, ends)
pieces <- pieces[order(pieces$group),]
-
+
GeomPath$draw_groups(pieces, scales, coordinates, arrow = arrow, ...)
}
-
+
default_stat <- function(.) StatIdentity
required_aes <- c("x", "y", "xend", "yend")
default_aes <- function(.) aes(colour="black", size=0.5, linetype=1, alpha = NA)
diff --git a/R/geom-smooth.r b/R/geom-smooth.r
index b7d5f8a..4e3db12 100644
--- a/R/geom-smooth.r
+++ b/R/geom-smooth.r
@@ -1,10 +1,10 @@
#' Add a smoothed conditional mean.
#'
-#' @section Aesthetics:
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "smooth")}
#'
#' @inheritParams geom_point
-#' @seealso The default stat for this geom is \code{\link{stat_smooth}} see
+#' @seealso The default stat for this geom is \code{\link{stat_smooth}} see
#' that documentation for more options to control the underlying statistical transformation.
#' @export
#' @examples
@@ -12,26 +12,26 @@
#' # if you need some more flexible, this example shows you how to
#' # plot the fits from any model of your choosing
#' qplot(wt, mpg, data=mtcars, colour=factor(cyl))
-#'
+#'
#' model <- lm(mpg ~ wt + factor(cyl), data=mtcars)
#' grid <- with(mtcars, expand.grid(
#' wt = seq(min(wt), max(wt), length = 20),
#' cyl = levels(factor(cyl))
#' ))
-#'
+#'
#' grid$mpg <- stats::predict(model, newdata=grid)
-#'
+#'
#' qplot(wt, mpg, data=mtcars, colour=factor(cyl)) + geom_line(data=grid)
-#'
+#'
#' # or with standard errors
-#'
+#'
#' err <- stats::predict(model, newdata=grid, se = TRUE)
#' grid$ucl <- err$fit + 1.96 * err$se.fit
#' grid$lcl <- err$fit - 1.96 * err$se.fit
-#'
-#' qplot(wt, mpg, data=mtcars, colour=factor(cyl)) +
-#' geom_smooth(aes(ymin = lcl, ymax = ucl), data=grid, stat="identity")
-geom_smooth <- function (mapping = NULL, data = NULL, stat = "smooth", position = "identity", ...) {
+#'
+#' qplot(wt, mpg, data=mtcars, colour=factor(cyl)) +
+#' geom_smooth(aes(ymin = lcl, ymax = ucl), data=grid, stat="identity")
+geom_smooth <- function (mapping = NULL, data = NULL, stat = "smooth", position = "identity", ...) {
GeomSmooth$new(mapping = mapping, data = data, stat = stat, position = position, ...)
}
@@ -41,9 +41,9 @@ GeomSmooth <- proto(Geom, {
draw <- function(., data, scales, coordinates, ...) {
ribbon <- transform(data, colour = NA)
path <- transform(data, alpha = NA)
-
+
has_ribbon <- function(x) !is.null(data$ymax) && !is.null(data$ymin)
-
+
gList(
if (has_ribbon(data)) GeomRibbon$draw(ribbon, scales, coordinates),
GeomLine$draw(path, scales, coordinates)
@@ -51,7 +51,7 @@ GeomSmooth <- proto(Geom, {
}
guide_geom <- function(.) "smooth"
-
+
default_stat <- function(.) StatSmooth
required_aes <- c("x", "y")
default_aes <- function(.) aes(colour="#3366FF", fill="grey60", size=0.5, linetype=1, weight=1, alpha=0.4)
@@ -61,12 +61,12 @@ GeomSmooth <- proto(Geom, {
data <- aesdefaults(data, .$default_aes(), list(...))
data$fill <- alpha(data$fill, data$alpha)
data$alpha <- 1
-
+
if (is.null(params$se) || params$se) {
gTree(children = gList(
rectGrob(gp = gpar(col = NA, fill = data$fill)),
GeomPath$draw_legend(data, ...)
- ))
+ ))
} else {
GeomPath$draw_legend(data, ...)
}
diff --git a/R/geom-text.r b/R/geom-text.r
index 0e2a12c..2e7c909 100644
--- a/R/geom-text.r
+++ b/R/geom-text.r
@@ -1,6 +1,6 @@
#' Textual annotations.
-#'
-#' @section Aesthetics:
+#'
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "text")}
#'
#' @inheritParams geom_point
@@ -10,30 +10,30 @@
#' @examples
#' \donttest{
#' p <- ggplot(mtcars, aes(x=wt, y=mpg, label=rownames(mtcars)))
-#'
+#'
#' p + geom_text()
#' # Change size of the label
#' p + geom_text(size=10)
#' p <- p + geom_point()
-#'
+#'
#' # Set aesthetics to fixed value
#' p + geom_text()
#' p + geom_point() + geom_text(hjust=0, vjust=0)
#' p + geom_point() + geom_text(angle = 45)
-#'
+#'
#' # Add aesthetic mappings
#' p + geom_text(aes(colour=factor(cyl)))
#' p + geom_text(aes(colour=factor(cyl))) + scale_colour_discrete(l=40)
-#'
+#'
#' p + geom_text(aes(size=wt))
#' p + geom_text(aes(size=wt)) + scale_size(range=c(3,6))
-#'
-#' # You can display expressions by setting parse = TRUE. The
+#'
+#' # You can display expressions by setting parse = TRUE. The
#' # details of the display are described in ?plotmath, but note that
#' # geom_text uses strings, not expressions.
#' p + geom_text(aes(label = paste(wt, "^(", cyl, ")", sep = "")),
#' parse = TRUE)
-#'
+#'
#' # Add an annotation not from a variable source
#' c <- ggplot(mtcars, aes(wt, mpg)) + geom_point()
#' c + geom_text(data = NULL, x = 5, y = 30, label = "plot mpg vs. wt")
@@ -52,9 +52,9 @@
#' p + geom_text(aes(fontface=am+1))
#' p + geom_text(aes(family=c("serif", "mono")[am+1]))
#' }
-geom_text <- function (mapping = NULL, data = NULL, stat = "identity", position = "identity",
-parse = FALSE, ...) {
- GeomText$new(mapping = mapping, data = data, stat = stat, position = position,
+geom_text <- function (mapping = NULL, data = NULL, stat = "identity", position = "identity",
+parse = FALSE, ...) {
+ GeomText$new(mapping = mapping, data = data, stat = stat, position = position,
parse = parse, ...)
}
@@ -63,17 +63,17 @@ GeomText <- proto(Geom, {
draw_groups <- function(., ...) .$draw(...)
draw <- function(., data, scales, coordinates, ..., parse = FALSE, na.rm = FALSE) {
- data <- remove_missing(data, na.rm,
+ data <- remove_missing(data, na.rm,
c("x", "y", "label"), name = "geom_text")
-
+
lab <- data$label
if (parse) {
lab <- parse(text = lab)
}
-
+
with(coord_transform(coordinates, data, scales),
- textGrob(lab, x, y, default.units="native",
- hjust=hjust, vjust=vjust, rot=angle,
+ textGrob(lab, x, y, default.units="native",
+ hjust=hjust, vjust=vjust, rot=angle,
gp = gpar(col = alpha(colour, alpha), fontsize = size * .pt,
fontfamily = family, fontface = fontface, lineheight = lineheight))
)
@@ -82,16 +82,16 @@ GeomText <- proto(Geom, {
draw_legend <- function(., data, ...) {
data <- aesdefaults(data, .$default_aes(), list(...))
with(data,
- textGrob("a", 0.5, 0.5, rot = angle,
+ textGrob("a", 0.5, 0.5, rot = angle,
gp=gpar(col=alpha(colour, alpha), fontsize = size * .pt))
)
}
-
+
default_stat <- function(.) StatIdentity
required_aes <- c("x", "y", "label")
default_aes <- function(.) aes(colour="black", size=5 , angle=0, hjust=0.5,
vjust=0.5, alpha = NA, family="", fontface=1, lineheight=1.2)
guide_geom <- function(x) "text"
-
+
})
diff --git a/R/geom-tile.r b/R/geom-tile.r
index 59c8240..551bfe0 100644
--- a/R/geom-tile.r
+++ b/R/geom-tile.r
@@ -2,7 +2,7 @@
#'
#' Similar to \code{\link{levelplot}} and \code{\link{image}}.
#'
-#' @section Aesthetics:
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "tile")}
#'
#' @inheritParams geom_point
@@ -18,37 +18,37 @@
#' df
#' }
#' p <- ggplot(pp(20), aes(x=x,y=y))
-#'
+#'
#' p + geom_tile() #pretty useless!
-#'
+#'
#' # Add aesthetic mappings
#' p + geom_tile(aes(fill=z))
-#'
+#'
#' # Change scale
#' p + geom_tile(aes(fill=z)) + scale_fill_gradient(low="green", high="red")
-#'
+#'
#' # Use qplot instead
#' qplot(x, y, data=pp(20), geom="tile", fill=z)
#' qplot(x, y, data=pp(100), geom="tile", fill=z)
-#'
+#'
#' # Missing values
#' p <- ggplot(pp(20)[sample(20*20, size=200),], aes(x=x,y=y,fill=z))
#' p + geom_tile()
-#'
+#'
#' # Input that works with image
#' image(t(volcano)[ncol(volcano):1,])
#' library(reshape2) # for melt
#' ggplot(melt(volcano), aes(x=Var1, y=Var2, fill=value)) + geom_tile()
-#'
+#'
#' # inspired by the image-density plots of Ken Knoblauch
#' cars <- ggplot(mtcars, aes(y=factor(cyl), x=mpg))
#' cars + geom_point()
#' cars + stat_bin(aes(fill=..count..), geom="tile", binwidth=3, position="identity")
#' cars + stat_bin(aes(fill=..density..), geom="tile", binwidth=3, position="identity")
-#'
+#'
#' cars + stat_density(aes(fill=..density..), geom="tile", position="identity")
#' cars + stat_density(aes(fill=..count..), geom="tile", position="identity")
-#'
+#'
#' # Another example with with unequal tile sizes
#' x.cell.boundary <- c(0, 4, 6, 8, 10, 14)
#' example <- data.frame(
@@ -57,17 +57,18 @@
#' z = rep(1:5, each=2),
#' w = rep(diff(x.cell.boundary), 2)
#' )
-#'
+#'
#' qplot(x, y, fill=z, data=example, geom="tile")
#' qplot(x, y, fill=z, data=example, geom="tile", width=w)
#' qplot(x, y, fill=factor(z), data=example, geom="tile", width=w)
-#'
-#' # You can manually set the colour of the tiles using
+#'
+#' # You can manually set the colour of the tiles using
#' # scale_manual
#' col <- c("darkblue", "blue", "green", "orange", "red")
-#' qplot(x, y, fill=col[z], data=example, geom="tile", width=w, group=1) + scale_fill_identity(labels=letters[1:5], breaks=col)
+#' qplot(x, y, fill=col[z], data=example, geom="tile", width=w, group=1) +
+#' scale_fill_identity(labels=letters[1:5], breaks=col)
#' }
-geom_tile <- function (mapping = NULL, data = NULL, stat = "identity", position = "identity", ...) {
+geom_tile <- function (mapping = NULL, data = NULL, stat = "identity", position = "identity", ...) {
GeomTile$new(mapping = mapping, data = data, stat = stat, position = position, ...)
}
@@ -78,9 +79,9 @@ GeomTile <- proto(Geom, {
df$width <- df$width %||% params$width %||% resolution(df$x, FALSE)
df$height <- df$height %||% params$height %||% resolution(df$y, FALSE)
- transform(df,
+ transform(df,
xmin = x - width / 2, xmax = x + width / 2, width = NULL,
- ymin = y - height / 2, ymax = y + height / 2, height = NULL
+ ymin = y - height / 2, ymax = y + height / 2, height = NULL
)
}
diff --git a/R/geom-violin.r b/R/geom-violin.r
index 7080cd6..105c2b5 100644
--- a/R/geom-violin.r
+++ b/R/geom-violin.r
@@ -1,6 +1,6 @@
#' Violin plot.
#'
-#' @section Aesthetics:
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "violin")}
#'
#' @inheritParams geom_point
@@ -13,40 +13,40 @@
#' @examples
#' \donttest{
#' p <- ggplot(mtcars, aes(factor(cyl), mpg))
-#'
+#'
#' p + geom_violin()
#' qplot(factor(cyl), mpg, data = mtcars, geom = "violin")
-#'
+#'
#' p + geom_violin() + geom_jitter(height = 0)
#' p + geom_violin() + coord_flip()
#' qplot(factor(cyl), mpg, data = mtcars, geom = "violin") +
#' coord_flip()
-#'
+#'
#' # Scale maximum width proportional to sample size:
#' p + geom_violin(scale = "count")
#'
#' # Scale maximum width to 1 for all violins:
#' p + geom_violin(scale = "width")
-#'
+#'
#' # Default is to trim violins to the range of the data. To disable:
#' p + geom_violin(trim = FALSE)
-#'
+#'
#' # Use a smaller bandwidth for closer density fit (default is 1).
#' p + geom_violin(adjust = .5)
-#'
+#'
#' # Add aesthetic mappings
-#' # Note that violins are automatically dodged when any aesthetic is
+#' # Note that violins are automatically dodged when any aesthetic is
#' # a factor
#' p + geom_violin(aes(fill = cyl))
#' p + geom_violin(aes(fill = factor(cyl)))
#' p + geom_violin(aes(fill = factor(vs)))
#' p + geom_violin(aes(fill = factor(am)))
-#'
+#'
#' # Set aesthetics to fixed value
#' p + geom_violin(fill = "grey80", colour = "#3366FF")
-#' qplot(factor(cyl), mpg, data = mtcars, geom = "violin",
+#' qplot(factor(cyl), mpg, data = mtcars, geom = "violin",
#' colour = I("#3366FF"))
-#'
+#'
#' # Scales vs. coordinate transforms -------
#' # Scale transformations occur before the density statistics are computed.
#' # Coordinate transformations occur afterwards. Observe the effect on the
@@ -58,16 +58,16 @@
#' m + geom_violin() + scale_y_log10()
#' m + geom_violin() + coord_trans(y = "log10")
#' m + geom_violin() + scale_y_log10() + coord_trans(y = "log10")
-#'
+#'
#' # Violin plots with continuous x:
#' # Use the group aesthetic to group observations in violins
#' qplot(year, budget, data = movies, geom = "violin")
-#' qplot(year, budget, data = movies, geom = "violin",
+#' qplot(year, budget, data = movies, geom = "violin",
#' group = round_any(year, 10, floor))
#' }
geom_violin <- function (mapping = NULL, data = NULL, stat = "ydensity", position = "dodge",
trim = TRUE, scale = "area", ...) {
- GeomViolin$new(mapping = mapping, data = data, stat = stat,
+ GeomViolin$new(mapping = mapping, data = data, stat = stat,
position = position, trim = trim, scale = scale, ...)
}
@@ -75,7 +75,7 @@ GeomViolin <- proto(Geom, {
objname <- "violin"
reparameterise <- function(., df, params) {
- df$width <- df$width %||%
+ df$width <- df$width %||%
params$width %||% (resolution(df$x, FALSE) * 0.9)
# ymin, ymax, xmin, and xmax define the bounding rectangle for each group
@@ -86,8 +86,8 @@ GeomViolin <- proto(Geom, {
xmax = x + width / 2)
}
-
- draw <- function(., data, ...) {
+
+ draw <- function(., data, ...) {
# Find the points for the line to go all the way around
data <- transform(data, xminv = x - violinwidth * (x-xmin),
diff --git a/R/geom-vline.r b/R/geom-vline.r
index 8084e2d..4281b89 100644
--- a/R/geom-vline.r
+++ b/R/geom-vline.r
@@ -1,5 +1,5 @@
#' Line, vertical.
-#'
+#'
#' This geom allows you to annotate the plot with vertical lines (see
#' \code{\link{geom_hline}} and \code{\link{geom_abline}} for other types of
#' lines.
@@ -10,7 +10,7 @@
#' intercept for each panel using a data.frame. See the examples for the
#' differences.
#'
-#' @section Aesthetics:
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "vline")}
#'
#' @param show_guide should a legend be drawn? (defaults to \code{FALSE})
@@ -27,21 +27,21 @@
#' p + geom_vline(xintercept = 1:5)
#' p + geom_vline(xintercept = 1:5, colour="green", linetype = "longdash")
#' p + geom_vline(aes(xintercept = wt))
-#'
+#'
#' # With coordinate transforms
#' p + geom_vline(aes(xintercept = wt)) + coord_equal()
#' p + geom_vline(aes(xintercept = wt)) + coord_flip()
#' p + geom_vline(aes(xintercept = wt)) + coord_polar()
-#'
+#'
#' p2 <- p + aes(colour = factor(cyl))
#' p2 + geom_vline(xintercept = 15)
#'
-#' # To display different lines in different facets, you need to
+#' # To display different lines in different facets, you need to
#' # create a data frame.
-#' p <- qplot(mpg, wt, data=mtcars, facets = vs ~ am)
-#' vline.data <- data.frame(z = c(15, 20, 25, 30), vs = c(0, 0, 1, 1), am = c(0, 1, 0, 1))
+#' p <- qplot(mpg, wt, data=mtcars, facets = vs ~ am)
+#' vline.data <- data.frame(z = c(15, 20, 25, 30), vs = c(0, 0, 1, 1), am = c(0, 1, 0, 1))
#' p + geom_vline(aes(xintercept = z), vline.data)
-geom_vline <- function (mapping = NULL, data = NULL, stat = "vline", position = "identity", show_guide = FALSE, ...) {
+geom_vline <- function (mapping = NULL, data = NULL, stat = "vline", position = "identity", show_guide = FALSE, ...) {
GeomVline$new(mapping = mapping, data = data, stat = stat, position = position, show_guide = show_guide, ...)
}
@@ -54,20 +54,20 @@ GeomVline <- proto(Geom, {
xintercept <- NULL
mapping <- aes_all(names(data))
}
- .super$new(., data = data, mapping = mapping, inherit.aes = FALSE,
+ .super$new(., data = data, mapping = mapping, inherit.aes = FALSE,
xintercept = xintercept, ...)
}
-
+
draw <- function(., data, scales, coordinates, ...) {
ranges <- coord_range(coordinates, scales)
data$y <- ranges$y[1]
data$yend <- ranges$y[2]
-
+
GeomSegment$draw(unique(data), scales, coordinates)
}
-
+
default_stat <- function(.) StatVline
default_aes <- function(.) aes(colour="black", size=0.5, linetype=1, alpha = NA)
guide_geom <- function(.) "vline"
@@ -75,7 +75,7 @@ GeomVline <- proto(Geom, {
draw_legend <- function(., data, ...) {
data <- aesdefaults(data, .$default_aes(), list(...))
- with(data,
+ with(data,
ggname(.$my_name(), segmentsGrob(0.5, 0, 0.5, 1, default.units="npc",
gp=gpar(col=alpha(colour, alpha), lwd=size * .pt, lty=linetype, lineend="butt")))
)
diff --git a/R/ggplot2.r b/R/ggplot2.r
index 02ff8f3..0aca6e5 100644
--- a/R/ggplot2.r
+++ b/R/ggplot2.r
@@ -1,28 +1,28 @@
#' ggplot2.
-#'
+#'
#' @name ggplot2
#' @docType package
#' @import plyr digest scales grid reshape2 proto gtable
NULL
#' Prices of 50,000 round cut diamonds
-#'
+#'
#' A dataset containing the prices and other attributes of almost 54,000
#' diamonds. The variables are as follows:
-#'
+#'
#' \itemize{
-#' \item price. price in US dollars (\$326--\$18,823)
-#' \item carat. weight of the diamond (0.2--5.01)
+#' \item price. price in US dollars (\$326--\$18,823)
+#' \item carat. weight of the diamond (0.2--5.01)
#' \item cut. quality of the cut (Fair, Good, Very Good, Premium, Ideal)
#' \item colour. diamond colour, from J (worst) to D (best)
-#' \item clarity. a measurement of how clear the diamond is (I1 (worst), SI1, SI2, VS1, VS2, VVS1, VVS2, IF (best))
+#' \item clarity. a measurement of how clear the diamond is (I1 (worst), SI1, SI2, VS1, VS2, VVS1, VVS2, IF (best))
#' \item x. length in mm (0--10.74)
#' \item y. width in mm (0--58.9)
#' \item z. depth in mm (0--31.8)
-#' \item depth. total depth percentage = z / mean(x, y) = 2 * z / (x + y) (43--79)
+#' \item depth. total depth percentage = z / mean(x, y) = 2 * z / (x + y) (43--79)
#' \item table. width of top of diamond relative to widest point (43--95)
#' }
-#'
+#'
#' @docType data
#' @keywords datasets
#' @name diamonds
@@ -34,16 +34,16 @@ NULL
#' US economic time series.
#'
#' This dataset was produced from US economic time series data available from \url{http://research.stlouisfed.org/fred2}.
-#'
+#'
#' \itemize{
#' \item date. Month of data collection
-#'
+#'
#' \item psavert, personal savings rate, \url{http://research.stlouisfed.org/fred2/series/PSAVERT/}
#' \item pce, personal consumption expenditures, in billions of dollars, \url{http://research.stlouisfed.org/fred2/series/PCE}
#' \item unemploy, number of unemployed in thousands, \url{http://research.stlouisfed.org/fred2/series/UNEMPLOY}
#' \item uempmed, median duration of unemployment, in week, \url{http://research.stlouisfed.org/fred2/series/UEMPMED}
#' \item pop, total population, in thousands, \url{http://research.stlouisfed.org/fred2/series/POP}
-#'
+#'
#' }
#'
#' @docType data
@@ -58,7 +58,7 @@ NULL
#' Demographic information of midwest counties
#'
#' The variables are as follows:
-#'
+#'
#' \itemize{
#' \item PID
#' \item county
@@ -77,10 +77,10 @@ NULL
#' \item percasian. Percent Asian.
#' \item percother. Percent other races.
#' \item popadults. Number of adults.
-#' \item perchsd.
+#' \item perchsd.
#' \item percollege. Percent college educated.
#' \item percprof. Percent profession.
-#' \item poppovertyknown.
+#' \item poppovertyknown.
#' \item percpovertyknown
#' \item percbelowpoverty
#' \item percchildbelowpovert
@@ -103,13 +103,13 @@ NULL
#' The internet movie database, \url{http://imdb.com/}, is a website devoted
#' to collecting movie data supplied by studios and fans. It claims to be the
#' biggest movie database on the web and is run by amazon. More about
-#' information imdb.com can be found online,
-#' \url{http://imdb.com/help/show_leaf?about}, including information about
+#' information imdb.com can be found online,
+#' \url{http://imdb.com/help/show_leaf?about}, including information about
#' the data collection process,
#' \url{http://imdb.com/help/show_leaf?infosource}.
-#'
+#'
#' Movies were selected for inclusion if they had a known length and had been rated by at least one imdb user. The data set contains the following fields:
-#'
+#'
#' \itemize{
#' \item title. Title of the movie.
#' \item year. Year of release.
@@ -121,7 +121,7 @@ NULL
#' \item mpaa. MPAA rating.
#' \item action, animation, comedy, drama, documentary, romance, short. Binary variables representing if movie was classified as belonging to that genre.
#' }
-#'
+#'
#' @docType data
#' @keywords datasets
#' @usage data(movies)
@@ -131,17 +131,17 @@ NULL
NULL
#' Fuel economy data from 1999 and 2008 for 38 popular models of car
-#'
+#'
#' This dataset contains a subset of the fuel economy data that the EPA makes
#' available on \url{http://fueleconomy.gov}. It contains only models which
#' had a new release every year between 1999 and 2008 - this was used as a
#' proxy for the popularity of the car.
-#'
+#'
#' \itemize{
#' \item manufacturer.
#' \item model.
#' \item displ. engine displacement, in litres
-#' \item year.
+#' \item year.
#' \item cyl. number of cylinders
#' \item trans. type of transmission
#' \item drv. f = front-wheel drive, r = rear wheel drive, 4 = 4wd
@@ -150,7 +150,7 @@ NULL
#' \item fl.
#' \item class.
#' }
-#'
+#'
#' @docType data
#' @keywords datasets
#' @name mpg
@@ -159,21 +159,21 @@ NULL
NULL
#' An updated and expanded version of the mammals sleep dataset.
-#'
-#' This is an updated and expanded version of the mammals sleep dataset.
+#'
+#' This is an updated and expanded version of the mammals sleep dataset.
#' Updated sleep times and weights were taken from V. M. Savage and G. B.
#' West. A quantitative, theoretical framework for understanding mammalian
#' sleep. Proceedings of the National Academy of Sciences, 104 (3):1051-1056,
-#' 2007.
-#'
+#' 2007.
+#'
#' Additional variables order, conservation status and vore were added from
#' wikipedia.
-#'
+#'
#' \itemize{
#' \item name. common name
-#' \item genus.
+#' \item genus.
#' \item vore. carnivore, omnivore or herbivore?
-#' \item order.
+#' \item order.
#' \item conservation. the conservation status of the animal
#' \item sleep\_total. total amount of sleep, in hours
#' \item sleep\_rem. rem sleep, in hours
@@ -182,7 +182,7 @@ NULL
#' \item brainwt. brain weight in kilograms
#' \item bodywt. body weight in kilograms
#' }
-#'
+#'
#' @docType data
#' @keywords datasets
#' @name msleep
@@ -191,10 +191,10 @@ NULL
NULL
#' Terms of 10 presidents from Eisenhower to Bush W.
-#'
+#'
#' The names of each president, the start and end date of their term, and
#' their party of 10 US presidents from Eisenhower to Bush W.
-#'
+#'
#' @docType data
#' @keywords datasets
#' @name presidential
@@ -210,7 +210,7 @@ NULL
#' Inference 122 (2004), 43-63, using the methods of Brillinger, D.R.,
#' "Learning a potential function from a trajectory", Signal Processing
#' Letters. December (2007).
-#'
+#'
#' @name seals
#' @usage data(seals)
#' @docType data
diff --git a/R/grob-absolute.r b/R/grob-absolute.r
index dd59121..a2d9388 100644
--- a/R/grob-absolute.r
+++ b/R/grob-absolute.r
@@ -1,41 +1,47 @@
#' Absolute grob
#'
#' This grob has fixed dimesions and position.
-#'
+#'
#' It's still experimental
-#'
-#' @S3method grobHeight absoluteGrob
-#' @S3method grobWidth absoluteGrob
-#' @S3method grobX absoluteGrob
-#' @S3method grobY absoluteGrob
-#' @S3method grid.draw absoluteGrob
+#'
#' @keywords internal
absoluteGrob <- function(grob, width = NULL, height = NULL,
xmin = NULL, ymin = NULL, vp = NULL) {
+
gTree(
- children = grob,
- width = width, height = height,
+ children = grob,
+ width = width, height = height,
xmin = xmin, ymin = ymin,
vp = vp, cl="absoluteGrob"
)
}
+#' @export
+#' @method grobHeight absoluteGrob
grobHeight.absoluteGrob <- function(x) {
x$height %||% grobHeight(x$children)
}
+#' @export
+#' @method grobWidth absoluteGrob
grobWidth.absoluteGrob <- function(x) {
x$width %||% grobWidth(x$children)
}
+#' @export
+#' @method grobX absoluteGrob
grobX.absoluteGrob <- function(x, theta) {
if (!is.null(x$xmin) && theta == "west") return(x$xmin)
grobX(x$children, theta)
}
+#' @export
+#' @method grobY absoluteGrob
grobY.absoluteGrob <- function(x, theta) {
if (!is.null(x$ymin) && theta == "south") return(x$ymin)
grobY(x$children, theta)
}
+#' @export
+#' @method grid.draw absoluteGrob
grid.draw.absoluteGrob <- function(x, recording = TRUE) {
- grid:::drawGTree(x)
+ NextMethod()
}
diff --git a/R/grob-dotstack.r b/R/grob-dotstack.r
index fa29b92..3f257ba 100644
--- a/R/grob-dotstack.r
+++ b/R/grob-dotstack.r
@@ -5,13 +5,13 @@ dotstackGrob <- function (
dotdia = unit(1, "npc"), # Dot diameter in the non-stack axis, should be in npc
stackposition = 0, # Position of each dot in the stack, relative to origin
stackratio = 1, # Stacking height of dots (.75 means 25% dot overlap)
- default.units = "npc", name = NULL, gp = gpar(), vp = NULL)
+ default.units = "npc", name = NULL, gp = gpar(), vp = NULL)
{
- if (!is.unit(x))
+ if (!is.unit(x))
x <- unit(x, default.units)
- if (!is.unit(y))
+ if (!is.unit(y))
y <- unit(y, default.units)
- if (!is.unit(dotdia))
+ if (!is.unit(dotdia))
dotdia <- unit(dotdia, default.units)
if (attr(dotdia,"unit") != "npc")
warning("Unit type of dotdia should be 'npc'")
@@ -21,7 +21,8 @@ dotstackGrob <- function (
name = name, gp = gp, vp = vp, cl = "dotstackGrob")
}
-#' @S3method drawDetails dotstackGrob
+#' @export
+#' @method drawDetails dotstackGrob
drawDetails.dotstackGrob <- function(x, recording = TRUE) {
# Need absolute coordinates because when using npc coords with circleGrob,
diff --git a/R/grob-null.r b/R/grob-null.r
index 352082a..b86ff24 100644
--- a/R/grob-null.r
+++ b/R/grob-null.r
@@ -1,19 +1,23 @@
#' The zero grob draws nothing and has zero size.
-#'
-#' @S3method widthDetails zeroGrob
-#' @S3method heightDetails zeroGrob
-#' @S3method grobWidth zeroGrob
-#' @S3method grobHeight zeroGrob
-#' @S3method drawDetails zeroGrob
+#'
#' @keywords internal
zeroGrob <- function() .zeroGrob
.zeroGrob <- grob(cl = "zeroGrob", name = "NULL")
-widthDetails.zeroGrob <-
-heightDetails.zeroGrob <-
-grobWidth.zeroGrob <-
+#' @export
+#' @method widthDetails zeroGrob
+widthDetails.zeroGrob <- function(x) unit(0, "cm")
+#' @export
+#' @method heightDetails zeroGrob
+heightDetails.zeroGrob <- function(x) unit(0, "cm")
+#' @export
+#' @method grobWidth zeroGrob
+grobWidth.zeroGrob <- function(x) unit(0, "cm")
+#' @export
+#' @method grobHeight zeroGrob
grobHeight.zeroGrob <- function(x) unit(0, "cm")
-
+#' @export
+#' @method drawDetails zeroGrob
drawDetails.zeroGrob <- function(x, recording) {}
is.zero <- function(x) is.null(x) || inherits(x, "zeroGrob")
diff --git a/R/guide-colorbar.r b/R/guide-colorbar.r
index 9138438..694045d 100644
--- a/R/guide-colorbar.r
+++ b/R/guide-colorbar.r
@@ -1,4 +1,4 @@
-#' Contiuous colour bar guide.
+#' Continuous colour bar guide.
#'
#' Colour bar guide shows continuous color scales mapped onto values.
#' Colour bar is available with \code{scale_fill} and \code{scale_colour}.
@@ -7,7 +7,7 @@
#'
#' Guides can be specified in each scale or in \code{\link{guides}}.
#' \code{guide="legend"} in scale is syntax sugar for
-#' \code{guide=guide_legend()} - but the second form allows you to specify
+#' \code{guide=guide_legend()} - but the second form allows you to specify
#' more options. As for how to specify the guide for each
#' scales, see \code{\link{guides}}.
#'
@@ -43,53 +43,53 @@
#' @examples
#' library(reshape2) # for melt
#' df <- melt(outer(1:4, 1:4), varnames = c("X1", "X2"))
-#'
+#'
#' p1 <- ggplot(df, aes(X1, X2)) + geom_tile(aes(fill = value))
#' p2 <- p1 + geom_point(aes(size = value))
-#'
+#'
#' # Basic form
#' p1 + scale_fill_continuous(guide = "colorbar")
#' p1 + scale_fill_continuous(guide = guide_colorbar())
#' p1 + guides(fill = guide_colorbar())
-#'
+#'
#' # Control styles
-#'
+#'
#' # bar size
#' p1 + guides(fill = guide_colorbar(barwidth = 0.5, barheight = 10))
-#'
+#'
#' # no label
#' p1 + guides(fill = guide_colorbar(label = FALSE))
-#'
+#'
#' # no tick marks
#' p1 + guides(fill = guide_colorbar(ticks = FALSE))
-#'
+#'
#' # label position
#' p1 + guides(fill = guide_colorbar(label.position = "left"))
#'
#' # label theme
#' p1 + guides(fill = guide_colorbar(label.theme = element_text(colour = "blue", angle = 0)))
-#'
+#'
#' # small number of bins
#' p1 + guides(fill = guide_colorbar(nbin = 3))
-#'
+#'
#' # large number of bins
#' p1 + guides(fill = guide_colorbar(nbin = 100))
-#'
+#'
#' # make top- and bottom-most ticks invisible
#' p1 + scale_fill_continuous(limits = c(0,20), breaks=c(0, 5, 10, 15, 20),
#' guide = guide_colorbar(nbin=100, draw.ulim = FALSE, draw.llim = FALSE))
-#'
+#'
#' # guides can be controlled independently
-#' p2 +
-#' scale_fill_continuous(guide = "colorbar") +
+#' p2 +
+#' scale_fill_continuous(guide = "colorbar") +
#' scale_size(guide = "legend")
#' p2 + guides(fill = "colorbar", size = "legend")
#'
-#' p2 +
+#' p2 +
#' scale_fill_continuous(guide = guide_colorbar(direction = "horizontal")) +
-#' scale_size(guide = guide_legend(direction = "vertical"))
+#' scale_size(guide = guide_legend(direction = "vertical"))
guide_colourbar <- function(
-
+
# title
title = waiver(),
title.position = NULL,
@@ -122,7 +122,7 @@ guide_colourbar <- function(
order = 0,
...) {
-
+
if (!is.null(barwidth) && !is.unit(barwidth)) barwidth <- unit(barwidth, default.unit)
if (!is.null(barheight) && !is.unit(barheight)) barheight <- unit(barheight, default.unit)
@@ -160,11 +160,12 @@ guide_colourbar <- function(
# parameter
available_aes = c("colour", "color", "fill"),
-
+
..., name="colorbar"),
class=c("guide", "colorbar"))
}
+#' @export
guide_train.colorbar <- function(guide, scale) {
# do nothing if scale are inappropriate
@@ -176,14 +177,14 @@ guide_train.colorbar <- function(guide, scale) {
warning("colorbar guide needs continuous scales.")
return(NULL)
}
-
-
+
+
# ticks - label (i.e. breaks)
output <- scale$aesthetics[1]
breaks <- scale_breaks(scale)
guide$key <- data.frame(scale_map(scale, breaks), I(scale_labels(scale, breaks)), breaks,
stringsAsFactors = FALSE)
-
+
# .value = breaks (numeric) is used for determining the position of ticks in gengrob
names(guide$key) <- c(output, ".label", ".value")
@@ -199,15 +200,18 @@ guide_train.colorbar <- function(guide, scale) {
}
# simply discards the new guide
+#' @export
guide_merge.colorbar <- function(guide, new_guide) {
guide
}
# this guide is not geom-based.
+#' @export
guide_geom.colorbar <- function(guide, ...) {
guide
}
+#' @export
guide_gengrob.colorbar <- function(guide, theme) {
# settings of location and size
@@ -215,28 +219,28 @@ guide_gengrob.colorbar <- function(guide, theme) {
"horizontal" = {
label.position <- guide$label.position %||% "bottom"
if (!label.position %in% c("top", "bottom")) stop("label position \"", label.position, "\" is invalid")
-
+
barwidth <- convertWidth(guide$barwidth %||% (theme$legend.key.width * 5), "mm")
barheight <- convertHeight(guide$barheight %||% theme$legend.key.height, "mm")
},
"vertical" = {
label.position <- guide$label.position %||% "right"
if (!label.position %in% c("left", "right")) stop("label position \"", label.position, "\" is invalid")
-
+
barwidth <- convertWidth(guide$barwidth %||% theme$legend.key.width, "mm")
barheight <- convertHeight(guide$barheight %||% (theme$legend.key.height * 5), "mm")
})
-
+
barwidth.c <- c(barwidth)
barheight.c <- c(barheight)
barlength.c <- switch(guide$direction, "horizontal" = barwidth.c, "vertical" = barheight.c)
nbreak <- nrow(guide$key)
-
+
# gap between keys etc
hgap <- c(convertWidth(unit(0.3, "lines"), "mm"))
vgap <- hgap
- grob.bar <-
+ grob.bar <-
if (guide$raster) {
image <- switch(guide$direction, horizontal = t(guide$bar$colour), vertical = rev(guide$bar$colour))
rasterGrob(image = image, width=barwidth.c, height=barheight.c, default.units = "mm", gp=gpar(col=NA), interpolate = TRUE)
@@ -382,7 +386,7 @@ guide_gengrob.colorbar <- function(guide, theme) {
"bottom" = {
widths <- c(bl_widths, max(0, title_width.c-sum(bl_widths)))
heights <- c(bl_heights, vgap, title_height.c)
- vps <- with(vps,
+ vps <- with(vps,
list(bar.row = bar.row, bar.col = bar.col,
label.row = label.row, label.col = label.col,
title.row = length(heights), title.col = 1:length(widths)))
@@ -390,7 +394,7 @@ guide_gengrob.colorbar <- function(guide, theme) {
"left" = {
widths <- c(title_width.c, hgap, bl_widths)
heights <- c(bl_heights, max(0, title_height.c-sum(bl_heights)))
- vps <- with(vps,
+ vps <- with(vps,
list(bar.row = bar.row, bar.col = bar.col+2,
label.row = label.row, label.col = label.col+2,
title.row = 1:length(heights), title.col = 1))
@@ -398,7 +402,7 @@ guide_gengrob.colorbar <- function(guide, theme) {
"right" = {
widths <- c(bl_widths, hgap, title_width.c)
heights <- c(bl_heights, max(0, title_height.c-sum(bl_heights)))
- vps <- with(vps,
+ vps <- with(vps,
list(bar.row = bar.row, bar.col = bar.col,
label.row = label.row, label.col = label.col,
title.row = 1:length(heights), title.col = length(widths)))
@@ -406,7 +410,7 @@ guide_gengrob.colorbar <- function(guide, theme) {
# background
grob.background <- element_render(theme, "legend.background")
-
+
# padding
padding <- unit(1.5, "mm")
widths <- c(padding, widths, padding)
@@ -433,4 +437,4 @@ guide_gengrob.colorbar <- function(guide, theme) {
#' @export
#' @rdname guide_colourbar
-guide_colorbar <- guide_colourbar
+guide_colorbar <- guide_colourbar
diff --git a/R/guide-legend.r b/R/guide-legend.r
index 7d5d1eb..12a9e6e 100644
--- a/R/guide-legend.r
+++ b/R/guide-legend.r
@@ -2,12 +2,12 @@
#'
#' Legend type guide shows key (i.e., geoms) mapped onto values.
#' Legend guides for various scales are integrated if possible.
-#'
+#'
#' Guides can be specified in each scale or in \code{\link{guides}}.
#' \code{guide="legend"} in scale is syntactic sugar for
#' \code{guide=guide_legend()}. As for how to specify the guide for each
#' scales in more detail, see \code{\link{guides}}.
-#'
+#'
#' @param title A character string or expression indicating a title of guide.
#' If \code{NULL}, the title is not shown. By default
#' (\code{\link{waiver}}), the name of the scale object or tha name
@@ -62,7 +62,7 @@
#' \donttest{
#' library(reshape2) # for melt
#' df <- melt(outer(1:4, 1:4), varnames = c("X1", "X2"))
-#'
+#'
#' p1 <- ggplot(df, aes(X1, X2)) + geom_tile(aes(fill = value))
#' p2 <- p1 + geom_point(aes(size = value))
#'
@@ -71,55 +71,55 @@
#' p1 + scale_fill_continuous(guide = guide_legend())
#'
#' # Guide title
-#'
+#'
#' p1 + scale_fill_continuous(guide = guide_legend(title = "V")) # title text
#' p1 + scale_fill_continuous(name = "V") # same
#' p1 + scale_fill_continuous(guide = guide_legend(title = NULL)) # no title
-#'
+#'
#' # Control styles
-#'
+#'
#' # key size
#' p1 + guides(fill = guide_legend(keywidth = 3, keyheight = 1))
-#'
+#'
#' # title position
#' p1 + guides(fill = guide_legend(title = "LEFT", title.position = "left"))
-#'
+#'
#' # title text styles via element_text
#' p1 + guides(fill = guide_legend(
#' title.theme = element_text(size=15, face="italic", colour = "red", angle = 45)))
-#'
+#'
#' # label position
#' p1 + guides(fill = guide_legend(label.position = "bottom"))
-#'
+#'
#' # label styles
-#' p1 + scale_fill_continuous(breaks = c(5, 10, 15),
-#' labels = paste("long", c(5, 10, 15)),
+#' p1 + scale_fill_continuous(breaks = c(5, 10, 15),
+#' labels = paste("long", c(5, 10, 15)),
#' guide = guide_legend(direction = "horizontal", title.position = "top",
#' label.position="bottom", label.hjust = 0.5, label.vjust = 0.5,
#' label.theme = element_text(angle = 90)))
-#'
+#'
#' # Set aesthetic of legend key
-#'
+#'
#' # very low alpha value make it difficult to see legend key
-#' p3 <- qplot(carat, price, data = diamonds, colour = color,
+#' p3 <- qplot(carat, price, data = diamonds, colour = color,
#' alpha = I(1/100))
#' p3
-#'
+#'
#' # override.aes overwrites the alpha
#' p3 + guides(colour = guide_legend(override.aes = list(alpha = 1)))
-#'
+#'
#' # multiple row/col legends
#' p <- qplot(1:20, 1:20, colour = letters[1:20])
#' p + guides(col = guide_legend(nrow = 8))
#' p + guides(col = guide_legend(ncol = 8))
#' p + guides(col = guide_legend(nrow = 8, byrow = TRUE))
#' p + guides(col = guide_legend(ncol = 8, byrow = TRUE))
-#'
+#'
#' # reversed order legend
#' p + guides(col = guide_legend(reverse = TRUE))
#' }
guide_legend <- function(
-
+
# title
title = waiver(),
title.position = NULL,
@@ -133,7 +133,7 @@ guide_legend <- function(
label.theme = NULL,
label.hjust = NULL,
label.vjust = NULL,
-
+
# key
keywidth = NULL,
keyheight = NULL,
@@ -147,12 +147,12 @@ guide_legend <- function(
byrow = FALSE,
reverse = FALSE,
order = 0,
-
+
...) {
-
+
if (!is.null(keywidth) && !is.unit(keywidth)) keywidth <- unit(keywidth, default.unit)
if (!is.null(keyheight) && !is.unit(keyheight)) keyheight <- unit(keyheight, default.unit)
-
+
structure(list(
# title
title = title,
@@ -160,7 +160,7 @@ guide_legend <- function(
title.theme = title.theme,
title.hjust = title.hjust,
title.vjust = title.vjust,
-
+
# label
label = label,
label.position = label.position,
@@ -181,7 +181,7 @@ guide_legend <- function(
byrow = byrow,
reverse = reverse,
order = order,
-
+
# parameter
available_aes = c("any"),
@@ -189,6 +189,7 @@ guide_legend <- function(
class=c("guide", "legend"))
}
+#' @export
guide_train.legend <- function(guide, scale) {
breaks <- scale_breaks(scale)
key <- data.frame(
@@ -210,17 +211,18 @@ guide_train.legend <- function(guide, scale) {
} else {
key <- key[!is.na(breaks), , drop = FALSE]
}
-
+
if (empty(key) || all(is.na(breaks))) return(NULL)
names(key) <- c(scale$aesthetics[1], ".label")
if (guide$reverse) key <- key[nrow(key):1, ]
-
+
guide$key <- key
guide$hash <- with(guide, digest(list(title, key$.label, direction, name)))
guide
}
+#' @export
guide_merge.legend <- function(guide, new_guide) {
guide$key <- merge(guide$key, new_guide$key, sort=FALSE)
guide$override.aes <- c(guide$override.aes, new_guide$override.aes)
@@ -229,6 +231,7 @@ guide_merge.legend <- function(guide, new_guide) {
guide
}
+#' @export
guide_geom.legend <- function(guide, layers, default_mapping) {
# TODO: how to deal with same geoms of multiple layers.
@@ -237,7 +240,7 @@ guide_geom.legend <- function(guide, layers, default_mapping) {
# but probably it is better to sensitive to that and generate only one geom like this:
#
# geoms <- unique(sapply(layers, function(layer) if (is.na(layer$legend) || layer$legend) layer$geom$guide_geom() else NULL))
- #
+ #
# but in this case, some conflicts occurs, e.g.,
#
# d <- data.frame(x=1:5, y=1:5, v=factor(1:5))
@@ -245,18 +248,18 @@ guide_geom.legend <- function(guide, layers, default_mapping) {
#
# geom_line generate path geom with red and geom_rug generate it with blue.
# how to deal with them ?
-
+
# arrange common data for vertical and horizontal guide
guide$geoms <- llply(layers, function(layer) {
all <- names(c(layer$mapping, default_mapping, layer$stat$default_aes()))
geom <- c(layer$geom$required_aes, names(layer$geom$default_aes()))
matched <- intersect(intersect(all, geom), names(guide$key))
matched <- setdiff(matched, names(layer$geom_params))
- data <-
+ data <-
if (length(matched) > 0) {
# This layer contributes to the legend
if (is.na(layer$show_guide) || layer$show_guide) {
- # Default is to include it
+ # Default is to include it
layer$use_defaults(guide$key[matched])
} else {
NULL
@@ -271,7 +274,7 @@ guide_geom.legend <- function(guide, layers, default_mapping) {
}
}
if (is.null(data)) return(NULL)
-
+
# override.aes in guide_legend manually changes the geom
for (aes in intersect(names(guide$override.aes), names(data))) data[[aes]] <- guide$override.aes[[aes]]
@@ -289,12 +292,14 @@ guide_geom.legend <- function(guide, layers, default_mapping) {
guide
}
+#' @export
guide_gengrob.legend <- function(guide, theme) {
# default setting
label.position <- guide$label.position %||% "right"
- if (!label.position %in% c("top", "bottom", "left", "right")) stop("label position \"", label.position, "\" is invalid")
-
+ if (!label.position %in% c("top", "bottom", "left", "right"))
+ stop("label position \"", label.position, "\" is invalid")
+
nbreak <- nrow(guide$key)
# gap between keys etc
@@ -305,7 +310,7 @@ guide_gengrob.legend <- function(guide, theme) {
title.theme <- guide$title.theme %||% calc_element("legend.title", theme)
title.hjust <- title.x <- guide$title.hjust %||% theme$legend.title.align %||% 0
title.vjust <- title.y <- guide$title.vjust %||% 0.5
-
+
grob.title <- {
if (is.null(guide$title))
zeroGrob()
@@ -326,7 +331,7 @@ guide_gengrob.legend <- function(guide, theme) {
#
# label.theme in param of guide_legend() > theme$legend.text.align > default
# hjust/vjust in theme$legend.text and label.theme are ignored.
- #
+ #
# Default:
# If label includes expression, the label is right-alignd (hjust = 0). Ohterwise, left-aligned (x = 1, hjust = 1).
# Vertical adjustment is always mid-alined (vjust = 0.5).
@@ -341,7 +346,7 @@ guide_gengrob.legend <- function(guide, theme) {
lapply(guide$key$.label,
function(label, ...) {
- g <- element_grob(element = label.theme, label = label,
+ g <- element_grob(element = label.theme, label = label,
x = x, y = y, hjust = hjust, vjust = vjust)
ggname("guide.label", g)
}
@@ -358,14 +363,14 @@ guide_gengrob.legend <- function(guide, theme) {
key_width <- convertWidth(guide$keywidth %||% theme$legend.key.width %||% theme$legend.key.size, "mm")
key_height <- convertHeight(guide$keyheight %||% theme$legend.key.height %||% theme$legend.key.size, "mm")
-
+
key_width.c <- c(key_width)
key_height.c <- c(key_height)
key_size_mat <- do.call("cbind", llply(guide$geoms, function(g) g$data$size))
key_sizes <- if (is.null(key_size_mat)) rep(0, nbreak) else apply(key_size_mat, 1, max)
- if (!is.null(guide$nrow) && !is.null(guide$ncol) && guide$nrow * guide$ncol < nbreak)
+ if (!is.null(guide$nrow) && !is.null(guide$ncol) && guide$nrow * guide$ncol < nbreak)
stop("nrow x ncol need to be larger than the number of breaks")
legend.nrow <- guide$nrow %||%
if (!is.null(guide$ncol)) ceiling(nbreak/guide$ncol)
@@ -378,7 +383,7 @@ guide_gengrob.legend <- function(guide, theme) {
key_widths.c <- pmax(key_width.c, apply(key_sizes, 2, max))
key_heights.c <-pmax(key_height.c, apply(key_sizes, 1, max))
-
+
label_widths.c <- apply(matrix(c(label_widths.c, rep(0, legend.nrow * legend.ncol - nbreak)),
legend.nrow, legend.ncol, byrow = guide$byrow),
2, max)
@@ -412,7 +417,7 @@ guide_gengrob.legend <- function(guide, theme) {
kl_widths <- head(interleave(key_widths.c, hgap/2, label_widths.c, hgap/2), -1)
kl_heights <- head(interleave(pmax(label_heights.c, key_heights.c), vgap/2), -1)
vps <- transform(vps, key.row = R*2-1, key.col = C*4-3, label.row = R*2-1, label.col = C*4-1)
- })
+ })
} else {
switch(label.position,
"top" = {
@@ -466,7 +471,7 @@ guide_gengrob.legend <- function(guide, theme) {
# grob for key
grob.keys <- list()
-
+
for (i in 1:nbreak) {
# layout position
@@ -511,3 +516,5 @@ guide_gengrob.legend <- function(guide, theme) {
gt
}
+
+globalVariables(c("R", "key.row", "key.col", "label.row", "label.col"))
diff --git a/R/guides-.r b/R/guides-.r
index ae534f7..436649f 100644
--- a/R/guides-.r
+++ b/R/guides-.r
@@ -2,7 +2,7 @@
#'
#' Guides for each scale can be set in call of \code{scale_*} with argument
#' \code{guide}, or in \code{guides}.
-#'
+#'
#' @param ... List of scale guide pairs
#' @return A list containing the mapping between scale and guide.
#' @export
@@ -10,37 +10,37 @@
#' @examples
#' \donttest{
#' # ggplot object
-#'
-#' dat <- data.frame(x = 1:5, y = 1:5, p = 1:5, q = factor(1:5),
+#'
+#' dat <- data.frame(x = 1:5, y = 1:5, p = 1:5, q = factor(1:5),
#' r = factor(1:5))
#' p <- ggplot(dat, aes(x, y, colour = p, size = q, shape = r)) + geom_point()
-#'
+#'
#' # without guide specification
#' p
-#'
+#'
#' # Show colorbar guide for colour.
#' # All these examples below have a same effect.
-#'
+#'
#' p + guides(colour = "colorbar", size = "legend", shape = "legend")
-#' p + guides(colour = guide_colorbar(), size = guide_legend(),
+#' p + guides(colour = guide_colorbar(), size = guide_legend(),
#' shape = guide_legend())
-#' p +
+#' p +
#' scale_colour_continuous(guide = "colorbar") +
-#' scale_size_discrete(guide = "legend") +
+#' scale_size_discrete(guide = "legend") +
#' scale_shape(guide = "legend")
-#'
+#'
#' # Guides are integrated where possible
-#'
+#'
#' p + guides(colour = guide_legend("title"), size = guide_legend("title"),
#' shape = guide_legend("title"))
#' # same as
#' g <- guide_legend("title")
#' p + guides(colour = g, size = g, shape = g)
-#'
+#'
#' p + theme(legend.position = "bottom")
#'
#' # position of guides
-#'
+#'
#' p + theme(legend.position = "bottom", legend.box = "horizontal")
#'
#' # Set order for multiple guides
@@ -90,7 +90,7 @@ build_guides <- function(scales, layers, default_mapping, position, theme, guide
# set themes w.r.t. guides
# should these theme$legend.XXX be renamed to theme$guide.XXX ?
-
+
# by default, guide boxes are vertically aligned
theme$legend.box <- theme$legend.box %||% "vertical"
@@ -216,7 +216,7 @@ guides_gengrob <- function(gdefs, theme) {
if (!g$title.position %in% c("top", "bottom", "left", "right")) stop("title position \"", g$title.position, "\" is invalid")
g
})
-
+
lapply(gdefs, guide_gengrob, theme)
}
@@ -224,11 +224,11 @@ guides_gengrob <- function(gdefs, theme) {
guides_build <- function(ggrobs, theme) {
n <- length(ggrobs)
-
+
theme$guide.margin <- theme$guide.margin %||% unit(0.5, "lines")
theme$guide.vmargin <- theme$guide.vmargin %||% theme$guide.margin
theme$guide.hmargin <- theme$guide.hmargin %||% theme$guide.margin
-
+
widths <- do.call("unit.c", lapply(ggrobs, function(g)sum(g$widths)))
heights <- do.call("unit.c", lapply(ggrobs, function(g)sum(g$heights)))
@@ -282,18 +282,10 @@ guides_build <- function(ggrobs, theme) {
# S3 dispatches
-#' @S3method guide_train legend
-#' @S3method guide_train colorbar
guide_train <- function(...) UseMethod("guide_train")
-#' @S3method guide_merge legend
-#' @S3method guide_merge colorbar
guide_merge <- function(...) UseMethod("guide_merge")
-#' @S3method guide_geom legend
-#' @S3method guide_geom colorbar
guide_geom <- function(...) UseMethod("guide_geom")
-#' @S3method guide_gengrob legend
-#' @S3method guide_gengrob colorbar
guide_gengrob <- function(...) UseMethod("guide_gengrob")
diff --git a/R/guides-axis.r b/R/guides-axis.r
index f3aedd7..b076513 100644
--- a/R/guides-axis.r
+++ b/R/guides-axis.r
@@ -1,5 +1,5 @@
# Grob for axes
-#
+#
# @param position of ticks
# @param labels at ticks
# @param position of axis (top, bottom, left or right)
@@ -13,7 +13,7 @@ guide_axis <- function(at, labels, position="right", theme) {
# Temporally, at is set as NA if there is no breaks.
# see also SHA: f332070fca77399a84ea7a116e8c63f6990abaf6, SHA: 2ae13ad0a856c24cab6a69b523da0936ef7a94d8
if (length(at) == 0) at <- NA
-
+
at <- unit(at, "native")
length <- theme$axis.ticks.length
label_pos <- length + theme$axis.ticks.margin
@@ -22,30 +22,30 @@ guide_axis <- function(at, labels, position="right", theme) {
zero <- unit(0, "npc")
one <- unit(1, "npc")
-
+
label_render <- switch(position,
top = , bottom = "axis.text.x",
left = , right = "axis.text.y"
)
label_x <- switch(position,
- top = ,
+ top = ,
bottom = at,
right = label_pos,
left = one - label_pos
)
label_y <- switch(position,
- top = label_pos,
+ top = label_pos,
bottom = one - label_pos,
right = ,
left = at,
)
-
+
if (is.list(labels)) {
if (any(sapply(labels, is.language))) {
labels <- do.call(expression, labels)
} else {
- labels <- unlist(labels)
+ labels <- unlist(labels)
}
}
@@ -54,14 +54,14 @@ guide_axis <- function(at, labels, position="right", theme) {
bottom = element_render(theme, label_render, labels, x = label_x),
right = ,
left = element_render(theme, label_render, labels, y = label_y))
-
+
line <- switch(position,
top = element_render(theme, "axis.line.x", c(0, 1), c(0, 0), id.lengths = 2),
bottom = element_render(theme, "axis.line.x", c(0, 1), c(1, 1), id.lengths = 2),
right = element_render(theme, "axis.line.y", c(0, 0), c(0, 1), id.lengths = 2),
left = element_render(theme, "axis.line.y", c(1, 1), c(0, 1), id.lengths = 2)
)
-
+
ticks <- switch(position,
top = element_render(theme, "axis.ticks.x",
x = rep(at, each=2),
diff --git a/R/guides-grid.r b/R/guides-grid.r
index 9885c7d..a90ed7c 100644
--- a/R/guides-grid.r
+++ b/R/guides-grid.r
@@ -1,14 +1,14 @@
# Produce a grob to be used as for panel backgrounds
guide_grid <- function(theme, x.minor, x.major, y.minor, y.major) {
-
+
x.minor <- setdiff(x.minor, x.major)
y.minor <- setdiff(y.minor, y.major)
-
+
ggname("grill", grobTree(
element_render(theme, "panel.background"),
if(length(y.minor) > 0) element_render(
theme, "panel.grid.minor.y",
- x = rep(0:1, length(y.minor)), y = rep(y.minor, each=2),
+ x = rep(0:1, length(y.minor)), y = rep(y.minor, each=2),
id.lengths = rep(2, length(y.minor))
),
if(length(x.minor) > 0) element_render(
@@ -18,12 +18,12 @@ guide_grid <- function(theme, x.minor, x.major, y.minor, y.major) {
),
if(length(y.major) > 0) element_render(
theme, "panel.grid.major.y",
- x = rep(0:1, length(y.major)), y = rep(y.major, each=2),
+ x = rep(0:1, length(y.major)), y = rep(y.major, each=2),
id.lengths = rep(2, length(y.major))
),
if(length(x.major) > 0) element_render(
theme, "panel.grid.major.x",
- x = rep(x.major, each=2), y = rep(0:1, length(x.major)),
+ x = rep(x.major, each=2), y = rep(0:1, length(x.major)),
id.lengths = rep(2, length(x.major))
)
))
diff --git a/R/labels.r b/R/labels.r
index a2c7ebe..8966ea7 100644
--- a/R/labels.r
+++ b/R/labels.r
@@ -1,5 +1,5 @@
#' Update axis/legend labels
-#'
+#'
#' @param p plot to modify
#' @param labels named list of new labels
#' @export
@@ -16,7 +16,7 @@ update_labels <- function(p, labels) {
}
#' Change axis labels and legend titles
-#'
+#'
#' @param label The text for the axis or plot title.
#' @param ... a list of new names in the form aesthetic = "new name"
#' @export
@@ -28,7 +28,7 @@ update_labels <- function(p, labels) {
#' p + ylab("New y label")
#' p + ggtitle("New plot title")
#'
-#' # This should work indepdendently of other functions that modify the
+#' # This should work indepdendently of other functions that modify the
#' # the scale names
#' p + ylab("New y label") + ylim(2, 4)
#' p + ylim(2, 4) + ylab("New y label")
@@ -38,7 +38,7 @@ update_labels <- function(p, labels) {
#' p + labs(colour = "Cylinders")
#'
#' # Can also pass in a list, if that is more convenient
-#' p + labs(list(title = "Title", x = "X", y = "Y"))
+#' p + labs(list(title = "Title", x = "X", y = "Y"))
labs <- function(...) {
args <- list(...)
if (is.list(args[[1]])) args <- args[[1]]
@@ -65,8 +65,8 @@ ggtitle <- function(label) {
# Convert aesthetic mapping into text labels
make_labels <- function(mapping) {
remove_dots <- function(x) {
- gsub("\\.\\.([a-zA-z._]+)\\.\\.", "\\1", x)
+ gsub(match_calculated_aes, "\\1", x)
}
-
+
lapply(mapping, function(x) remove_dots(deparse(x)))
}
diff --git a/R/layer.r b/R/layer.r
index 011a052..6b61f67 100644
--- a/R/layer.r
+++ b/R/layer.r
@@ -1,17 +1,17 @@
# Create a new layer
# Layer objects store the layer of an object.
-#
+#
# They have the following attributes:
-#
+#
# * data
# * geom + parameters
# * statistic + parameters
# * position + parameters
# * aesthetic mapping
# * flag for display guide: TRUE/FALSE/NA. in the case of NA, decision depends on a guide itself.
-#
+#
# Can think about grob creation as a series of data frame transformations.
-Layer <- proto(expr = {
+Layer <- proto(expr = {
geom <- NULL
geom_params <- NULL
stat <- NULL
@@ -21,13 +21,13 @@ Layer <- proto(expr = {
position <- NULL
params <- NULL
inherit.aes <- FALSE
-
+
new <- function (., geom=NULL, geom_params=NULL, stat=NULL, stat_params=NULL, data=NULL, mapping=NULL, position=NULL, params=NULL, ..., inherit.aes = TRUE, legend = NA, subset = NULL, show_guide = NA) {
# now, as for the guide, we can choose only if the layer is included or not in the guide: guide = TRUE or guide = FALSE
# in future, it may be better if we can choose which aes of this layer is included in the guide, e.g.: guide = c(colour = TRUE, size = FALSE)
if (!is.na(legend)) {
- gg_dep("0.8.9", "\"legend\" argument in geom_XXX and stat_XXX is deprecated. Use show_guide = TRUE or show_guide = FALSE for display or suppress the guide display.")
+ gg_dep("0.8.9", "Use show_guide = TRUE or show_guide = FALSE to display or suppress the guide display.")
show_guide = legend
}
@@ -36,16 +36,16 @@ Layer <- proto(expr = {
show_guide = FALSE
}
-
+
if (is.null(geom) && is.null(stat)) stop("Need at least one of stat and geom")
-
+
data <- fortify(data)
if (!is.null(mapping) && !inherits(mapping, "uneval")) stop("Mapping should be a list of unevaluated mappings created by aes or aes_string")
-
+
if (is.character(geom)) geom <- Geom$find(geom)
if (is.character(stat)) stat <- Stat$find(stat)
if (is.character(position)) position <- Position$find(position)$new()
-
+
if (is.null(geom)) geom <- stat$default_geom()
if (is.null(stat)) stat <- geom$default_stat()
if (is.null(position)) position <- geom$default_pos()$new()
@@ -61,30 +61,30 @@ Layer <- proto(expr = {
if (is.null(geom_params) && is.null(stat_params)) {
params <- c(params, list(...))
params <- rename_aes(params) # Rename American to British spellings etc
-
+
geom_params <- match.params(geom$parameters(), params)
stat_params <- match.params(stat$parameters(), params)
stat_params <- stat_params[setdiff(names(stat_params),
names(geom_params))]
- } else {
+ } else {
geom_params <- rename_aes(geom_params)
}
-
- proto(.,
- geom=geom, geom_params=geom_params,
- stat=stat, stat_params=stat_params,
+
+ proto(.,
+ geom=geom, geom_params=geom_params,
+ stat=stat, stat_params=stat_params,
data=data, mapping=mapping, subset=subset,
position=position,
inherit.aes = inherit.aes,
show_guide = show_guide,
)
}
-
+
clone <- function(.) as.proto(.$as.list(all.names=TRUE))
-
+
use_defaults <- function(., data) {
df <- aesdefaults(data, .$geom$default_aes(), NULL)
-
+
# Override mappings with atomic parameters
gp <- intersect(c(names(df), .$geom$required_aes), names(.$geom_params))
gp <- gp[unlist(lapply(.$geom_params[gp], is.atomic))]
@@ -94,37 +94,37 @@ Layer <- proto(expr = {
param_lengths <- vapply(.$geom_params[gp], length, numeric(1))
bad <- param_lengths != 1L & param_lengths != nrow(df)
if (any(bad)) {
- stop("Incompatible lengths for set aesthetics: ",
+ stop("Incompatible lengths for set aesthetics: ",
paste(names(bad), collapse = ", "), call. = FALSE)
}
df[gp] <- .$geom_params[gp]
df
}
-
+
layer_mapping <- function(., mapping = NULL) {
# For certain geoms, it is useful to be able to ignore the default
# aesthetics and only use those set in the layer
if (.$inherit.aes) {
- aesthetics <- compact(defaults(.$mapping, mapping))
+ aesthetics <- compact(defaults(.$mapping, mapping))
} else {
aesthetics <- .$mapping
}
-
+
# Drop aesthetics that are set or calculated
set <- names(aesthetics) %in% names(.$geom_params)
calculated <- is_calculated_aes(aesthetics)
-
+
aesthetics[!set & !calculated]
}
-
+
pprint <- function(.) {
if (is.null(.$geom)) {
cat("Empty layer\n")
return(invisible());
}
if (!is.null(.$mapping)) {
- cat("mapping:", clist(.$mapping), "\n")
+ cat("mapping:", clist(.$mapping), "\n")
}
.$geom$print(newline=FALSE)
cat(clist(.$geom_params), "\n")
@@ -132,23 +132,23 @@ Layer <- proto(expr = {
cat(clist(.$stat_params), "\n")
.$position$print()
}
-
-
+
+
compute_aesthetics <- function(., data, plot) {
aesthetics <- .$layer_mapping(plot$mapping)
-
+
if (!is.null(.$subset)) {
include <- data.frame(eval.quoted(.$subset, data, plot$env))
data <- data[rowSums(include, na.rm = TRUE) == ncol(include), ]
}
-
- # Override grouping if set in layer.
+
+ # Override grouping if set in layer.
if (!is.null(.$geom_params$group)) {
aesthetics["group"] <- .$geom_params$group
}
scales_add_defaults(plot$scales, data, aesthetics, plot$plot_env)
-
+
# Evaluate aesthetics in the context of their data frame
evaled <- compact(
eval.quoted(aesthetics, data, plot$plot_env))
@@ -170,24 +170,24 @@ Layer <- proto(expr = {
}
data.frame(evaled)
}
-
+
calc_statistic <- function(., data, scales) {
if (empty(data)) return(data.frame())
-
- check_required_aesthetics(.$stat$required_aes,
- c(names(data), names(.$stat_params)),
+
+ check_required_aesthetics(.$stat$required_aes,
+ c(names(data), names(.$stat_params)),
paste("stat_", .$stat$objname, sep=""))
-
+
res <- NULL
try(res <- do.call(.$stat$calculate_groups, c(
- list(data=as.name("data"), scales=as.name("scales")),
+ list(data=as.name("data"), scales=as.name("scales")),
.$stat_params)
))
if (is.null(res)) return(data.frame())
-
+
res
-
+
}
@@ -201,28 +201,28 @@ Layer <- proto(expr = {
}
aesthetics <- defaults(aesthetics, .$stat$default_aes())
aesthetics <- compact(aesthetics)
-
+
new <- strip_dots(aesthetics[is_calculated_aes(aesthetics)])
if (length(new) == 0) return(data)
# Add map stat output to aesthetics
stat_data <- as.data.frame(lapply(new, eval, data, baseenv()))
names(stat_data) <- names(new)
-
+
# Add any new scales, if needed
scales_add_defaults(plot$scales, data, new, plot$plot_env)
- # Transform the values, if the scale say it's ok
+ # Transform the values, if the scale say it's ok
# (see stat_spoke for one exception)
if (.$stat$retransform) {
stat_data <- scales_transform_df(plot$scales, stat_data)
}
-
+
cunion(stat_data, data)
}
reparameterise <- function(., data) {
if (empty(data)) return(data.frame())
- .$geom$reparameterise(data, .$geom_params)
+ .$geom$reparameterise(data, .$geom_params)
}
@@ -231,20 +231,20 @@ Layer <- proto(expr = {
.$position$adjust(data)
})
}
-
+
make_grob <- function(., data, scales, cs) {
if (empty(data)) return(zeroGrob())
-
+
data <- .$use_defaults(data)
-
+
check_required_aesthetics(.$geom$required_aes,
- c(names(data), names(.$geom_params)),
+ c(names(data), names(.$geom_params)),
paste("geom_", .$geom$objname, sep=""))
-
+
do.call(.$geom$draw_groups, c(
- data = list(as.name("data")),
- scales = list(as.name("scales")),
- coordinates = list(as.name("cs")),
+ data = list(as.name("data")),
+ scales = list(as.name("scales")),
+ coordinates = list(as.name("cs")),
.$geom_params
))
}
@@ -253,22 +253,7 @@ Layer <- proto(expr = {
})
#' Create a new layer
-#'
+#'
#' @keywords internal
#' @export
layer <- Layer$new
-
-# Determine if aesthetic is calculated
-is_calculated_aes <- function(aesthetics) {
- match <- "\\.\\.([a-zA-z._]+)\\.\\."
- stats <- rep(FALSE, length(aesthetics))
- grepl(match, sapply(aesthetics, deparse))
-}
-
-# Strip dots from expressions
-strip_dots <- function(aesthetics) {
- match <- "\\.\\.([a-zA-z._]+)\\.\\."
- strings <- lapply(aesthetics, deparse)
- strings <- lapply(strings, gsub, pattern = match, replacement = "\\1")
- lapply(strings, function(x) parse(text = x)[[1]])
-}
diff --git a/R/limits.r b/R/limits.r
index 8f06f02..97f737e 100644
--- a/R/limits.r
+++ b/R/limits.r
@@ -1,11 +1,12 @@
#' Convenience functions to set the limits of the x and y axis.
#'
#' Observations not in this range will be dropped completely and
-#' not passed to any other layers.
-#'
+#' not passed to any other layers. If a NA value is substituted for one of the
+#' limits that limit is automatically calculated.
+#'
#' @param ... if numeric, will create a continuous scale, if factor or
#' character, will create a discrete scale.
-#' @seealso For changing x or y axis limits \strong{without} dropping data
+#' @seealso For changing x or y axis limits \strong{without} dropping data
#' observations, see \code{\link{coord_cartesian}}.
#' @rdname xylim
#' @export
@@ -14,14 +15,18 @@
#' xlim(15, 20)
#' xlim(20, 15)
#' xlim(c(10, 20))
-#' xlim("a", "b", "c")
+#' xlim("a", "b", "c")
#' qplot(mpg, wt, data=mtcars) + xlim(15, 20)
-#'
+#' # with automatic lower limit
+#' qplot(mpg, wt, data=mtcars) + xlim(NA, 20)
+#'
#' # ylim
#' ylim(15, 20)
#' ylim(c(10, 20))
-#' ylim("a", "b", "c")
-#' qplot(mpg, wt, data=mtcars) + ylim(15, 20)
+#' ylim("a", "b", "c")
+#' qplot(mpg, wt, data=mtcars) + ylim(0, 4)
+#' # with automatic upper limit
+#' qplot(mpg, wt, data=mtcars) + ylim(0, NA)
xlim <- function(...) {
limits(c(...), "x")
}
@@ -33,16 +38,10 @@ ylim <- function(...) {
}
#' Generate correct scale type for specified limits
-#'
+#'
#' @param limts vector of limits
#' @param var name of variable
#' @keywords internal
-#' @S3method limits numeric
-#' @S3method limits character
-#' @S3method limits factor
-#' @S3method limits Date
-#' @S3method limits POSIXct
-#' @S3method limits POSIXlt
#' @examples
#' ggplot2:::limits(c(1, 5), "x")
#' ggplot2:::limits(c(5, 1), "x")
@@ -50,36 +49,42 @@ ylim <- function(...) {
#' ggplot2:::limits(c("A", "b", "c"), "fill")
#' ggplot2:::limits(as.Date(c("2008-01-01", "2009-01-01")), "x")
limits <- function(lims, var) UseMethod("limits")
+#' @export
limits.numeric <- function(lims, var) {
stopifnot(length(lims) == 2)
- if (lims[1] > lims[2]) {
+ if (!any(is.na(lims)) && lims[1] > lims[2]) {
trans <- "reverse"
} else {
trans <- "identity"
}
-
+
make_scale("continuous", var, limits = lims, trans = trans)
}
make_scale <- function(type, var, ...) {
scale <- match.fun(paste("scale_", var, "_", type, sep = ""))
- scale(...)
+ scale(...)
}
+#' @export
limits.character <- function(lims, var) {
make_scale("discrete", var, limits = lims)
}
+#' @export
limits.factor <- function(lims, var) {
make_scale("discrete", var, limits = as.character(lims))
}
+#' @export
limits.Date <- function(lims, var) {
stopifnot(length(lims) == 2)
make_scale("date", var, limits = lims)
}
+#' @export
limits.POSIXct <- function(lims, var) {
stopifnot(length(lims) == 2)
make_scale("datetime", var, limits = lims)
}
+#' @export
limits.POSIXlt <- function(lims, var) {
stopifnot(length(lims) == 2)
make_scale("datetime", var, limits = as.POSIXct(lims))
@@ -90,8 +95,8 @@ limits.POSIXlt <- function(lims, var) {
#. Sometimes you may want to ensure limits include a single value, for all
#' panels or all plots. This function is a thin wrapper around
#' \code{\link{geom_blank}} that makes it easy to add such values.
-#'
-#' @param ... named list of aesthetics specifying the value (or values) that
+#'
+#' @param ... named list of aesthetics specifying the value (or values) that
#' should be included in each scale.
#' @export
#' @examples
@@ -100,12 +105,12 @@ limits.POSIXlt <- function(lims, var) {
#' p + expand_limits(y = c(1, 9))
#' p + expand_limits(x = 0, y = 0)
#'
-#' qplot(mpg, wt, data = mtcars, colour = cyl) +
+#' qplot(mpg, wt, data = mtcars, colour = cyl) +
#' expand_limits(colour = seq(2, 10, by = 2))
-#' qplot(mpg, wt, data = mtcars, colour = factor(cyl)) +
+#' qplot(mpg, wt, data = mtcars, colour = factor(cyl)) +
#' expand_limits(colour = factor(seq(2, 10, by = 2)))
expand_limits <- function(...) {
data <- data.frame(...)
-
+
geom_blank(aes_all(names(data)), data, inherit.aes = FALSE)
}
diff --git a/R/matrix.r b/R/matrix.r
deleted file mode 100644
index 9430706..0000000
--- a/R/matrix.r
+++ /dev/null
@@ -1,48 +0,0 @@
-#' Code to create a scatterplot matrix (experimental)
-#'
-#' @param data data frame
-#' @param mapping any additional aesthetic mappings (do not use x and y)
-#' @param colour default point colour
-#' @keywords hplot
-#' @export
-#' @examples
-#' plotmatrix(mtcars[, 1:3])
-#' plotmatrix(mtcars[, 1:3]) + geom_smooth(method="lm")
-plotmatrix <- function(data, mapping=aes(), colour="black") {
- gg_dep("0.9.2", "This function is deprecated. For a replacement, see the ggpairs function in the GGally package.")
-
- # data <- rescaler(data, "range")
- grid <- expand.grid(x=1:ncol(data), y=1:ncol(data))
- grid <- subset(grid, x != y)
-
- all <- do.call("rbind", lapply(1:nrow(grid), function(i) {
- xcol <- grid[i, "x"]
- ycol <- grid[i, "y"]
-
- data.frame(
- xvar = names(data)[ycol],
- yvar = names(data)[xcol],
- x = data[, xcol], y = data[, ycol], data
- )
- }))
- all$xvar <- factor(all$xvar, levels=names(data))
- all$yvar <- factor(all$yvar, levels=names(data))
-
- densities <- do.call("rbind", lapply(1:ncol(data), function(i) {
- data.frame(
- xvar = names(data)[i],
- yvar = names(data)[i],
- x = data[, i]
- )
- }))
- mapping <- defaults(mapping, aes_string(x="x", y="y"))
- class(mapping) <- "uneval"
-
- ggplot(all, mapping) + facet_grid(xvar ~ yvar, scales = "free") +
- geom_point(colour = colour, na.rm = TRUE) +
- stat_density(
- aes(x = x, y = ..scaled.. * diff(range(x)) + min(x)),
- data = densities, position ="identity", colour = "grey20", geom = "line"
- )
-}
-
diff --git a/R/panel.r b/R/panel.r
index 58da336..fdb5ea7 100644
--- a/R/panel.r
+++ b/R/panel.r
@@ -2,7 +2,7 @@
#
# A panel figures out how data is positioned within a panel of a plot,
# coordinates information from scales, facets and coords. Eventually all
-# state will move out of facets and coords, and live only in panels and
+# state will move out of facets and coords, and live only in panels and
# stats, simplifying these data structures to become strategies.
#
# Information about a panel is built up progressively over time, which
@@ -30,36 +30,36 @@ train_layout <- function(panel, facet, data, plot_data) {
layout <- facet_train_layout(facet, c(list(plot_data), data))
panel$layout <- layout
panel$shrink <- facet$shrink
-
+
panel
}
# Map data to find out where it belongs in the plot.
#
-# Layout map ensures that all layer data has extra copies of data for margins
+# Layout map ensures that all layer data has extra copies of data for margins
# and missing facetting variables, and has a PANEL variable that tells that
# so it know what panel it belongs to. This is a change from the previous
# design which added facetting variables directly to the data frame and
# caused problems when they had names of aesthetics (like colour or group).
-#
+#
# @param panel a trained panel object
# @param the facetting specification
-# @param data list of data frames (one for each layer)
+# @param data list of data frames (one for each layer)
# @param plot_data default plot data frame
map_layout <- function(panel, facet, data, plot_data) {
lapply(data, function(data) {
if (is.waive(data)) data <- plot_data
facet_map_layout(facet, data, panel$layout)
- })
+ })
}
# Train position scales with data
-#
+#
# If panel-specific scales are not already present, will clone from
# the scales provided in the parameter
#
# @param panel the panel object to train
-# @param data a list of data frames (one for each layer)
+# @param data a list of data frames (one for each layer)
# @param x_scale x scale for the plot
# @param y_scale y scale for the plot
train_position <- function(panel, data, x_scale, y_scale) {
@@ -71,23 +71,23 @@ train_position <- function(panel, data, x_scale, y_scale) {
if (is.null(panel$y_scales) && !is.null(y_scale)) {
panel$y_scales <- rlply(max(layout$SCALE_Y), scale_clone(y_scale))
}
-
+
# loop over each layer, training x and y scales in turn
for(layer_data in data) {
-
+
match_id <- match(layer_data$PANEL, layout$PANEL)
-
+
if (!is.null(x_scale)) {
x_vars <- intersect(x_scale$aesthetics, names(layer_data))
SCALE_X <- layout$SCALE_X[match_id]
-
+
scale_apply(layer_data, x_vars, scale_train, SCALE_X, panel$x_scales)
}
if (!is.null(y_scale)) {
y_vars <- intersect(y_scale$aesthetics, names(layer_data))
SCALE_Y <- layout$SCALE_Y[match_id]
-
+
scale_apply(layer_data, y_vars, scale_train, SCALE_Y, panel$y_scales)
}
}
@@ -100,22 +100,22 @@ reset_scales <- function(panel) {
if (!panel$shrink) return()
l_ply(panel$x_scales, scale_reset)
l_ply(panel$y_scales, scale_reset)
-}
+}
# Map data with scales.
#
# This operation must be idempotent because it is applied twice: both before
# and after statistical transformation.
-#
-# @param data a list of data frames (one for each layer)
+#
+# @param data a list of data frames (one for each layer)
map_position <- function(panel, data, x_scale, y_scale) {
layout <- panel$layout
-
+
lapply(data, function(layer_data) {
match_id <- match(layer_data$PANEL, layout$PANEL)
- # Loop through each variable, mapping across each scale, then joining
- # back together
+ # Loop through each variable, mapping across each scale, then joining
+ # back together
x_vars <- intersect(x_scale$aesthetics, names(layer_data))
names(x_vars) <- x_vars
SCALE_X <- layout$SCALE_X[match_id]
@@ -128,7 +128,7 @@ map_position <- function(panel, data, x_scale, y_scale) {
SCALE_Y <- layout$SCALE_Y[match_id]
new_y <- scale_apply(layer_data, y_vars, scale_map, SCALE_Y,
panel$y_scales)
-
+
layer_data[, y_vars] <- new_y
layer_data
})
@@ -140,18 +140,11 @@ map_position <- function(panel, data, x_scale, y_scale) {
scale_apply <- function(data, vars, f, scale_id, scales) {
if (length(vars) == 0) return()
if (nrow(data) == 0) return()
-
+
n <- length(scales)
if (any(is.na(scale_id))) stop()
- # This is a hack for ggplot2 0.9.3 to make it compatible with both plyr 1.7.1 and
- # plyr 1.8 (and above). This should be removed for the next release of ggplot2.
- # Tag: deprecated
- if (packageVersion("plyr") <= package_version("1.7.1")) {
- scale_index <- plyr:::split_indices(seq_len(nrow(data)), scale_id, n)
- } else {
- scale_index <- plyr:::split_indices(scale_id, n)
- }
+ scale_index <- split_indices(scale_id, n)
lapply(vars, function(var) {
pieces <- lapply(seq_along(scales), function(i) {
@@ -159,7 +152,7 @@ scale_apply <- function(data, vars, f, scale_id, scales) {
})
# Join pieces back together, if necessary
if (!is.null(pieces)) {
- unlist(pieces)[order(unlist(scale_index))]
+ unlist(pieces)[order(unlist(scale_index))]
}
})
}
@@ -171,7 +164,7 @@ panel_scales <- function(panel, i) {
list(
x = panel$x_scales[[this_panel$SCALE_X]],
y = panel$y_scales[[this_panel$SCALE_Y]]
- )
+ )
}
# Compute ranges and dimensions of each panel, using the coord.
@@ -181,33 +174,33 @@ train_ranges <- function(panel, coord) {
coord_train(coord, list(x = panel$x_scales[[ix]], y = panel$y_scales[[iy]]))
}
- panel$ranges <- Map(compute_range,
+ panel$ranges <- Map(compute_range,
panel$layout$SCALE_X, panel$layout$SCALE_Y)
panel
}
# Calculate statistics
-#
+#
# @param layers list of layers
-# @param data a list of data frames (one for each layer)
+# @param data a list of data frames (one for each layer)
calculate_stats <- function(panel, data, layers) {
-
+
lapply(seq_along(data), function(i) {
d <- data[[i]]
l <- layers[[i]]
-
+
ddply(d, "PANEL", function(panel_data) {
scales <- panel_scales(panel, panel_data$PANEL[1])
l$calc_statistic(panel_data, scales)
- })
- })
+ })
+ })
}
xlabel <- function(panel, labels) {
panel$x_scales[[1]]$name %||% labels$x
}
-
+
ylabel <- function(panel, labels) {
panel$y_scales[[1]]$name %||% labels$y
}
diff --git a/R/plot-build.r b/R/plot-build.r
index 30f64b6..a691ea8 100644
--- a/R/plot-build.r
+++ b/R/plot-build.r
@@ -6,18 +6,18 @@
#' contain all information about axis limits, breaks etc.
#'
#' @param plot ggplot object
-#' @seealso \code{\link{print.ggplot}} and \code{link{benchplot}} for
+#' @seealso \code{\link{print.ggplot}} and \code{link{benchplot}} for
#' for functions that contain the complete set of steps for generating
#' a ggplot2 plot.
#' @keywords internal
#' @export
ggplot_build <- function(plot) {
if (length(plot$layers) == 0) stop("No layers in plot", call.=FALSE)
-
+
plot <- plot_clone(plot)
layers <- plot$layers
layer_data <- lapply(layers, function(y) y$data)
-
+
scales <- plot$scales
# Apply function to layer and matching data
dlapply <- function(f) {
@@ -30,7 +30,7 @@ ggplot_build <- function(plot) {
# Initialise panels, add extra data for margins & missing facetting
# variables, and add on a PANEL variable to data
-
+
panel <- new_panel()
panel <- train_layout(panel, plot$facet, layer_data, plot$data)
data <- map_layout(panel, plot$facet, layer_data, plot$data)
@@ -38,10 +38,10 @@ ggplot_build <- function(plot) {
# Compute aesthetics to produce data with generalised variable names
data <- dlapply(function(d, p) p$compute_aesthetics(d, plot))
data <- lapply(data, add_group)
-
+
# Transform all scales
data <- lapply(data, scales_transform_df, scales = scales)
-
+
# Map and train positions so that statistics have access to ranges
# and all positions are numeric
scale_x <- function() scales$get_scales("x")
@@ -49,38 +49,38 @@ ggplot_build <- function(plot) {
panel <- train_position(panel, data, scale_x(), scale_y())
data <- map_position(panel, data, scale_x(), scale_y())
-
+
# Apply and map statistics
data <- calculate_stats(panel, data, layers)
- data <- dlapply(function(d, p) p$map_statistic(d, plot))
+ data <- dlapply(function(d, p) p$map_statistic(d, plot))
data <- lapply(data, order_groups)
# Make sure missing (but required) aesthetics are added
scales_add_missing(plot, c("x", "y"))
-
+
# Reparameterise geoms from (e.g.) y and width to ymin and ymax
data <- dlapply(function(d, p) p$reparameterise(d))
# Apply position adjustments
data <- dlapply(function(d, p) p$adjust_position(d))
-
+
# Reset position scales, then re-train and map. This ensures that facets
- # have control over the range of a plot: is it generated from what's
+ # have control over the range of a plot: is it generated from what's
# displayed, or does it include the range of underlying data
reset_scales(panel)
panel <- train_position(panel, data, scale_x(), scale_y())
data <- map_position(panel, data, scale_x(), scale_y())
-
+
# Train and map non-position scales
- npscales <- scales$non_position_scales()
+ npscales <- scales$non_position_scales()
if (npscales$n() > 0) {
lapply(data, scales_train_df, scales = npscales)
data <- lapply(data, scales_map_df, scales = npscales)
}
-
+
# Train coordinate system
panel <- train_ranges(panel, plot$coordinates)
-
+
list(data = data, panel = panel, plot = plot)
}
diff --git a/R/plot-construction.r b/R/plot-construction.r
index 7fd7d8c..cbbe477 100644
--- a/R/plot-construction.r
+++ b/R/plot-construction.r
@@ -1,5 +1,5 @@
#' Modify a ggplot or theme object by adding on new components.
-#'
+#'
#' This operator allows you to add objects to a ggplot or theme object.
#'
#' If the first object is an object of class \code{ggplot}, you can add
@@ -7,7 +7,7 @@
#' object.
#'
#' \itemize{
-#' \item \code{data.frame}: replace current data.frame
+#' \item \code{data.frame}: replace current data.frame
#' (must use \code{\%+\%})
#' \item \code{uneval}: replace current aesthetics
#' \item \code{layer}: add new layer
@@ -91,7 +91,7 @@ add_ggplot <- function(p, object, objectname) {
p <- update_guides(p, object)
} else if(inherits(object, "uneval")) {
p$mapping <- defaults(object, p$mapping)
-
+
labels <- lapply(object, deparse)
names(labels) <- names(object)
p <- update_labels(p, labels)
@@ -109,11 +109,11 @@ add_ggplot <- function(p, object, objectname) {
p <- switch(object$class(),
layer = {
p$layers <- append(p$layers, object)
-
+
# Add any new labels
mapping <- make_labels(object$mapping)
default <- make_labels(object$stat$default_aes())
-
+
new_labels <- defaults(mapping, default)
p$labels <- defaults(p$labels, new_labels)
p
diff --git a/R/plot-last.r b/R/plot-last.r
index ceadb73..9e167ec 100644
--- a/R/plot-last.r
+++ b/R/plot-last.r
@@ -1,8 +1,8 @@
.plot_store <- function() {
.last_plot <- NULL
-
+
list(
- get = function() .last_plot,
+ get = function() .last_plot,
set = function(value) .last_plot <<- value
)
}
@@ -13,7 +13,7 @@ set_last_plot <- function(value) .store$set(value)
#' Retrieve the last plot to be modified or created.
-#'
+#'
#' @seealso \code{\link{ggsave}}
#' @export
last_plot <- function() .store$get()
diff --git a/R/plot-render.r b/R/plot-render.r
index cc4b54a..d976465 100644
--- a/R/plot-render.r
+++ b/R/plot-render.r
@@ -1,12 +1,12 @@
#' Build a plot with all the usual bits and pieces.
-#'
+#'
#' This function builds all grobs necessary for displaying the plot, and
#' stores them in a special data structure called a \code{\link{gtable}}.
#' This object is amenable to programmatic manipulation, should you want
#' to (e.g.) make the legend box 2 cm wide, or combine multiple plots into
#' a single display, preserving aspect ratios across the plots.
#'
-#' @seealso \code{\link{print.ggplot}} and \code{link{benchplot}} for
+#' @seealso \code{\link{print.ggplot}} and \code{link{benchplot}} for
#' for functions that contain the complete set of steps for generating
#' a ggplot2 plot.
#' @return a \code{\link{gtable}} object
@@ -20,7 +20,7 @@ ggplot_gtable <- function(data) {
panel <- data$panel
data <- data$data
theme <- plot_theme(plot)
-
+
build_grob <- function(layer, layer_data) {
if (nrow(layer_data) == 0) return()
@@ -32,8 +32,15 @@ ggplot_gtable <- function(data) {
# helper function return the position of panels in plot_table
find_panel <- function(table) {
- summarise(subset(table$layout, grepl("^panel", name)),
- t = min(t), r = max(r), b = max(b), l = min(l))
+ layout <- table$layout
+ panels <- layout[grepl("^panel", layout$name), , drop = FALSE]
+
+ data.frame(
+ t = min(panels$t),
+ r = max(panels$r),
+ b = max(panels$b),
+ l = min(panels$l)
+ )
}
# List by layer, list by panel
@@ -49,16 +56,16 @@ ggplot_gtable <- function(data) {
))
xlabel <- element_render(theme, "axis.title.x", labels$x)
ylabel <- element_render(theme, "axis.title.y", labels$y)
-
+
panel_dim <- find_panel(plot_table)
- xlab_height <- grobHeight(xlabel) +
+ xlab_height <- grobHeight(xlabel) +
if (is.null(labels$x)) unit(0, "lines") else unit(0.5, "lines")
plot_table <- gtable_add_rows(plot_table, xlab_height)
plot_table <- gtable_add_grob(plot_table, xlabel, name = "xlab",
l = panel_dim$l, r = panel_dim$r, t = -1, clip = "off")
-
- ylab_width <- grobWidth(ylabel) +
+
+ ylab_width <- grobWidth(ylabel) +
if (is.null(labels$y)) unit(0, "lines") else unit(0.5, "lines")
plot_table <- gtable_add_cols(plot_table, ylab_width, pos = 0)
plot_table <- gtable_add_grob(plot_table, ylabel, name = "ylab",
@@ -108,14 +115,14 @@ ggplot_gtable <- function(data) {
panel_dim <- find_panel(plot_table)
# for align-to-device, use this:
# panel_dim <- summarise(plot_table$layout, t = min(t), r = max(r), b = max(b), l = min(l))
-
+
if (position == "left") {
plot_table <- gtable_add_cols(plot_table, legend_width, pos = 0)
plot_table <- gtable_add_grob(plot_table, legend_box, clip = "off",
t = panel_dim$t, b = panel_dim$b, l = 1, r = 1, name = "guide-box")
} else if (position == "right") {
plot_table <- gtable_add_cols(plot_table, legend_width, pos = -1)
- plot_table <- gtable_add_grob(plot_table, legend_box, clip = "off",
+ plot_table <- gtable_add_grob(plot_table, legend_box, clip = "off",
t = panel_dim$t, b = panel_dim$b, l = -1, r = -1, name = "guide-box")
} else if (position == "bottom") {
plot_table <- gtable_add_rows(plot_table, legend_height, pos = -1)
@@ -132,17 +139,18 @@ ggplot_gtable <- function(data) {
clip = "off", name = "guide-box")
}
- # Title
+ # Title
title <- element_render(theme, "plot.title", plot$labels$title)
- title_height <- grobHeight(title) +
+ title_height <- grobHeight(title) +
if (is.null(plot$labels$title)) unit(0, "lines") else unit(0.5, "lines")
- pans <- subset(plot_table$layout, grepl("^panel", name))
-
+ pans <- plot_table$layout[grepl("^panel", plot_table$layout$name), ,
+ drop = FALSE]
+
plot_table <- gtable_add_rows(plot_table, title_height, pos = 0)
plot_table <- gtable_add_grob(plot_table, title, name = "title",
t = 1, b = 1, l = min(pans$l), r = max(pans$r), clip = "off")
-
+
# Margins
plot_table <- gtable_add_rows(plot_table, theme$plot.margin[1], pos = 0)
plot_table <- gtable_add_cols(plot_table, theme$plot.margin[2])
@@ -171,18 +179,18 @@ ggplot_gtable <- function(data) {
print.ggplot <- function(x, newpage = is.null(vp), vp = NULL, ...) {
set_last_plot(x)
if (newpage) grid.newpage()
-
+
data <- ggplot_build(x)
-
+
gtable <- ggplot_gtable(data)
if (is.null(vp)) {
- grid.draw(gtable)
+ grid.draw(gtable)
} else {
if (is.character(vp)) seekViewport(vp) else pushViewport(vp)
- grid.draw(gtable)
+ grid.draw(gtable)
upViewport()
}
-
+
invisible(data)
}
#' @rdname print.ggplot
@@ -192,7 +200,7 @@ plot.ggplot <- print.ggplot
#' Generate a ggplot2 plot grob.
-#'
+#'
#' @param x ggplot2 object
#' @keywords internal
#' @export
diff --git a/R/plot.r b/R/plot.r
index c2e404f..808f036 100644
--- a/R/plot.r
+++ b/R/plot.r
@@ -1,12 +1,12 @@
#' Create a new ggplot plot
-#'
-#' \code{ggplot()} initializes a ggplot object. It can be used to
-#' declare the input data frame for a graphic and to specify the
-#' set of plot aesthetics intended to be common throughout all
-#' subsequent layers unless specifically overridden.
#'
-#' \code{ggplot()} is typically used to construct a plot
-#' incrementally, using the + operator to add layers to the
+#' \code{ggplot()} initializes a ggplot object. It can be used to
+#' declare the input data frame for a graphic and to specify the
+#' set of plot aesthetics intended to be common throughout all
+#' subsequent layers unless specifically overridden.
+#'
+#' \code{ggplot()} is typically used to construct a plot
+#' incrementally, using the + operator to add layers to the
#' existing ggplot object. This is advantageous in that the
#' code is explicit about which layers are added and the order
#' in which they are added. For complex graphics with multiple
@@ -18,9 +18,9 @@
#' \item \code{ggplot(df)}
#' \item \code{ggplot()}
#' }
-#' The first method is recommended if all layers use the same
-#' data and the same set of aesthetics, although this method
-#' can also be used to add a layer using data from another
+#' The first method is recommended if all layers use the same
+#' data and the same set of aesthetics, although this method
+#' can also be used to add a layer using data from another
#' data frame. See the first example below. The second
#' method specifies the default data frame to use for the plot,
#' but no aesthetics are defined up front. This is useful when
@@ -30,7 +30,7 @@
#' is fleshed out as layers are added. This method is useful when
#' multiple data frames are used to produce different layers, as
#' is often the case in complex graphics.
-#'
+#'
#' The examples below illustrate how these methods of
#' invoking \code{ggplot} can be used in constructing a
#' graphic.
@@ -40,7 +40,7 @@
#' @param data default data set
#' @param ... other arguments passed to specific methods
#' @examples
-#
+#
#' df <- data.frame(gp = factor(rep(letters[1:3], each = 10)),
#' y = rnorm(30))
#' # Compute sample mean and standard deviation in each group
@@ -53,8 +53,8 @@
#' # If the data = argument is not specified, it uses the
#' # declared data frame from ggplot(); ditto for the aesthetics.
#' ggplot(df, aes(x = gp, y = y)) +
-#' geom_point() +
-#' geom_point(data = ds, aes(y = mean),
+#' geom_point() +
+#' geom_point(data = ds, aes(y = mean),
#' colour = 'red', size = 3)
#' # Same plot as above, declaring only the data frame in ggplot().
#' # Note how the x and y aesthetics must now be declared in
@@ -68,12 +68,12 @@
#' geom_point(data = df, aes(x = gp, y = y)) +
#' geom_point(data = ds, aes(x = gp, y = mean),
#' colour = 'red', size = 3) +
-#' geom_errorbar(data = ds, aes(x = gp, y = mean,
+#' geom_errorbar(data = ds, aes(x = gp, y = mean,
#' ymin = mean - sd, ymax = mean + sd),
#' colour = 'red', width = 0.4)
ggplot <- function(data = NULL, ...) UseMethod("ggplot")
-#' @S3method ggplot default
+#' @export
ggplot.default <- function(data = NULL, mapping = aes(), ...) {
ggplot.data.frame(fortify(data, ...), mapping)
}
@@ -84,7 +84,7 @@ ggplot.default <- function(data = NULL, mapping = aes(), ...) {
is.ggplot <- function(x) inherits(x, "ggplot")
#' Create a new ggplot plot from a data frame
-#'
+#'
#' @param data default data frame for plot
#' @param mapping default list of aesthetic mappings (these can be colour,
#' size, shape, line type -- see individual geom functions for more details)
@@ -95,9 +95,9 @@ is.ggplot <- function(x) inherits(x, "ggplot")
#' @export
ggplot.data.frame <- function(data, mapping=aes(), ..., environment = globalenv()) {
if (!missing(mapping) && !inherits(mapping, "uneval")) stop("Mapping should be created with aes or aes_string")
-
+
p <- structure(list(
- data = data,
+ data = data,
layers = list(),
scales = Scales$new(),
mapping = mapping,
@@ -106,7 +106,7 @@ ggplot.data.frame <- function(data, mapping=aes(), ..., environment = globalenv(
facet = facet_null(),
plot_env = environment
), class = c("gg", "ggplot"))
-
+
p$labels <- make_labels(mapping)
set_last_plot(p)
@@ -117,6 +117,6 @@ plot_clone <- function(plot) {
p <- plot
p$scales <- plot$scales$clone()
p$layers <- lapply(plot$layers, function(x) x$clone())
-
+
p
}
diff --git a/R/position-.r b/R/position-.r
index e4e5352..dbd1351 100644
--- a/R/position-.r
+++ b/R/position-.r
@@ -5,7 +5,7 @@ Position <- proto(TopLevel, expr = {
adjust <- function(., data, scales, ...) data
class <- function(.) "position"
-
+
width <- NULL
height <- NULL
new <- function(., width = NULL, height = NULL) {
@@ -16,19 +16,19 @@ Position <- proto(TopLevel, expr = {
pnames <- setdiff(names(formals(get("new", .))), ".")
values <- lapply(pnames, get, envir = .)
names(values) <- pnames
-
+
values
}
-
+
pprint <- function(., newline=TRUE) {
cat("position_", .$objname, ": (", clist(.$parameters()), ")", sep="")
if (newline) cat("\n")
}
-
+
})
-# Convenience function to ensure that all position variables
+# Convenience function to ensure that all position variables
# (x, xmin, xmax, xend) are transformed in the same way
transform_position <- function(df, trans_x = NULL, trans_y = NULL, ...) {
scales <- aes_to_scale(names(df))
@@ -39,6 +39,6 @@ transform_position <- function(df, trans_x = NULL, trans_y = NULL, ...) {
if (!is.null(trans_y)) {
df[scales == "y"] <- lapply(df[scales == "y"], trans_y, ...)
}
-
+
df
}
diff --git a/R/position-collide.r b/R/position-collide.r
index 9614aac..a4628b6 100644
--- a/R/position-collide.r
+++ b/R/position-collide.r
@@ -5,49 +5,48 @@ collide <- function(data, width = NULL, name, strategy, check.width = TRUE) {
if (!is.null(width)) {
# Width set manually
if (!(all(c("xmin", "xmax") %in% names(data)))) {
- data <- within(data, {
- xmin <- x - width / 2
- xmax <- x + width / 2
- })
+ data$xmin <- data$x - width / 2
+ data$xmax <- data$x - width / 2
}
} else {
if (!(all(c("xmin", "xmax") %in% names(data)))) {
data$xmin <- data$x
data$xmax <- data$x
}
-
- # Width determined from data, must be floating point constant
- widths <- unique(with(data, xmax - xmin))
+
+ # Width determined from data, must be floating point constant
+ widths <- unique(data$xmax - data$xmin)
widths <- widths[!is.na(widths)]
if (!zero_range(range(widths))) {
- warning(name, " requires constant width: output may be incorrect",
+ warning(name, " requires constant width: output may be incorrect",
call. = FALSE)
}
width <- widths[1]
}
- # Reorder by x position, relying on stable sort to preserve existing
+ # Reorder by x position, relying on stable sort to preserve existing
# ordering, which may be by group or order.
data <- data[order(data$xmin), ]
# Check for overlap
intervals <- as.numeric(t(unique(data[c("xmin", "xmax")])))
intervals <- intervals[!is.na(intervals)]
-
+
if (length(unique(intervals)) > 1 & any(diff(scale(intervals)) < -1e-6)) {
warning(name, " requires non-overlapping x intervals", call. = FALSE)
- # This is where the algorithm from [L. Wilkinson. Dot plots.
+ # This is where the algorithm from [L. Wilkinson. Dot plots.
# The American Statistician, 1999.] should be used
}
if (!is.null(data$ymax)) {
- ddply(data, .(xmin), strategy, width = width)
+ ddply(data, "xmin", strategy, width = width)
} else if (!is.null(data$y)) {
message("ymax not defined: adjusting position using y instead")
- transform(
- ddply(transform(data, ymax = y), .(xmin), strategy, width = width),
- y = ymax
- )
+
+ data$ymax <- data$y
+ data <- ddply(data, "xmin", strategy, width = width)
+ data$y <- data$ymax
+ data
} else {
stop("Neither y nor ymax defined")
}
@@ -57,7 +56,7 @@ collide <- function(data, width = NULL, name, strategy, check.width = TRUE) {
# Assumes that each set has the same horizontal position
pos_stack <- function(df, width) {
if (nrow(df) == 1) return(df)
-
+
n <- nrow(df) + 1
y <- with(df, ifelse(is.na(y), 0, y))
if (all(is.na(df$x))) {
@@ -88,7 +87,7 @@ pos_fill <- function(df, width) {
pos_dodge <- function(df, width) {
n <- length(unique(df$group))
if (n == 1) return(df)
-
+
if (!all(c("xmin", "xmax") %in% names(df))) {
df$xmin <- df$x
df$xmax <- df$x
@@ -96,10 +95,10 @@ pos_dodge <- function(df, width) {
d_width <- max(df$xmax - df$xmin)
diff <- width - d_width
-
+
# df <- data.frame(n = c(2:5, 10, 26), div = c(4, 3, 2.666666, 2.5, 2.2, 2.1))
# qplot(n, div, data = df)
-
+
# Have a new group index from 1 to number of groups.
# This might be needed if the group numbers in this set don't include all of 1:n
groupidx <- match(df$group, sort(unique(df$group)))
diff --git a/R/position-dodge.r b/R/position-dodge.r
index e3acbc6..3241c6f 100644
--- a/R/position-dodge.r
+++ b/R/position-dodge.r
@@ -9,24 +9,24 @@
#' geom_bar(position="dodge")
#' ggplot(diamonds, aes(x=price, fill=cut)) + geom_bar(position="dodge")
#' # see ?geom_boxplot and ?geom_bar for more examples
-#'
+#'
#' # Dodging things with different widths is tricky
#' df <- data.frame(x=c("a","a","b","b"), y=1:4, g = rep(1:2, 2))
#' (p <- qplot(x, y, data=df, group=g, position="dodge", geom="bar",
#' stat="identity"))
-#'
+#'
#' p + geom_linerange(aes(ymin = y-1, ymax = y+1), position="dodge")
#' # You need to explicitly specify the width for dodging
-#' p + geom_linerange(aes(ymin = y-1, ymax = y+1),
+#' p + geom_linerange(aes(ymin = y-1, ymax = y+1),
#' position = position_dodge(width = 0.9))
-#'
+#'
#' # Similarly with error bars:
#' p + geom_errorbar(aes(ymin = y-1, ymax = y+1), width = 0.2,
#' position="dodge")
#' p + geom_errorbar(aes(ymin = y-1, ymax = y+1, width = 0.2),
#' position = position_dodge(width = 0.90))
#' }
-position_dodge <- function (width = NULL, height = NULL) {
+position_dodge <- function (width = NULL, height = NULL) {
PositionDodge$new(width = width, height = height)
}
@@ -36,9 +36,9 @@ PositionDodge <- proto(Position, {
adjust <- function(., data) {
if (empty(data)) return(data.frame())
check_required_aesthetics("x", names(data), "position_dodge")
-
+
collide(data, .$width, .$my_name(), pos_dodge, check.width = FALSE)
- }
+ }
})
diff --git a/R/position-fill.r b/R/position-fill.r
index c3032f1..d6e7edd 100644
--- a/R/position-fill.r
+++ b/R/position-fill.r
@@ -1,6 +1,6 @@
#' Stack overlapping objects on top of one another, and standardise to have
#' equal height.
-#'
+#'
#' @inheritParams position_identity
#' @family position adjustments
#' @seealso See \code{\link{geom_bar}} and \code{\link{geom_area}} for
@@ -11,27 +11,27 @@
#' # See ?geom_bar and ?geom_area for more examples
#' ggplot(mtcars, aes(x=factor(cyl), fill=factor(vs))) +
#' geom_bar(position="fill")
-#'
+#'
#' cde <- geom_histogram(position="fill", binwidth = 500)
-#'
+#'
#' ggplot(diamonds, aes(x=price)) + cde
#' ggplot(diamonds, aes(x=price, fill=cut)) + cde
#' ggplot(diamonds, aes(x=price, fill=clarity)) + cde
#' ggplot(diamonds, aes(x=price, fill=color)) + cde
#' }
-position_fill <- function (width = NULL, height = NULL) {
+position_fill <- function (width = NULL, height = NULL) {
PositionFill$new(width = width, height = height)
}
-
+
PositionFill <- proto(Position, {
objname <- "fill"
adjust <- function(., data) {
if (empty(data)) return(data.frame())
-
+
check_required_aesthetics(c("x", "ymax"), names(data), "position_fill")
if (!all(data$ymin == 0)) warning("Filling not well defined when ymin != 0")
collide(data, .$width, .$my_name(), pos_fill)
- }
+ }
})
diff --git a/R/position-identity.r b/R/position-identity.r
index 4c9b6c3..7305f27 100644
--- a/R/position-identity.r
+++ b/R/position-identity.r
@@ -6,7 +6,7 @@
#' adjustments)
#' @family position adjustments
#' @export
-position_identity <- function (width = NULL, height = NULL) {
+position_identity <- function (width = NULL, height = NULL) {
PositionIdentity$new(width = width, height = height)
}
diff --git a/R/position-jitter.r b/R/position-jitter.r
index 3c47a16..338d07b 100644
--- a/R/position-jitter.r
+++ b/R/position-jitter.r
@@ -8,8 +8,8 @@
#' @export
#' @examples
#' qplot(am, vs, data = mtcars)
-#'
-#' # Default amount of jittering will generally be too much for
+#'
+#' # Default amount of jittering will generally be too much for
#' # small datasets:
#' qplot(am, vs, data = mtcars, position = "jitter")
#' # Control the amount as follows
@@ -18,24 +18,24 @@
#' # With ggplot
#' ggplot(mtcars, aes(x = am, y = vs)) + geom_point(position = "jitter")
#' ggplot(mtcars, aes(x = am, y = vs)) + geom_point(position = position_jitter(w = 0.1, h = 0.1))
-#'
-#' # The default works better for large datasets, where it will
+#'
+#' # The default works better for large datasets, where it will
#' # take up as much space as a boxplot or a bar
#' qplot(class, hwy, data = mpg, geom = c("boxplot", "jitter"))
-position_jitter <- function (width = NULL, height = NULL) {
+position_jitter <- function (width = NULL, height = NULL) {
PositionJitter$new(width = width, height = height)
}
PositionJitter <- proto(Position, {
objname <- "jitter"
-
+
adjust <- function(., data) {
if (empty(data)) return(data.frame())
check_required_aesthetics(c("x", "y"), names(data), "position_jitter")
-
+
if (is.null(.$width)) .$width <- resolution(data$x, zero = FALSE) * 0.4
if (is.null(.$height)) .$height <- resolution(data$y, zero = FALSE) * 0.4
-
+
trans_x <- NULL
trans_y <- NULL
if(.$width > 0) {
@@ -44,8 +44,8 @@ PositionJitter <- proto(Position, {
if(.$height > 0) {
trans_y <- function(x) jitter(x, amount = .$height)
}
-
+
transform_position(data, trans_x, trans_y)
}
-
+
})
diff --git a/R/position-jitterdodge.R b/R/position-jitterdodge.R
new file mode 100644
index 0000000..903062d
--- /dev/null
+++ b/R/position-jitterdodge.R
@@ -0,0 +1,87 @@
+#' Adjust position by simultaneously dodging and jittering
+#'
+#' This is primarily used for aligning points generated through
+#' \code{geom_point()} with dodged boxplots (e.g., a \code{geom_boxplot()} with
+#' a fill aesthetic supplied).
+#'
+#' @family position adjustments
+#' @param jitter.width degree of jitter in x direction. Defaults to 40\% of the
+#' resolution of the data.
+#' @param jitter.height degree of jitter in y direction. Defaults to 0.
+#' @param dodge.width the amount to dodge in the x direction. Defaults to 0.75,
+#' the default \code{position_dodge()} width.
+#' @export
+#' @examples
+#' dsub <- diamonds[ sample(nrow(diamonds), 1000), ]
+#' ggplot(dsub, aes(x = cut, y = carat, fill = clarity)) +
+#' geom_boxplot(outlier.size = 0) +
+#' geom_point(pch = 21, position = position_jitterdodge())
+position_jitterdodge <- function (jitter.width = NULL,
+ jitter.height = NULL,
+ dodge.width = NULL) {
+
+ PositionJitterDodge$new(jitter.width = jitter.width,
+ jitter.height = jitter.height,
+ dodge.width = dodge.width)
+}
+
+PositionJitterDodge <- proto(Position, {
+
+ jitter.width <- NULL
+ jitter.height <- NULL
+ dodge.width <- NULL
+
+ new <- function(.,
+ jitter.width = NULL,
+ jitter.height = NULL,
+ dodge.width = NULL) {
+
+ .$proto(jitter.width=jitter.width,
+ jitter.height=jitter.height,
+ dodge.width=dodge.width)
+
+ }
+
+ objname <- "jitterdodge"
+
+ adjust <- function(., data) {
+
+ if (empty(data)) return(data.frame())
+ check_required_aesthetics(c("x", "y", "fill"), names(data), "position_jitterdodge")
+
+ ## Workaround to avoid this warning:
+ ## ymax not defined: adjusting position using y instead
+ if (!("ymax" %in% names(data))) {
+ data$ymax <- data$y
+ }
+
+ ## Adjust the x transformation based on the number of 'fill' variables
+ nfill <- length(levels(data$fill))
+
+ if (is.null(.$jitter.width)) {
+ .$jitter.width <- resolution(data$x, zero = FALSE) * 0.4
+ }
+
+ if (is.null(.$jitter.height)) {
+ .$jitter.height <- 0
+ }
+
+ trans_x <- NULL
+ trans_y <- NULL
+ if (.$jitter.width > 0) {
+ trans_x <- function(x) jitter(x, amount = .$jitter.width / (nfill + 2))
+ }
+ if (.$jitter.height > 0) {
+ trans_y <- function(x) jitter(x, amount = .$jitter.height)
+ }
+
+ if (is.null(.$dodge.width)) {
+ .$dodge.width <- 0.75
+ }
+
+ ## dodge, then jitter
+ data <- collide(data, .$dodge.width, .$my_name(), pos_dodge, check.width = FALSE)
+ transform_position(data, trans_x, trans_y)
+ }
+
+})
diff --git a/R/position-stack.r b/R/position-stack.r
index 0d73d4b..3404a87 100644
--- a/R/position-stack.r
+++ b/R/position-stack.r
@@ -1,26 +1,26 @@
#' Stack overlapping objects on top of one another.
-#'
+#'
#' @inheritParams position_identity
#' @family position adjustments
#' @export
-#' @examples
+#' @examples
#' # Stacking is the default behaviour for most area plots:
#' ggplot(mtcars, aes(factor(cyl), fill = factor(vs))) + geom_bar()
-#'
+#'
#' # To change stacking order, use factor() to change order of levels
#' mtcars$vs <- factor(mtcars$vs, levels = c(1,0))
#' ggplot(mtcars, aes(factor(cyl), fill = factor(vs))) + geom_bar()
#'
#' ggplot(diamonds, aes(price)) + geom_histogram(binwidth=500)
#' ggplot(diamonds, aes(price, fill = cut)) + geom_histogram(binwidth=500)
-#'
+#'
#' # Stacking is also useful for time series
#' data.set <- data.frame(
#' Time = c(rep(1, 4),rep(2, 4), rep(3, 4), rep(4, 4)),
#' Type = rep(c('a', 'b', 'c', 'd'), 4),
#' Value = rpois(16, 10)
#' )
-#'
+#'
#' qplot(Time, Value, data = data.set, fill = Type, geom = "area")
#' # If you want to stack lines, you need to say so:
#' qplot(Time, Value, data = data.set, colour = Type, geom = "line")
@@ -28,7 +28,7 @@
#' position = "stack")
#' # But realise that this makes it *much* harder to compare individual
#' # trends
-position_stack <- function (width = NULL, height = NULL) {
+position_stack <- function (width = NULL, height = NULL) {
PositionStack$new(width = width, height = height)
}
@@ -38,19 +38,19 @@ PositionStack <- proto(Position, {
adjust <- function(., data) {
if (empty(data)) return(data.frame())
- data <- remove_missing(data, FALSE,
+ data <- remove_missing(data, FALSE,
c("x", "y", "ymin", "ymax", "xmin", "xmax"), name = "position_stack")
-
+
if (is.null(data$ymax) && is.null(data$y)) {
- message("Missing y and ymax in position = 'stack'. ",
+ message("Missing y and ymax in position = 'stack'. ",
"Maybe you want position = 'identity'?")
return(data)
}
- if (!is.null(data$ymin) && !all(data$ymin == 0))
+ if (!is.null(data$ymin) && !all(data$ymin == 0))
warning("Stacking not well defined when ymin != 0", call. = FALSE)
collide(data, .$width, .$my_name(), pos_stack)
- }
+ }
})
diff --git a/R/quick-plot.r b/R/quick-plot.r
index 7538e4f..b1fd2dc 100644
--- a/R/quick-plot.r
+++ b/R/quick-plot.r
@@ -73,6 +73,7 @@
#' # Use different geoms
#' qplot(mpg, wt, data = mtcars, geom="path")
#' qplot(factor(cyl), wt, data = mtcars, geom=c("boxplot", "jitter"))
+#' qplot(mpg, data = mtcars, geom = "dotplot")
#' }
qplot <- function(x, y = NULL, ..., data, facets = NULL, margins=FALSE, geom = "auto", stat=list(NULL), position=list(NULL), xlim = c(NA, NA), ylim = c(NA, NA), log = "", main = NULL, xlab = deparse(substitute(x)), ylab = deparse(substitute(y)), asp = NA) {
diff --git a/R/save.r b/R/save.r
index 5aa2f44..0e95ba1 100644
--- a/R/save.r
+++ b/R/save.r
@@ -1,14 +1,14 @@
#' Save a ggplot with sensible defaults
-#'
+#'
#' ggsave is a convenient function for saving a plot. It defaults to
-#' saving the last plot that you displayed, and for a default size uses
-#' the size of the current graphics device. It also guesses the type of
-#' graphics device from the extension. This means the only argument you
+#' saving the last plot that you displayed, and for a default size uses
+#' the size of the current graphics device. It also guesses the type of
+#' graphics device from the extension. This means the only argument you
#' need to supply is the filename.
-#'
+#'
#' \code{ggsave} currently recognises the extensions eps/ps, tex (pictex),
#' pdf, jpeg, tiff, png, bmp, svg and wmf (windows only).
-#'
+#'
#' @param filename file name/filename of plot
#' @param plot plot to save, defaults to last plot displayed
#' @param device device to use, automatically extract from file name extension
@@ -25,15 +25,15 @@
#' @param ... other arguments passed to graphics device
#' @export
#' @examples
-#' \donttest{
+#' \dontrun{
#' ratings <- qplot(rating, data=movies, geom="histogram")
#' qplot(length, data=movies, geom="histogram")
-#' ggsave(file="length-hist.pdf")
-#' ggsave(file="length-hist.png")
-#' ggsave(ratings, file="ratings.pdf")
-#' ggsave(ratings, file="ratings.pdf", width=4, height=4)
+#' ggsave("length-hist.pdf")
+#' ggsave("length-hist.png")
+#' ggsave("ratings.pdf", ratings)
+#' ggsave("ratings.pdf", ratings, width=4, height=4)
#' # make twice as big as on screen
-#' ggsave(ratings, file="ratings.pdf", scale=2)
+#' ggsave("ratings.pdf", ratings, scale=2)
#' }
ggsave <- function(filename = default_name(plot), plot = last_plot(),
device = default_device(filename), path = NULL, scale = 1,
@@ -42,33 +42,33 @@ ggsave <- function(filename = default_name(plot), plot = last_plot(),
if (!inherits(plot, "ggplot")) stop("plot should be a ggplot2 plot")
- eps <- ps <- function(..., width, height)
+ eps <- ps <- function(..., width, height)
grDevices::postscript(..., width=width, height=height, onefile=FALSE,
horizontal = FALSE, paper = "special")
- tex <- function(..., width, height)
+ tex <- function(..., width, height)
grDevices::pictex(..., width=width, height=height)
- pdf <- function(..., version="1.4")
+ pdf <- function(..., version="1.4")
grDevices::pdf(..., version=version)
- svg <- function(...)
+ svg <- function(...)
grDevices::svg(...)
- wmf <- function(..., width, height)
+ wmf <- function(..., width, height)
grDevices::win.metafile(..., width=width, height=height)
emf <- function(..., width, height)
grDevices::win.metafile(..., width=width, height=height)
- png <- function(..., width, height)
+ png <- function(..., width, height)
grDevices::png(..., width=width, height=height, res = dpi, units = "in")
- jpg <- jpeg <- function(..., width, height)
+ jpg <- jpeg <- function(..., width, height)
grDevices::jpeg(..., width=width, height=height, res = dpi, units = "in")
- bmp <- function(..., width, height)
+ bmp <- function(..., width, height)
grDevices::bmp(..., width=width, height=height, res = dpi, units = "in")
- tiff <- function(..., width, height)
+ tiff <- function(..., width, height)
grDevices::tiff(..., width=width, height=height, res = dpi, units = "in")
-
- default_name <- function(plot) {
+
+ default_name <- function(plot) {
paste(digest.ggplot(plot), ".pdf", sep="")
}
-
+
default_device <- function(filename) {
pieces <- strsplit(filename, "\\.")[[1]]
ext <- tolower(pieces[length(pieces)])
@@ -113,13 +113,13 @@ ggsave <- function(filename = default_name(plot), plot = last_plot(),
stop("Dimensions exceed 50 inches (height and width are specified in inches/cm/mm, not pixels).",
" If you are sure you want these dimensions, use 'limitsize=FALSE'.")
}
-
+
if (!is.null(path)) {
filename <- file.path(path, filename)
}
device(file=filename, width=width, height=height, ...)
on.exit(capture.output(dev.off()))
print(plot)
-
+
invisible()
}
diff --git a/R/scale-.r b/R/scale-.r
index fd4a0ff..065ccaa 100644
--- a/R/scale-.r
+++ b/R/scale-.r
@@ -1,49 +1,54 @@
#' Components of a scale:
#'
#' Guide related:
-#' * name
-#' * breaks
-#' * labels
-#' * expand
+#'
+#' \itemize{
+#' \item name
+#' \item breaks
+#' \item labels
+#' \item expand
+#' }
#'
#' Mapping related:
-#' * aesthetic
-#' * limits
-#' * palette
-#' * trans
+#' \itemize{
+#' \item aesthetic
+#' \item limits
+#' \item palette
+#' \item trans
+#' }
#'
#' Scales are an S3 class with a single mutable component implemented with
#' a reference class - the range of the data. This mutability makes working
#' with scales much easier, because it makes it possible to distribute the
-#' training, without having to worry about collecting all the pieces back
+#' training, without having to worry about collecting all the pieces back
#' together again.
#'
#' @name ggscale
-#' @S3method print scale
+#' @keywords internal
NULL
#' Continuous scale constructor.
#'
#' @export
#' @inheritParams discrete_scale
-#' @param minor_breaks Used with date or datetime scales. Either \code{NULL} for
-#' no minor breaks, \code{waiver()} for the default breaks (one minor break
-#' between each major break), a numeric vector of positions, or a function
+#' @param minor_breaks Used with date or datetime scales. Either \code{NULL} for
+#' no minor breaks, \code{waiver()} for the default breaks (one minor break
+#' between each major break), a numeric vector of positions, or a function
#' that given the limits returns a vector of minor breaks.
-#' @param limits A numeric vector of length two describing the scale limits.
-#' @param rescaler Used by diverging and n colour gradients
+#' @param limits A numeric vector of length two describing the scale limits.
+#' @param rescaler Used by diverging and n colour gradients
#' (i.e. \code{\link{scale_colour_gradient2}}, \code{\link{scale_colour_gradientn}}).
#' @param oob What to do with values outside scale limits (out of bounds)?
#' @keywords internal
continuous_scale <- function(aesthetics, scale_name, palette, name = NULL, breaks = waiver(), minor_breaks = waiver(), labels = waiver(), legend = NULL, limits = NULL, rescaler = rescale, oob = censor, expand = waiver(), na.value = NA_real_, trans = "identity", guide="legend") {
if (!is.null(legend)) {
- gg_dep("0.8.9", "\"legend\" argument in scale_XXX is deprecated. Use guide=\"none\" for suppress the guide display.")
+ gg_dep("0.8.9", "Use guide=\"none\" for suppress the guide display.")
if (legend == FALSE) guide = "none"
else if (legend == TRUE) guide = "legend"
}
-
- bad_labels <- is.vector(breaks) && is.vector(labels) &&
+
+ bad_labels <- is.vector(breaks) && is.vector(labels) &&
length(breaks) != length(labels)
if (bad_labels) {
stop("Breaks and labels have unequal lengths", call. = FALSE)
@@ -52,32 +57,32 @@ continuous_scale <- function(aesthetics, scale_name, palette, name = NULL, break
if (is.null(breaks) && !is_position_aes(aesthetics) && guide != "none") {
guide <- "none"
}
-
+
trans <- as.trans(trans)
if (!is.null(limits)) {
limits <- trans$trans(limits)
}
-
+
structure(list(
- call = match.call(),
-
+ call = match.call(),
+
aesthetics = aesthetics,
scale_name = scale_name,
palette = palette,
-
+
range = ContinuousRange$new(),
limits = limits,
- trans = trans,
+ trans = trans,
na.value = na.value,
expand = expand,
- rescaler = rescaler, # Used by diverging and n colour gradients
+ rescaler = rescaler, # Used by diverging and n colour gradients
oob = oob,
- name = name,
+ name = name,
breaks = breaks,
minor_breaks = minor_breaks,
- labels = labels,
+ labels = labels,
legend = legend,
guide = guide
), class = c(scale_name, "continuous", "scale"))
@@ -100,7 +105,7 @@ continuous_scale <- function(aesthetics, scale_name, palette, name = NULL, break
#' \itemize{
#' \item \code{NULL}: don't display any breaks
#' \item a character vector giving the breaks as they should appear on the
-#' axis or in the legend.
+#' axis or in the legend.
#' \item \code{waiver()} to use the default break computation.
#' \item a function, that when called with a single argument, a character
#' vector giving the limits of the scale, returns a character vector
@@ -108,7 +113,7 @@ continuous_scale <- function(aesthetics, scale_name, palette, name = NULL, break
#' }
#' This parameter does not affect in any way how the data is scaled - it
#' only affects the appearance of the legend.
-#' @param limits A character vector specifying the data range for the scale.
+#' @param limits A character vector specifying the data range for the scale.
# The limits control what levels are displayed in the plot, their order,
#' and the default order of their display in guides.
#' @param labels \code{NULL} for no labels, \code{waiver()} for default
@@ -120,17 +125,18 @@ continuous_scale <- function(aesthetics, scale_name, palette, name = NULL, break
#' additive constant used to expand the range of the scales so that there
#' is a small gap between the data and the axes.
#' @param na.value how should missing values be displayed?
-#' @param guide the name of, or actual function, used to create the
+#' @param guide the name of, or actual function, used to create the
#' guide.
+#' @keywords internal
discrete_scale <- function(aesthetics, scale_name, palette, name = NULL, breaks = waiver(), labels = waiver(), legend = NULL, limits = NULL, expand = waiver(), na.value = NA, drop = TRUE, guide="legend") {
if (!is.null(legend)) {
- gg_dep("0.8.9", "\"legend\" argument in scale_XXX is deprecated. Use guide=\"none\" for suppress the guide display.")
+ gg_dep("0.8.9", "Use guide=\"none\" for suppress the guide display.")
if (legend == FALSE) guide = "none"
else if (legend == TRUE) guide = "legend"
}
-
- bad_labels <- is.vector(breaks) && is.vector(labels) &&
+
+ bad_labels <- is.vector(breaks) && is.vector(labels) &&
length(breaks) != length(labels)
if (bad_labels) {
stop("Breaks and labels have unequal lengths", call. = FALSE)
@@ -141,20 +147,20 @@ discrete_scale <- function(aesthetics, scale_name, palette, name = NULL, breaks
}
structure(list(
- call = match.call(),
+ call = match.call(),
aesthetics = aesthetics,
scale_name = scale_name,
palette = palette,
-
+
range = DiscreteRange$new(),
limits = limits,
na.value = na.value,
expand = expand,
- name = name,
+ name = name,
breaks = breaks,
- labels = labels,
+ labels = labels,
legend = legend,
drop = drop,
guide = guide
@@ -166,11 +172,11 @@ discrete_scale <- function(aesthetics, scale_name, palette, name = NULL, breaks
# @return updated range (invisibly)
# @seealso \code{\link{scale_train}} for scale specific generic method
scale_train_df <- function(scale, df) {
- if (empty(df)) return()
+ if (empty(df)) return()
aesthetics <- intersect(scale$aesthetics, names(df))
for(aesthetic in aesthetics) {
- scale_train(scale, df[[aesthetic]])
+ scale_train(scale, df[[aesthetic]])
}
invisible()
}
@@ -182,25 +188,25 @@ scale_train <- function(scale, x) {
UseMethod("scale_train")
}
-#' @S3method scale_train continuous
+#' @export
scale_train.continuous <- function(scale, x) {
scale$range$train(x)
}
-#' @S3method scale_train discrete
+#' @export
scale_train.discrete <- function(scale, x) {
scale$range$train(x, drop = scale$drop)
}
# Reset scale, untraining ranges
scale_reset <- function(scale, x) UseMethod("scale_reset")
-#' @S3method scale_reset default
+#' @export
scale_reset.default <- function(scale, x) {
scale$range$reset()
}
scale_is_empty <- function(scale) UseMethod("scale_is_empty")
-#' @S3method scale_is_empty default
+#' @export
scale_is_empty.default <- function(scale) {
is.null(scale$range$range) && is.null(scale$limits)
}
@@ -217,25 +223,25 @@ scale_transform_df <- function(scale, df) {
scale_transform <- function(scale, x) UseMethod("scale_transform")
-#' @S3method scale_transform continuous
+#' @export
scale_transform.continuous <- function(scale, x) {
scale$trans$trans(x)
}
-#' @S3method scale_transform discrete
+#' @export
scale_transform.discrete <- function(scale, x) {
x
}
# @return list of mapped variables
-scale_map_df <- function(scale, df, i = NULL) {
+scale_map_df <- function(scale, df, i = NULL) {
if (empty(df)) return()
aesthetics <- intersect(scale$aesthetics, names(df))
names(aesthetics) <- aesthetics
if (length(aesthetics) == 0) return()
-
+
if (is.null(i)) {
- lapply(aesthetics, function(j) scale_map(scale, df[[j]]))
+ lapply(aesthetics, function(j) scale_map(scale, df[[j]]))
} else {
lapply(aesthetics, function(j) scale_map(scale, df[[j]][i]))
}
@@ -252,11 +258,11 @@ scale_map_df <- function(scale, df, i = NULL) {
# Now coord_train calls this function with limits determined by coord (with expansion).
scale_map <- function(scale, x, limits) UseMethod("scale_map")
-#' @S3method scale_map continuous
+#' @export
scale_map.continuous <- function(scale, x, limits = scale_limits(scale)) {
x <- scale$oob(scale$rescaler(x, from = limits))
- # Points are rounded to the nearest 500th, to reduce the amount of
+ # Points are rounded to the nearest 500th, to reduce the amount of
# work that the scale palette must do - this is particularly important
# for colour scales which are rather slow. This shouldn't have any
# perceptual impacts.
@@ -268,7 +274,7 @@ scale_map.continuous <- function(scale, x, limits = scale_limits(scale)) {
ifelse(!is.na(scaled), scaled, scale$na.value)
}
-#' @S3method scale_map discrete
+#' @export
scale_map.discrete <- function(scale, x, limits = scale_limits(scale)) {
n <- sum(!is.na(limits))
pal <- scale$palette(n)
@@ -276,7 +282,7 @@ scale_map.discrete <- function(scale, x, limits = scale_limits(scale)) {
if (is.null(names(pal))) {
pal_match <- pal[match(as.character(x), limits)]
} else {
- pal_match <- pal[match(as.character(x), names(pal))]
+ pal_match <- pal[match(as.character(x), names(pal))]
pal_match <- unname(pal_match)
}
@@ -288,20 +294,27 @@ scale_limits <- function(scale) {
UseMethod("scale_limits")
}
-
-#' @S3method scale_limits default
+
+# if scale contains a NULL, use the default scale range
+# if scale contains a NA, use the default range for that axis, otherwise
+# use the user defined limit for that axis
+#' @export
scale_limits.default <- function(scale) {
- scale$limits %||% scale$range$range
+ if(!is.null(scale$limits)) {
+ ifelse(!is.na(scale$limits), scale$limits, scale$range$range)
+ } else {
+ scale$range$range
+ }
}
# @kohske
# this (internal) function always returns a vector of length 2 of giving
-# multiplicative and additive expansion constants.
+# multiplicative and additive expansion constants.
# if scale' expand is specified, return it.
# if is.waive, return c(0, 0)
scale_expand <- function(scale) UseMethod("scale_expand")
-#' @S3method scale_expand default
+#' @export
scale_expand.default <- function(scale) {
if (is.waive(scale$expand)) c(0, 0)
else scale$expand
@@ -313,22 +326,22 @@ scale_expand.default <- function(scale) {
# scale_dimension uses scale_expand(scale) for expansion by default.
scale_dimension <- function(scale, expand = scale_expand(scale)) UseMethod("scale_dimension")
-#' @S3method scale_dimension continuous
+#' @export
scale_dimension.continuous <- function(scale, expand = scale_expand(scale)) {
expand_range(scale_limits(scale), expand[1], expand[2])
}
-#' @S3method scale_dimension discrete
+#' @export
scale_dimension.discrete <- function(scale, expand = scale_expand(scale)) {
expand_range(length(scale_limits(scale)), expand[1], expand[2])
}
scale_breaks <- function(scale, limits = scale_limits(scale)) {
if (scale_is_empty(scale)) return(numeric())
-
+
UseMethod("scale_breaks")
}
-#' @S3method scale_breaks continuous
+#' @export
scale_breaks.continuous <- function(scale, limits = scale_limits(scale)) {
# Limits in transformed space need to be converted back to data space
limits <- scale$trans$inv(limits)
@@ -336,7 +349,7 @@ scale_breaks.continuous <- function(scale, limits = scale_limits(scale)) {
if (is.null(scale$breaks)) {
return(NULL)
} else if (length(scale$breaks) == 1 && !is.function(scale$breaks) && is.na(scale$breaks)) {
- gg_dep("0.8.9", "breaks = NA is deprecated. Please use breaks = NULL to remove breaks in the scale.")
+ gg_dep("0.8.9", "Please use breaks = NULL to remove breaks in the scale.")
return(NULL)
} else if (zero_range(as.numeric(limits))) {
breaks <- limits[1]
@@ -362,12 +375,12 @@ scale_breaks.continuous <- function(scale, limits = scale_limits(scale)) {
breaks
}
-#' @S3method scale_breaks discrete
+#' @export
scale_breaks.discrete <- function(scale, limits = scale_limits(scale)) {
if (is.null(scale$breaks)) {
return(NULL)
} else if (length(scale$breaks) == 1 && !is.function(scale$breaks) && is.na(scale$breaks)) {
- gg_dep("0.8.9", "breaks = NA is deprecated. Please use breaks = NULL to remove breaks in the scale.")
+ gg_dep("0.8.9", "Please use breaks = NULL to remove breaks in the scale.")
return(NULL)
} else if (is.waive(scale$breaks)) {
breaks <- limits
@@ -376,7 +389,7 @@ scale_breaks.discrete <- function(scale, limits = scale_limits(scale)) {
} else {
breaks <- scale$breaks
}
-
+
# Breaks can only occur only on values in domain
in_domain <- intersect(breaks, scale_limits(scale))
structure(in_domain, pos = match(in_domain, breaks))
@@ -391,7 +404,7 @@ scale_breaks_minor<- function(scale, n = 2, b = scale_break_positions(scale), li
UseMethod("scale_breaks_minor")
}
-#' @S3method scale_breaks_minor continuous
+#' @export
scale_breaks_minor.continuous <- function(scale, n = 2, b = scale_break_positions(scale), limits = scale_limits(scale)) {
if (zero_range(as.numeric(limits))) {
return()
@@ -400,7 +413,7 @@ scale_breaks_minor.continuous <- function(scale, n = 2, b = scale_break_position
if (is.null(scale$minor_breaks)) {
return(NULL)
} else if (length(scale$minor_breaks) == 1 && !is.function(scale$minor_breaks) && is.na(scale$minor_breaks)) {
- gg_dep("0.8.9", "minor_breaks = NA is deprecated. Please use minor_breaks = NULL to remove minor breaks in the scale.")
+ gg_dep("0.8.9", "Please use minor_breaks = NULL to remove minor breaks in the scale.")
return(NULL)
} else if (is.waive(scale$minor_breaks)) {
if (is.null(b)) {
@@ -422,12 +435,12 @@ scale_breaks_minor.continuous <- function(scale, n = 2, b = scale_break_position
} else {
breaks <- scale$minor_breaks
}
-
+
# Any minor breaks outside the dimensions need to be thrown away
discard(breaks, limits)
}
-#' @S3method scale_breaks_minor discrete
+#' @export
scale_breaks_minor.discrete <- function(...) NULL
scale_breaks_minor_positions <- function(scale) {
@@ -436,20 +449,20 @@ scale_breaks_minor_positions <- function(scale) {
scale_labels <- function(scale, breaks = scale_breaks(scale)) {
if (scale_is_empty(scale)) return(character())
-
+
UseMethod("scale_labels")
}
-#' @S3method scale_labels continuous
+#' @export
scale_labels.continuous <- function(scale, breaks = scale_breaks(scale)) {
if (is.null(breaks)) return(NULL)
-
+
breaks <- scale$trans$inv(breaks)
if (is.null(scale$labels)) {
return(NULL)
} else if (length(scale$labels) == 1 && !is.function(scale$labels) && is.na(scale$labels)) {
- gg_dep("0.8.9", "labels = NA is deprecated. Please use labels = NULL to remove labels in the scale.")
+ gg_dep("0.8.9", "Please use labels = NULL to remove labels in the scale.")
return(NULL)
} else if (is.waive(scale$labels)) {
labels <- scale$trans$format(breaks)
@@ -464,14 +477,14 @@ scale_labels.continuous <- function(scale, breaks = scale_breaks(scale)) {
labels
}
-#' @S3method scale_labels discrete
+#' @export
scale_labels.discrete <- function(scale, breaks = scale_breaks(scale)) {
if (is.null(breaks)) return(NULL)
-
+
if (is.null(scale$labels)) {
return(NULL)
} else if (length(scale$labels) == 1 && !is.function(scale$labels) && is.na(scale$labels)) {
- gg_dep("0.8.9", "labels = NA is deprecated. Please use labels = NULL to remove labels in the scale.")
+ gg_dep("0.8.9", "Please use labels = NULL to remove labels in the scale.")
return(NULL)
}else if (is.waive(scale$labels)) {
format(scale_breaks(scale), justify = "none", trim = TRUE)
@@ -481,21 +494,21 @@ scale_labels.discrete <- function(scale, breaks = scale_breaks(scale)) {
if (!is.null(names(scale$labels))) {
# If labels have names, use them to match with breaks
labels <- breaks
-
+
map <- match(names(scale$labels), labels, nomatch = 0)
labels[map] <- scale$labels[map != 0]
labels
} else {
labels <- scale$labels
-
+
# Need to ensure that if breaks were dropped, corresponding labels are too
pos <- attr(breaks, "pos")
if (!is.null(pos)) {
labels <- labels[pos]
}
- labels
+ labels
}
-
+
}
}
@@ -504,20 +517,21 @@ named_labels <- function(breaks, labels) {
breaks
}
+#' @export
print.scale <- function(x, ...) {
print(x$call)
}
scale_clone <- function(scale) UseMethod("scale_clone")
-#' @S3method scale_clone continuous
+#' @export
scale_clone.continuous <- function(scale) {
new <- scale
- new$range <- ContinuousRange$new()
+ new$range <- ContinuousRange$new()
new
}
-#' @S3method scale_clone discrete
+#' @export
scale_clone.discrete <- function(scale) {
new <- scale
new$range <- DiscreteRange$new()
@@ -526,12 +540,12 @@ scale_clone.discrete <- function(scale) {
scale_break_info <- function(scale, range = NULL) UseMethod("scale_break_info")
-#' @S3method scale_break_info discrete
+#' @export
scale_break_info.discrete <- function(scale, range = NULL) {
# for discrete, limits != range
limits <- scale_limits(scale)
-
+
major <- scale_breaks(scale, limits)
if (is.null(major)) {
labels <- major_n <- NULL
@@ -546,12 +560,12 @@ scale_break_info.discrete <- function(scale, range = NULL) {
# rescale breaks [0, 1], which are used by coord/guide
major_n <- rescale(major, from = range)
}
-
+
list(range = range, labels = labels,
- major = major_n, minor = NULL,
+ major = major_n, minor = NULL,
major_source = major, minor_source = NULL)
}
-#' @S3method scale_break_info continuous
+#' @export
scale_break_info.continuous <- function(scale, range = NULL) {
# range
if (is.null(range)) range <- scale_dimension(scale)
@@ -563,9 +577,9 @@ scale_break_info.continuous <- function(scale, range = NULL) {
labels <- scale_labels(scale, major)
# drop oob breaks/labels by testing major == NA
- if (!is.null(labels)) labels <- labels[!is.na(major)]
+ if (!is.null(labels)) labels <- labels[!is.na(major)]
if (!is.null(major)) major <- major[!is.na(major)]
-
+
# minor breaks
minor <- scale_breaks_minor(scale, b = major, limits = range)
if (!is.null(minor)) minor <- minor[!is.na(minor)]
@@ -573,8 +587,8 @@ scale_break_info.continuous <- function(scale, range = NULL) {
# rescale breaks [0, 1], which are used by coord/guide
major_n <- rescale(major, from = range)
minor_n <- rescale(minor, from = range)
-
+
list(range = range, labels = labels,
- major = major_n, minor = minor_n,
+ major = major_n, minor = minor_n,
major_source = major, minor_source = minor)
}
diff --git a/R/scale-alpha.r b/R/scale-alpha.r
index bd99783..8d5599d 100644
--- a/R/scale-alpha.r
+++ b/R/scale-alpha.r
@@ -1,9 +1,9 @@
#' Alpha scales.
#'
-#' \code{scale_alpha} is an alias for \code{scale_alpha_continuous} since
+#' \code{scale_alpha} is an alias for \code{scale_alpha_continuous} since
#' that is the most common use of alpha, and it saves a bit of typing.
#'
-#' @param ... Other arguments passed on to \code{\link{continuous_scale}}
+#' @param ... Other arguments passed on to \code{\link{continuous_scale}}
#' or \code{\link{discrete_scale}} as appropriate, to control name, limits,
#' breaks, labels and so forth.
#' @param range range of output alpha values. Should lie between 0 and 1.
@@ -12,7 +12,7 @@
#' (p <- qplot(mpg, cyl, data = mtcars, alpha = cyl))
#' p + scale_alpha("cylinders")
#' p + scale_alpha("number\nof\ncylinders")
-#'
+#'
#' p + scale_alpha(range = c(0.4, 0.8))
#'
#' (p <- qplot(mpg, cyl, data=mtcars, alpha = factor(cyl)))
diff --git a/R/scale-area.r b/R/scale-area.r
index fd62a60..f54bddd 100644
--- a/R/scale-area.r
+++ b/R/scale-area.r
@@ -5,13 +5,13 @@
#' default behavir of \code{\link{scale_size_area}} is slightly different: by
#' default, it makes the area proportional to the numeric value.
#'
-#' @param ... Other arguments passed on to \code{\link{continuous_scale}}
+#' @param ... Other arguments passed on to \code{\link{continuous_scale}}
#' to control name, limits, breaks, labels and so forth.
#' @param range Range of output sizes. Should be greater than 0.
#' @export
scale_area <- function(..., range = c(1, 6)) {
gg_dep("0.9.2", paste(sep = "\n",
- "scale_area is deprecated. Use scale_size_area instead.",
+ "Use scale_size_area instead.",
" Note that the behavior of scale_size_area is slightly different:",
" by default it makes the area proportional to the numeric value."))
continuous_scale("size", "area", area_pal(range), ...)
diff --git a/R/scale-brewer.r b/R/scale-brewer.r
index 23984b4..aa73238 100644
--- a/R/scale-brewer.r
+++ b/R/scale-brewer.r
@@ -1,33 +1,60 @@
#' Sequential, diverging and qualitative colour scales from colorbrewer.org
#'
+#' ColorBrewer provides sequential, diverging and qualitative colour schemes
+#' which are particularly suited and tested to display discrete values (levels
+#' of a factor) on a map. ggplot2 can use those colours in discrete scales. It
+#' also allows to smoothly interpolate 6 colours from any palette to a
+#' continuous scale (6 colours per palette gives nice gradients; more results in
+#' more saturated colours which do not look as good). However, the original
+#' colour schemes (particularly the qualitative ones) were not intended for this
+#' and the perceptual result is left to the appreciation of the user.
+#'
#' See \url{http://colorbrewer2.org} for more information.
#'
#' @inheritParams scales::brewer_pal
#' @inheritParams scale_colour_hue
+#' @inheritParams scale_colour_gradient
+#' @inheritParams scales::gradient_n_pal
#' @family colour scales
#' @rdname scale_brewer
-#' @export
+#' @export
#' @examples
#' dsamp <- diamonds[sample(nrow(diamonds), 1000), ]
-#' (d <- qplot(carat, price, data=dsamp, colour=clarity))
-#'
+#' (d <- qplot(carat, price, data = dsamp, colour = clarity))
+#'
#' # Change scale label
#' d + scale_colour_brewer()
#' d + scale_colour_brewer("clarity")
#' d + scale_colour_brewer(expression(clarity[beta]))
-#'
+#'
#' # Select brewer palette to use, see ?scales::brewer_pal for more details
-#' d + scale_colour_brewer(type="seq")
-#' d + scale_colour_brewer(type="seq", palette=3)
-#'
-#' d + scale_colour_brewer(palette="Blues")
-#' d + scale_colour_brewer(palette="Set1")
-#'
-#' # scale_fill_brewer works just the same as
+#' d + scale_colour_brewer(type = "seq")
+#' d + scale_colour_brewer(type = "seq", palette = 3)
+#'
+#' d + scale_colour_brewer(palette = "Blues")
+#' d + scale_colour_brewer(palette = "Set1")
+#'
+#' # scale_fill_brewer works just the same as
#' # scale_colour_brewer but for fill colours
-#' ggplot(diamonds, aes(x=price, fill=cut)) +
-#' geom_histogram(position="dodge", binwidth=1000) +
+#' ggplot(diamonds, aes(x = price, fill = cut)) +
+#' geom_histogram(position = "dodge", binwidth = 1000) +
#' scale_fill_brewer()
+#'
+#' # Generate map data
+#' library(reshape2) # for melt
+#' volcano3d <- melt(volcano)
+#' names(volcano3d) <- c("x", "y", "z")
+#'
+#' # Basic plot
+#' v <- ggplot() + geom_tile(aes(x = x, y = y, fill = z), data = volcano3d)
+#' v
+#' v + scale_fill_distiller()
+#' v + scale_fill_distiller(palette = 2)
+#' v + scale_fill_distiller(type = "div")
+#' v + scale_fill_distiller(palette = "Spectral")
+#' v + scale_fill_distiller(palette = "Spectral", trans = "reverse")
+#' v + scale_fill_distiller(type = "qual")
+#' # Not appropriate for continuous data, issues a warning
scale_colour_brewer <- function(..., type = "seq", palette = 1) {
discrete_scale("colour", "brewer", brewer_pal(type, palette), ...)
}
@@ -37,3 +64,33 @@ scale_colour_brewer <- function(..., type = "seq", palette = 1) {
scale_fill_brewer <- function(..., type = "seq", palette = 1) {
discrete_scale("fill", "brewer", brewer_pal(type, palette), ...)
}
+
+#' @export
+#' @rdname scale_brewer
+scale_colour_distiller <- function(..., type = "seq", palette = 1, values = NULL, space = "Lab", na.value = "grey50") {
+ # warn about using a qualitative brewer palette to generate the gradient
+ type <- match.arg(type, c("seq", "div", "qual"))
+ if (type == "qual") {
+ warning("Using a discrete colour palette in a continuous scale.\n Consider using type = \"seq\" or type = \"div\" instead", call. = FALSE)
+ }
+ continuous_scale("colour", "distiller",
+ gradient_n_pal(brewer_pal(type, palette)(6), values, space), na.value = na.value, ...)
+ # NB: 6 colours per palette gives nice gradients; more results in more saturated colours which do not look as good
+}
+
+#' @export
+#' @rdname scale_brewer
+scale_fill_distiller <- function(..., type = "seq", palette = 1, values = NULL, space = "Lab", na.value = "grey50") {
+ type <- match.arg(type, c("seq", "div", "qual"))
+ if (type == "qual") {
+ warning("Using a discrete colour palette in a continuous scale.\n Consider using type = \"seq\" or type = \"div\" instead", call. = FALSE)
+ }
+ continuous_scale("fill", "distiller",
+ gradient_n_pal(brewer_pal(type, palette)(6), values, space), na.value = na.value, ...)
+}
+
+# icon.brewer <- function() {
+# rectGrob(c(0.1, 0.3, 0.5, 0.7, 0.9), width = 0.21,
+# gp = gpar(fill = RColorBrewer::brewer.pal(5, "PuOr"), col = NA)
+# )
+# }
diff --git a/R/scale-continuous.r b/R/scale-continuous.r
index bd78085..123acd0 100644
--- a/R/scale-continuous.r
+++ b/R/scale-continuous.r
@@ -1,30 +1,30 @@
#' Continuous position scales (x & y).
-#'
+#'
#' @param ... common continuous scale parameters: \code{name}, \code{breaks},
#' \code{labels}, \code{na.value}, \code{limits} and \code{trans}. See
#' \code{\link{continuous_scale}} for more details
-#' @param expand a numeric vector of length two giving multiplicative and
-#' additive expansion constants. These constants ensure that the data is
+#' @param expand a numeric vector of length two giving multiplicative and
+#' additive expansion constants. These constants ensure that the data is
#' placed some distance away from the axes.
#' @family position scales
#' @rdname scale_continuous
#' @export
#' @examples
#' \donttest{
-#' (m <- qplot(rating, votes, data=subset(movies, votes > 1000),
+#' (m <- qplot(rating, votes, data=subset(movies, votes > 1000),
#' na.rm = TRUE))
-#'
+#'
#' # Manipulating the default position scales lets you:
#'
#' # * change the axis labels
#' m + scale_y_continuous("number of votes")
#' m + scale_y_continuous(expression(votes^alpha))
-#'
+#'
#' # * modify the axis limits
#' m + scale_y_continuous(limits=c(0, 5000))
#' m + scale_y_continuous(limits=c(1000, 10000))
#' m + scale_x_continuous(limits=c(7, 8))
-#'
+#'
#' # you can also use the short hand functions xlim and ylim
#' m + ylim(0, 5000)
#' m + ylim(1000, 10000)
@@ -38,14 +38,14 @@
#' m + scale_x_continuous(breaks=c(2,5,8), labels=c("two", "five", "eight"))
#' m + scale_x_continuous(breaks=c(2,5,8), labels=c("horrible", "ok", "awesome"))
#' m + scale_x_continuous(breaks=c(2,5,8), labels=expression(Alpha, Beta, Omega))
-#'
+#'
#' # There are a few built in transformation that you can use:
#' m + scale_y_log10()
#' m + scale_y_sqrt()
#' m + scale_y_reverse()
#' # You can also create your own and supply them to the trans argument.
#' # See ?scale::trans_new
-#'
+#'
#' # You can control the formatting of the labels with the formatter
#' # argument. Some common formats are built into the scales package:
#' x <- rnorm(10) * 100000
@@ -55,7 +55,7 @@
#' p + scale_y_continuous(labels = percent)
#' p + scale_y_continuous(labels = dollar)
#' p + scale_x_continuous(labels = comma)
-#'
+#'
#' # qplot allows you to do some of this with a little less typing:
#' # * axis limits
#' qplot(rating, votes, data=movies, ylim=c(1e4, 5e4))
@@ -80,7 +80,7 @@ scale_y_continuous <- function(..., expand = waiver()) {
# Position aesthetics don't map, because the coordinate system takes
# care of it. But they do need to be made in to doubles, so stat methods
# can tell the difference between continuous and discrete data.
-#' @S3method scale_map position_c
+#' @export
scale_map.position_c <- function(scale, x, limits = scale_limits(scale)) {
scaled <- as.numeric(scale$oob(x, limits))
ifelse(!is.na(scaled), scaled, scale$na.value)
diff --git a/R/scale-date.r b/R/scale-date.r
index d239d95..03b2b6a 100644
--- a/R/scale-date.r
+++ b/R/scale-date.r
@@ -8,7 +8,7 @@
#' \code{\link{continuous_scale}}, for more information about the last,
#' see \code{\link[scales]{date_breaks}}`.
#' @param minor_breaks Either \code{NULL} for no minor breaks, \code{waiver()}
-#' for the default breaks (one minor break between each major break), a
+#' for the default breaks (one minor break between each major break), a
#' numeric vector of positions, or a function that given the limits returns
#' a vector of minor breaks.
#' @family position scales
@@ -21,9 +21,9 @@
#' )
#' df <- df[order(df$date), ]
#' dt <- qplot(date, price, data=df, geom="line") + theme(aspect.ratio = 1/4)
-#'
-#' # We can control the format of the labels, and the frequency of
-#' # the major and minor tickmarks. See ?format.Date and ?seq.Date
+#'
+#' # We can control the format of the labels, and the frequency of
+#' # the major and minor tickmarks. See ?format.Date and ?seq.Date
#' # for more details.
#' library(scales) # to access breaks/formatting functions
#' dt + scale_x_date()
@@ -31,49 +31,49 @@
#' dt + scale_x_date(labels = date_format("%W"))
#' dt + scale_x_date(labels = date_format("%W"), breaks = date_breaks("week"))
#'
-#' dt + scale_x_date(breaks = date_breaks("months"),
+#' dt + scale_x_date(breaks = date_breaks("months"),
#' labels = date_format("%b"))
-#' dt + scale_x_date(breaks = date_breaks("4 weeks"),
+#' dt + scale_x_date(breaks = date_breaks("4 weeks"),
#' labels = date_format("%d-%b"))
#'
#' # We can use character string for breaks.
#' # See \code{\link{by}} argument in \code{\link{seq.Date}}.
#' dt + scale_x_date(breaks = "2 weeks")
#' dt + scale_x_date(breaks = "1 month", minor_breaks = "1 week")
-#'
-#' # The date scale will attempt to pick sensible defaults for
+#'
+#' # The date scale will attempt to pick sensible defaults for
#' # major and minor tick marks
#' qplot(date, price, data=df[1:10,], geom="line")
#' qplot(date, price, data=df[1:4,], geom="line")
-#'
+#'
#' df <- data.frame(
#' date = seq(Sys.Date(), len=1000, by="1 day"),
#' price = runif(500)
#' )
#' qplot(date, price, data=df, geom="line")
-#'
+#'
#' # A real example using economic time series data
-#' qplot(date, psavert, data=economics)
-#' qplot(date, psavert, data=economics, geom="path")
-#'
+#' qplot(date, psavert, data=economics)
+#' qplot(date, psavert, data=economics, geom="path")
+#'
#' end <- max(economics$date)
#' last_plot() + scale_x_date(limits = c(as.Date("2000-1-1"), end))
#' last_plot() + scale_x_date(limits = c(as.Date("2005-1-1"), end))
#' last_plot() + scale_x_date(limits = c(as.Date("2006-1-1"), end))
-#'
+#'
#' # If we want to display multiple series, one for each variable
#' # it's easiest to first change the data from a "wide" to a "long"
#' # format:
#' library(reshape2) # for melt
#' em <- melt(economics, id = "date")
-#'
+#'
#' # Then we can group and facet by the new "variable" variable
#' qplot(date, value, data = em, geom = "line", group = variable)
-#' qplot(date, value, data = em, geom = "line", group = variable) +
+#' qplot(date, value, data = em, geom = "line", group = variable) +
#' facet_grid(variable ~ ., scale = "free_y")
scale_x_date <- function(..., expand = waiver(), breaks = pretty_breaks(),
minor_breaks = waiver()) {
-
+
scale_date(c("x", "xmin", "xmax", "xend"), expand = expand, breaks = breaks,
minor_breaks = minor_breaks, ...)
}
@@ -95,18 +95,18 @@ scale_date <- function(aesthetics, expand = waiver(), breaks = pretty_breaks(),
breaks_str <- breaks
breaks <- date_breaks(breaks_str)
}
-
+
if (is.character(minor_breaks)) {
mbreaks_str <- minor_breaks
minor_breaks <- date_breaks(mbreaks_str)
}
-
+
continuous_scale(aesthetics, "date", identity, breaks = breaks,
minor_breaks = minor_breaks, guide = "none", expand = expand,
trans = "date", ...)
}
-#' @S3method scale_map date
+#' @export
scale_map.date <- function(scale, x, limits = scale_limits(scale)) {
x
}
diff --git a/R/scale-datetime.r b/R/scale-datetime.r
index 481dc5c..1283114 100644
--- a/R/scale-datetime.r
+++ b/R/scale-datetime.r
@@ -7,12 +7,12 @@
#' returns a vector of breaks, or a character vector, specifying the width
#' between breaks. For more information about the first two, see
#' \code{\link{continuous_scale}}, for more information about the last,
-#' see \code{\link[scales]{date_breaks}}`.
+#' see \code{\link[scales]{date_breaks}}.
#' @param minor_breaks Either \code{NULL} for no minor breaks, \code{waiver()}
-#' for the default breaks (one minor break between each major break), a
+#' for the default breaks (one minor break between each major break), a
#' numeric vector of positions, or a function that given the limits returns
#' a vector of minor breaks.
-#' @export
+#' @export
#' @examples
#' start <- ISOdate(2001, 1, 1, tz = "")
#' df <- data.frame(
@@ -28,7 +28,7 @@
#' sec10 = start + round(runif(100, max = 10)),
#' y = runif(100)
#' )
-#'
+#'
#' # Automatic scale selection
#' qplot(sec10, y, data = df)
#' qplot(min, y, data = df)
@@ -39,34 +39,34 @@
#' qplot(hour10, y, data = df)
#' qplot(day, y, data = df)
#' qplot(day30, y, data = df)
-#'
+#'
#' # Manual scale selection
#' qplot(day30, y, data = df)
#' library(scales) # to access breaks/formatting functions
#' last_plot() + scale_x_datetime(breaks = date_breaks("2 weeks"))
#' last_plot() + scale_x_datetime(breaks = date_breaks("10 days"))
#' library(scales) # to access breaks/formatting functions
-#' last_plot() + scale_x_datetime(breaks = date_breaks("10 days"),
+#' last_plot() + scale_x_datetime(breaks = date_breaks("10 days"),
#' labels = date_format("%d/%m"))
#' last_plot() + scale_x_datetime(breaks = date_breaks("1 day"),
#' minor_breaks = date_breaks("2 hour"))
scale_x_datetime <- function(..., expand = waiver(), breaks = pretty_breaks(),
minor_breaks = waiver()) {
-
+
scale_datetime(c("x", "xmin", "xmax", "xend"), expand = expand,
breaks = breaks, minor_breaks = minor_breaks, ...)
}
-#' @S3method scale_map datetime
+#' @export
scale_map.datetime <- function(scale, x, limits = scale_limits(scale)) {
x
}
#' @rdname scale_datetime
-#' @export
+#' @export
scale_y_datetime <- function(..., expand = waiver(), breaks = pretty_breaks(),
minor_breaks = waiver()) {
-
+
scale_datetime(c("y", "ymin", "ymax", "yend"), expand = expand,
breaks = breaks, minor_breaks = minor_breaks, ...)
}
@@ -80,12 +80,12 @@ scale_datetime <- function(aesthetics, expand = waiver(), breaks = pretty_breaks
breaks_str <- breaks
breaks <- date_breaks(breaks_str)
}
-
+
if (is.character(minor_breaks)) {
mbreaks_str <- minor_breaks
minor_breaks <- date_breaks(mbreaks_str)
}
-
+
continuous_scale(aesthetics, "datetime", identity, breaks = breaks,
minor_breaks = minor_breaks, guide = "none", expand = expand,
trans = "time", ...)
diff --git a/R/scale-discrete-.r b/R/scale-discrete-.r
index 1b51077..393e52d 100644
--- a/R/scale-discrete-.r
+++ b/R/scale-discrete-.r
@@ -1,17 +1,17 @@
#' Discrete position.
#'
-#' You can use continuous positions even with a discrete position scale -
+#' You can use continuous positions even with a discrete position scale -
#' this allows you (e.g.) to place labels between bars in a bar chart.
#' Continuous positions are numeric values starting at one for the first
#' level, and increasing by one for each level (i.e. the labels are placed
#' at integer positions). This is what allows jittering to work.
#'
-#'
+#'
#' @param ... common discrete scale parameters: \code{name}, \code{breaks},
#' \code{labels}, \code{na.value}, \code{limits} and \code{guide}. See
#' \code{\link{discrete_scale}} for more details
-#' @param expand a numeric vector of length two giving multiplicative and
-#' additive expansion constants. These constants ensure that the data is
+#' @param expand a numeric vector of length two giving multiplicative and
+#' additive expansion constants. These constants ensure that the data is
#' placed some distance away from the axes.
#' @rdname scale_discrete
#' @family position scales
@@ -20,50 +20,50 @@
#' \donttest{
#' qplot(cut, data=diamonds, stat="bin")
#' qplot(cut, data=diamonds, geom="bar")
-#'
+#'
#' # The discrete position scale is added automatically whenever you
#' # have a discrete position.
-#'
+#'
#' (d <- qplot(cut, clarity, data=subset(diamonds, carat > 1), geom="jitter"))
-#'
+#'
#' d + scale_x_discrete("Cut")
#' d + scale_x_discrete("Cut", labels = c("Fair" = "F","Good" = "G",
#' "Very Good" = "VG","Perfect" = "P","Ideal" = "I"))
-#'
+#'
#' d + scale_y_discrete("Clarity")
#' d + scale_x_discrete("Cut") + scale_y_discrete("Clarity")
-#'
+#'
#' # Use limits to adjust the which levels (and in what order)
#' # are displayed
#' d + scale_x_discrete(limits=c("Fair","Ideal"))
-#'
+#'
#' # you can also use the short hand functions xlim and ylim
#' d + xlim("Fair","Ideal", "Good")
#' d + ylim("I1", "IF")
-#'
+#'
#' # See ?reorder to reorder based on the values of another variable
#' qplot(manufacturer, cty, data=mpg)
#' qplot(reorder(manufacturer, cty), cty, data=mpg)
#' qplot(reorder(manufacturer, displ), cty, data=mpg)
-#'
+#'
#' # Use abbreviate as a formatter to reduce long names
-#' qplot(reorder(manufacturer, cty), cty, data=mpg) +
+#' qplot(reorder(manufacturer, cty), cty, data=mpg) +
#' scale_x_discrete(labels = abbreviate)
#' }
scale_x_discrete <- function(..., expand = waiver()) {
- sc <- discrete_scale(c("x", "xmin", "xmax", "xend"), "position_d", identity, ...,
+ sc <- discrete_scale(c("x", "xmin", "xmax", "xend"), "position_d", identity, ...,
expand = expand, guide = "none")
-
+
sc$range_c <- ContinuousRange$new()
sc
}
#' @rdname scale_discrete
#' @export
scale_y_discrete <- function(..., expand = waiver()) {
- sc <- discrete_scale(c("y", "ymin", "ymax", "yend"), "position_d", identity, ...,
+ sc <- discrete_scale(c("y", "ymin", "ymax", "yend"), "position_d", identity, ...,
expand = expand, guide = "none")
sc$range_c <- ContinuousRange$new()
- sc
+ sc
}
# The discrete position scale maintains two separate ranges - one for
@@ -71,7 +71,7 @@ scale_y_discrete <- function(..., expand = waiver()) {
# mapping, but makes it possible to place objects at non-integer positions,
# as is necessary for jittering etc.
-#' @S3method scale_train position_d
+#' @export
scale_train.position_d <- function(scale, x) {
if (is.discrete(x)) {
scale$range$train(x, drop = scale$drop)
@@ -82,26 +82,26 @@ scale_train.position_d <- function(scale, x) {
# If range not available from discrete range, implies discrete scale been
# used with purely continuous data, so construct limits accordingly
-#' @S3method scale_limits position_d
+#' @export
scale_limits.position_d <- function(scale) {
dis_limits <- function(x) seq.int(floor(min(x)), ceiling(max(x)), by = 1L)
-
+
scale$limits %||% scale$range$range %||% dis_limits(scale$range_c$range)
}
-#' @S3method scale_is_empty position_d
+#' @export
scale_is_empty.position_d <- function(scale) {
NextMethod() && is.null(scale$range_c$range)
}
-#' @S3method scale_reset position_d
+#' @export
scale_reset.position_d <- function(scale, x) {
# Can't reset discrete scale because no way to recover values
scale$range_c$reset()
}
-#' @S3method scale_map position_d
+#' @export
scale_map.position_d <- function(scale, x, limits = scale_limits(scale)) {
if (is.discrete(x)) {
seq_along(limits)[match(as.character(x), limits)]
@@ -110,22 +110,22 @@ scale_map.position_d <- function(scale, x, limits = scale_limits(scale)) {
}
}
-#' @S3method scale_dimension position_d
+#' @export
scale_dimension.position_d <- function(scale, expand = scale$expand) {
if(is.waive(expand))
expand <- c(0, 0)
disc_range <- c(1, length(scale_limits(scale)))
disc <- expand_range(disc_range, 0, expand[2], 1)
cont <- expand_range(scale$range_c$range, expand[1], 0, expand[2])
-
+
range(disc, cont)
}
-#' @S3method scale_clone position_d
+#' @export
scale_clone.position_d <- function(scale) {
new <- scale
- new$range <- DiscreteRange$new()
- new$range_c <- ContinuousRange$new()
-
+ new$range <- DiscreteRange$new()
+ new$range_c <- ContinuousRange$new()
+
new
}
diff --git a/R/scale-gradient.r b/R/scale-gradient.r
index d0c4e36..b13dd0a 100644
--- a/R/scale-gradient.r
+++ b/R/scale-gradient.r
@@ -1,6 +1,6 @@
#' Smooth gradient between two colours
#'
-#' Default colours are generated with \pkg{munsell} and
+#' Default colours are generated with \pkg{munsell} and
#' \code{mnsl(c("2.5PB 2/4", "2.5PB 7/10")}. Generally, for continuous
#' colour scales you want to keep hue constant, but vary chroma and
#' luminance. The \pkg{munsell} package makes this easy to do using the
@@ -17,36 +17,36 @@
#' @export
#' @examples
#' \donttest{
-#' # It's hard to see, but look for the bright yellow dot
+#' # It's hard to see, but look for the bright yellow dot
#' # in the bottom right hand corner
#' dsub <- subset(diamonds, x > 5 & x < 6 & y > 5 & y < 6)
#' (d <- qplot(x, y, data=dsub, colour=z))
#' # That one point throws our entire scale off. We could
#' # remove it, or manually tweak the limits of the scale
-#'
-#' # Tweak scale limits. Any points outside these limits will not be
+#'
+#' # Tweak scale limits. Any points outside these limits will not be
#' # plotted, and will not affect the calculation of statistics, etc
#' d + scale_colour_gradient(limits=c(3, 10))
#' d + scale_colour_gradient(limits=c(3, 4))
#' # Setting the limits manually is also useful when producing
#' # multiple plots that need to be comparable
-#'
+#'
#' # Alternatively we could try transforming the scale:
#' d + scale_colour_gradient(trans = "log")
#' d + scale_colour_gradient(trans = "sqrt")
-#'
+#'
#' # Other more trivial manipulations, including changing the name
#' # of the scale and the colours.
#'
#' d + scale_colour_gradient("Depth")
#' d + scale_colour_gradient(expression(Depth[mm]))
-#'
+#'
#' d + scale_colour_gradient(limits=c(3, 4), low="red")
#' d + scale_colour_gradient(limits=c(3, 4), low="red", high="white")
#' # Much slower
#' d + scale_colour_gradient(limits=c(3, 4), low="red", high="white", space="Lab")
#' d + scale_colour_gradient(limits=c(3, 4), space="Lab")
-#'
+#'
#' # scale_fill_continuous works similarly, but for fill colours
#' (h <- qplot(x - y, data=dsub, geom="histogram", binwidth=0.01, fill=..count..))
#' h + scale_fill_continuous(low="black", high="pink", limits=c(0,3100))
@@ -54,7 +54,7 @@
#' # Colour of missing values is controlled with na.value:
#' miss <- sample(c(NA, 1:5), nrow(mtcars), rep = TRUE)
#' qplot(mpg, wt, data = mtcars, colour = miss)
-#' qplot(mpg, wt, data = mtcars, colour = miss) +
+#' qplot(mpg, wt, data = mtcars, colour = miss) +
#' scale_colour_gradient(na.value = "black")
#' }
scale_colour_gradient <- function(..., low = "#132B43", high = "#56B1F7", space = "Lab", na.value = "grey50", guide = "colourbar") {
diff --git a/R/scale-gradient2.r b/R/scale-gradient2.r
index f6d538e..33d090c 100644
--- a/R/scale-gradient2.r
+++ b/R/scale-gradient2.r
@@ -1,8 +1,8 @@
#' Diverging colour gradient
-#'
+#'
#' @inheritParams scale_colour_hue
#' @inheritParams scales::div_gradient_pal
-#' @param midpoint The midpoint (in data value) of the diverging scale.
+#' @param midpoint The midpoint (in data value) of the diverging scale.
#' Defaults to 0.
#' @param guide Type of legend. Use \code{"colourbar"} for continuous
#' colour bar, or \code{"legend"} for discrete colour legend.
@@ -14,38 +14,39 @@
#' dsub <- subset(diamonds, x > 5 & x < 6 & y > 5 & y < 6)
#' dsub$diff <- with(dsub, sqrt(abs(x-y))* sign(x-y))
#' (d <- qplot(x, y, data=dsub, colour=diff))
-#'
+#'
#' d + scale_colour_gradient2()
#' # Change scale name
#' d + scale_colour_gradient2(expression(sqrt(abs(x - y))))
#' d + scale_colour_gradient2("Difference\nbetween\nwidth and\nheight")
-#'
+#'
#' # Change limits and colours
#' d + scale_colour_gradient2(limits=c(-0.2, 0.2))
-#'
-#' # Using "muted" colours makes for pleasant graphics
+#'
+#' # Using "muted" colours makes for pleasant graphics
#' # (and they have better perceptual properties too)
#' library(scales) # for muted
#' d + scale_colour_gradient2(low="red", high="blue")
#' d + scale_colour_gradient2(low=muted("red"), high=muted("blue"))
-#'
+#'
#' # Using the Lab colour space also improves perceptual properties
#' # at the price of slightly slower operation
#' d + scale_colour_gradient2(space="Lab")
-#'
+#'
#' # About 5% of males are red-green colour blind, so it's a good
#' # idea to avoid that combination
#' d + scale_colour_gradient2(high=muted("green"))
-#'
+#'
#' # We can also make the middle stand out
#' d + scale_colour_gradient2(mid=muted("green"), high="white", low="white")
-#'
+#'
#' # or use a non zero mid point
#' (d <- qplot(carat, price, data=diamonds, colour=price/carat))
#' d + scale_colour_gradient2(midpoint=mean(diamonds$price / diamonds$carat))
-#'
+#'
#' # Fill gradients work much the same way
-#' p <- qplot(letters[1:5], 1:5, fill= c(-3, 3, 5, 2, -2), geom="bar")
+#' p <- qplot(letters[1:5], 1:5, fill= c(-3, 3, 5, 2, -2), geom = "bar",
+#' stat = "identity")
#' p + scale_fill_gradient2("fill")
#' # Note how positive and negative values of the same magnitude
#' # have similar intensity
@@ -59,7 +60,7 @@ scale_colour_gradient2 <- function(..., low = muted("red"), mid = "white", high
#' @rdname scale_gradient2
#' @export
scale_fill_gradient2 <- function(..., low = muted("red"), mid = "white", high = muted("blue"), midpoint = 0, space = "rgb", na.value = "grey50", guide = "colourbar") {
- continuous_scale("fill", "gradient2",
+ continuous_scale("fill", "gradient2",
div_gradient_pal(low, mid, high, space), na.value = na.value, guide = guide, ...,
rescaler = mid_rescaler(mid = midpoint))
}
diff --git a/R/scale-gradientn.r b/R/scale-gradientn.r
index ed85b7a..067de17 100644
--- a/R/scale-gradientn.r
+++ b/R/scale-gradientn.r
@@ -1,5 +1,5 @@
#' Smooth colour gradient between n colours
-#'
+#'
#' @inheritParams scales::gradient_n_pal
#' @inheritParams scale_colour_hue
#' @param guide Type of legend. Use \code{"colourbar"} for continuous
@@ -10,31 +10,31 @@
#' @examples
#' \donttest{
#' # scale_colour_gradient make it easy to use existing colour palettes
-#'
+#'
#' dsub <- subset(diamonds, x > 5 & x < 6 & y > 5 & y < 6)
#' dsub$diff <- with(dsub, sqrt(abs(x-y))* sign(x-y))
#' (d <- qplot(x, y, data=dsub, colour=diff))
-#'
+#'
#' d + scale_colour_gradientn(colours = rainbow(7))
#' breaks <- c(-0.5, 0, 0.5)
-#' d + scale_colour_gradientn(colours = rainbow(7),
+#' d + scale_colour_gradientn(colours = rainbow(7),
#' breaks = breaks, labels = format(breaks))
-#'
+#'
#' d + scale_colour_gradientn(colours = topo.colors(10))
#' d + scale_colour_gradientn(colours = terrain.colors(10))
-#'
-#' # You can force them to be symmetric by supplying a vector of
+#'
+#' # You can force them to be symmetric by supplying a vector of
#' # values, and turning rescaling off
#' max_val <- max(abs(dsub$diff))
#' values <- seq(-max_val, max_val, length = 11)
-#'
-#' d + scale_colour_gradientn(colours = topo.colors(10),
+#'
+#' d + scale_colour_gradientn(colours = topo.colors(10),
#' values = values, rescaler = function(x, ...) x, oob = identity)
-#' d + scale_colour_gradientn(colours = terrain.colors(10),
+#' d + scale_colour_gradientn(colours = terrain.colors(10),
#' values = values, rescaler = function(x, ...) x, oob = identity)
#' }
scale_colour_gradientn <- function(..., colours, values = NULL, space = "Lab", na.value = "grey50", guide = "colourbar") {
- continuous_scale("colour", "gradientn",
+ continuous_scale("colour", "gradientn",
gradient_n_pal(colours, values, space), na.value = na.value, guide = guide, ...)
}
#' @rdname scale_gradientn
diff --git a/R/scale-grey.r b/R/scale-grey.r
index e999ca6..b1c0c3f 100644
--- a/R/scale-grey.r
+++ b/R/scale-grey.r
@@ -8,26 +8,26 @@
#' @rdname scale_grey
#' @export
#' @examples
-#' p <- qplot(mpg, wt, data=mtcars, colour=factor(cyl))
+#' p <- qplot(mpg, wt, data=mtcars, colour=factor(cyl))
#' p + scale_colour_grey()
#' p + scale_colour_grey(end = 0)
-#'
+#'
#' # You may want to turn off the pale grey background with this scale
#' p + scale_colour_grey() + theme_bw()
#'
#' # Colour of missing values is controlled with na.value:
#' miss <- factor(sample(c(NA, 1:5), nrow(mtcars), rep = TRUE))
#' qplot(mpg, wt, data = mtcars, colour = miss) + scale_colour_grey()
-#' qplot(mpg, wt, data = mtcars, colour = miss) +
+#' qplot(mpg, wt, data = mtcars, colour = miss) +
#' scale_colour_grey(na.value = "green")
scale_colour_grey <- function(..., start = 0.2, end = 0.8, na.value = "red") {
- discrete_scale("colour", "grey", grey_pal(start, end),
+ discrete_scale("colour", "grey", grey_pal(start, end),
na.value = na.value, ...)
}
#' @rdname scale_grey
#' @export
scale_fill_grey <- function(..., start = 0.2, end = 0.8, na.value = "grey50") {
- discrete_scale("fill", "grey", grey_pal(start, end),
+ discrete_scale("fill", "grey", grey_pal(start, end),
na.value = na.value, ...)
}
diff --git a/R/scale-hue.r b/R/scale-hue.r
index 6e2d5b9..483bd6d 100644
--- a/R/scale-hue.r
+++ b/R/scale-hue.r
@@ -1,7 +1,7 @@
#' Qualitative colour scale with evenly spaced hues.
-#'
+#'
#' @param na.value Colour to use for missing values
-#' @param ... Other arguments passed on to \code{\link{discrete_scale}}
+#' @param ... Other arguments passed on to \code{\link{discrete_scale}}
#' to control name, limits, breaks, labels and so forth.
#' @inheritParams scales::hue_pal
#' @rdname scale_hue
@@ -11,24 +11,24 @@
#' \donttest{
#' dsamp <- diamonds[sample(nrow(diamonds), 1000), ]
#' (d <- qplot(carat, price, data=dsamp, colour=clarity))
-#'
+#'
#' # Change scale label
#' d + scale_colour_hue()
#' d + scale_colour_hue("clarity")
#' d + scale_colour_hue(expression(clarity[beta]))
-#'
+#'
#' # Adjust luminosity and chroma
#' d + scale_colour_hue(l=40, c=30)
#' d + scale_colour_hue(l=70, c=30)
#' d + scale_colour_hue(l=70, c=150)
#' d + scale_colour_hue(l=80, c=150)
-#'
+#'
#' # Change range of hues used
#' d + scale_colour_hue(h=c(0, 90))
#' d + scale_colour_hue(h=c(90, 180))
#' d + scale_colour_hue(h=c(180, 270))
#' d + scale_colour_hue(h=c(270, 360))
-#'
+#'
#' # Vary opacity
#' # (only works with pdf, quartz and cairo devices)
#' d <- ggplot(dsamp, aes(carat, price, colour = clarity))
@@ -39,7 +39,7 @@
#' # Colour of missing values is controlled with na.value:
#' miss <- factor(sample(c(NA, 1:5), nrow(mtcars), rep = TRUE))
#' qplot(mpg, wt, data = mtcars, colour = miss)
-#' qplot(mpg, wt, data = mtcars, colour = miss) +
+#' qplot(mpg, wt, data = mtcars, colour = miss) +
#' scale_colour_hue(na.value = "black")
#' }
scale_colour_hue <- function(..., h = c(0, 360) + 15, c = 100, l = 65, h.start = 0, direction = 1, na.value = "grey50") {
@@ -50,6 +50,6 @@ scale_colour_hue <- function(..., h = c(0, 360) + 15, c = 100, l = 65, h.start =
#' @rdname scale_hue
#' @export
scale_fill_hue <- function(..., h = c(0, 360) + 15, c = 100, l = 65, h.start = 0, direction = 1, na.value = "grey50") {
- discrete_scale("fill", "hue", hue_pal(h, c, l, h.start, direction),
+ discrete_scale("fill", "hue", hue_pal(h, c, l, h.start, direction),
na.value = na.value, ...)
}
diff --git a/R/scale-identity.r b/R/scale-identity.r
index 7579edb..2e552ec 100644
--- a/R/scale-identity.r
+++ b/R/scale-identity.r
@@ -8,18 +8,18 @@
#' colour <- c("red", "green", "blue", "yellow")
#' qplot(1:4, 1:4, fill = colour, geom = "tile")
#' qplot(1:4, 1:4, fill = colour, geom = "tile") + scale_fill_identity()
-#'
+#'
#' # To get a legend guide, specify guide = "legend"
-#' qplot(1:4, 1:4, fill = colour, geom = "tile") +
+#' qplot(1:4, 1:4, fill = colour, geom = "tile") +
#' scale_fill_identity(guide = "legend")
#' # But you'll typically also need to supply breaks and labels:
-#' qplot(1:4, 1:4, fill = colour, geom = "tile") +
-#' scale_fill_identity("trt", labels = letters[1:4], breaks = colour,
+#' qplot(1:4, 1:4, fill = colour, geom = "tile") +
+#' scale_fill_identity("trt", labels = letters[1:4], breaks = colour,
#' guide = "legend")
-#'
+#'
#' # cyl scaled to appropriate size
#' qplot(mpg, wt, data = mtcars, size = cyl)
-#'
+#'
#' # cyl used as point size
#' qplot(mpg, wt, data = mtcars, size = cyl) + scale_size_identity()
NULL
@@ -34,7 +34,7 @@ scale_colour_identity <- function(..., guide = "none") {
#' @export
scale_fill_identity <- function(..., guide = "none") {
identity_scale(discrete_scale("fill", "identity", identity_pal(), ..., guide = guide))
-
+
}
#' @rdname scale_identity
@@ -47,14 +47,14 @@ scale_shape_identity <- function(..., guide = "none") {
#' @export
scale_linetype_identity <- function(..., guide = "none") {
identity_scale(discrete_scale("linetype", "identity", identity_pal(), ..., guide = guide))
-
+
}
#' @rdname scale_identity
#' @export
scale_alpha_identity <- function(..., guide = "none") {
identity_scale(continuous_scale("alpha", "identity", identity_pal(), ..., guide = guide))
-
+
}
#' @rdname scale_identity
@@ -67,7 +67,7 @@ identity_scale <- function(x) {
structure(x, class = c("identity", class(x)))
}
-#' @S3method scale_map identity
+#' @export
scale_map.identity <- function(scale, x) {
if (is.factor(x)) {
as.character(x)
@@ -75,7 +75,7 @@ scale_map.identity <- function(scale, x) {
x
}
}
-#' @S3method scale_train identity
+#' @export
scale_train.identity <- function(scale, x) {
# do nothing if no guide, otherwise train so we know what breaks to use
if (scale$guide == "none") return()
diff --git a/R/scale-linetype.r b/R/scale-linetype.r
index 0570488..cc6d195 100644
--- a/R/scale-linetype.r
+++ b/R/scale-linetype.r
@@ -1,6 +1,6 @@
#' Scale for line patterns.
-#'
-#' Default line types based on a set supplied by Richard Pearson,
+#'
+#' Default line types based on a set supplied by Richard Pearson,
#' University of Manchester. Line types can not be mapped to continuous
#' values.
#'
@@ -14,11 +14,11 @@
#' ecm <- melt(economics, id = "date")
#' rescale01 <- function(x) (x - min(x)) / diff(range(x))
#' ecm <- ddply(ecm, "variable", transform, value = rescale01(value))
-#'
+#'
#' qplot(date, value, data=ecm, geom="line", group=variable)
#' qplot(date, value, data=ecm, geom="line", linetype=variable)
#' qplot(date, value, data=ecm, geom="line", colour=variable)
-#'
+#'
#' # See scale_manual for more flexibility
scale_linetype <- function(..., na.value = "blank") {
discrete_scale("linetype", "linetype_d", linetype_pal(),
diff --git a/R/scale-manual.r b/R/scale-manual.r
index b1bc736..00ecf71 100644
--- a/R/scale-manual.r
+++ b/R/scale-manual.r
@@ -1,5 +1,5 @@
#' Create your own discrete scale.
-#'
+#'
#' @name scale_manual
#' @inheritParams scale_x_discrete
#' @param values a set of aesthetic values to map data values to. If this
@@ -10,13 +10,13 @@
#' @examples
#' \donttest{
#' p <- qplot(mpg, wt, data = mtcars, colour = factor(cyl))
-#'
+#'
#' p + scale_colour_manual(values = c("red","blue", "green"))
#' p + scale_colour_manual(
#' values = c("8" = "red","4" = "blue","6" = "green"))
#' # With rgb hex values
#' p + scale_colour_manual(values = c("#FF0000", "#0000FF", "#00FF00"))
-#'
+#'
#' # As with other scales you can use breaks to control the appearance
#' # of the legend
#' cols <- c("8" = "red","4" = "blue","6" = "darkgreen", "10" = "orange")
@@ -25,7 +25,7 @@
#' p + scale_colour_manual(values = cols, breaks = c("8", "6", "4"))
#' p + scale_colour_manual(values = cols, breaks = c("4", "6", "8"),
#' labels = c("four", "six", "eight"))
-#'
+#'
#' # And limits to control the possible values of the scale
#' p + scale_colour_manual(values = cols, limits = c("4", "8"))
#' p + scale_colour_manual(values = cols, limits = c("4", "6", "8", "10"))
@@ -76,7 +76,7 @@ scale_alpha_manual <- function(..., values) {
manual_scale <- function(aesthetic, values, ...) {
pal <- function(n) {
if (n > length(values)) {
- stop("Insufficient values in manual scale. ", n, " needed but only ",
+ stop("Insufficient values in manual scale. ", n, " needed but only ",
length(values), " provided.", call. = FALSE)
}
values
diff --git a/R/scale-shape.r b/R/scale-shape.r
index 20780d7..3caf122 100644
--- a/R/scale-shape.r
+++ b/R/scale-shape.r
@@ -1,27 +1,27 @@
#' Scale for shapes, aka glyphs.
-#'
+#'
#' A continuous variable can not be mapped to shape.
#'
-#' @param solid Are the shapes solid, \code{TRUE}, or hollow \code{FALSE}?
+#' @param solid Are the shapes solid, \code{TRUE}, or hollow \code{FALSE}?
#' @inheritParams scale_x_discrete
#' @rdname scale_shape
#' @export
#' @examples
#' dsmall <- diamonds[sample(nrow(diamonds), 100), ]
-#'
+#'
#' (d <- qplot(carat, price, data=dsmall, shape=cut))
#' d + scale_shape(solid = TRUE) # the default
#' d + scale_shape(solid = FALSE)
#' d + scale_shape(name="Cut of diamond")
#' d + scale_shape(name="Cut of\ndiamond")
-#'
-#' # To change order of levels, change order of
+#'
+#' # To change order of levels, change order of
#' # underlying factor
#' levels(dsmall$cut) <- c("Fair", "Good", "Very Good", "Premium", "Ideal")
-#'
+#'
#' # Need to recreate plot to pick up new data
#' qplot(price, carat, data=dsmall, shape=cut)
-#'
+#'
#' # Or for short:
#' d %+% dsmall
scale_shape <- function(..., solid = TRUE) {
diff --git a/R/scale-size.r b/R/scale-size.r
index cb5e3ef..d753d86 100644
--- a/R/scale-size.r
+++ b/R/scale-size.r
@@ -1,5 +1,5 @@
#' Size scale.
-#'
+#'
#' @name scale_size
#' @inheritParams scale_x_continuous
#' @param range a numeric vector of length 2 that specifies the minimum and
@@ -9,20 +9,20 @@
#' (p <- qplot(mpg, cyl, data=mtcars, size=cyl))
#' p + scale_size("cylinders")
#' p + scale_size("number\nof\ncylinders")
-#'
+#'
#' p + scale_size(range = c(0, 10))
#' p + scale_size(range = c(1, 2))
-#'
+#'
#' # Map area, instead of width/radius
#' # Perceptually, this is a little better
-#' p + scale_area()
-#' p + scale_area(range = c(1, 25))
-#'
+#' p + scale_size_area()
+#' p + scale_size_area(max_size = 25)
+#'
#' # Also works with factors, but not a terribly good
#' # idea, unless your factor is ordered, as in this example
#' qplot(mpg, cyl, data=mtcars, size=factor(cyl))
-#'
-#' # To control the size mapping for discrete variable, use
+#'
+#' # To control the size mapping for discrete variable, use
#' # scale_size_manual:
#' last_plot() + scale_size_manual(values=c(2,4,6))
#' }
diff --git a/R/scales-.r b/R/scales-.r
index 494272c..792a302 100644
--- a/R/scales-.r
+++ b/R/scales-.r
@@ -1,7 +1,8 @@
# Scales object encapsultes multiple scales.
-# All input and output done with data.frames to facilitate
+# All input and output done with data.frames to facilitate
# multiple input and output variables
+#' @importFrom methods setRefClass
Scales <- setRefClass("Scales", fields = "scales", methods = list(
find = function(aesthetic) {
vapply(scales, function(x) any(aesthetic %in% x$aesthetics), logical(1))
@@ -22,7 +23,7 @@ Scales <- setRefClass("Scales", fields = "scales", methods = list(
# Remove old scale for this aesthetic (if it exists)
scales <<- c(scales[!prev_aes], list(scale))
- },
+ },
clone = function() {
new_scales <- lapply(scales, scale_clone)
Scales$new(new_scales)
@@ -32,7 +33,7 @@ Scales <- setRefClass("Scales", fields = "scales", methods = list(
},
input = function() {
unlist(lapply(scales, "[[", "aesthetics"))
- },
+ },
initialize = function(scales = NULL) {
initFields(scales = scales)
},
@@ -43,7 +44,7 @@ Scales <- setRefClass("Scales", fields = "scales", methods = list(
scale <- scales[find(output)]
if (length(scale) == 0) return()
scale[[1]]
- }
+ }
))
# Train scale from a data frame
@@ -55,17 +56,17 @@ scales_train_df <- function(scales, df, drop = FALSE) {
# Map values from a data.frame. Returns data.frame
scales_map_df <- function(scales, df) {
- if (empty(df) || length(scales$scales) == 0) return()
-
+ if (empty(df) || length(scales$scales) == 0) return(df)
+
mapped <- unlist(lapply(scales$scales, scale_map_df, df = df), recursive = FALSE)
-
+
quickdf(c(mapped, df[setdiff(names(df), names(mapped))]))
}
# Transform values to cardinal representation
scales_transform_df <- function(scales, df) {
if (empty(df) || length(scales$scales) == 0) return(df)
-
+
transformed <- unlist(lapply(scales$scales, scale_transform_df, df = df),
recursive = FALSE)
quickdf(c(transformed, df[setdiff(names(df), names(transformed))]))
@@ -76,13 +77,13 @@ scales_transform_df <- function(scales, df) {
scales_add_defaults <- function(scales, data, aesthetics, env) {
if (is.null(aesthetics)) return()
names(aesthetics) <- unlist(lapply(names(aesthetics), aes_to_scale))
-
+
new_aesthetics <- setdiff(names(aesthetics), scales$input())
# No new aesthetics, so no new scales to add
if (is.null(new_aesthetics)) return()
-
+
datacols <- tryapply(
- aesthetics[new_aesthetics], eval,
+ aesthetics[new_aesthetics], eval,
envir = data, enclos = env
)
@@ -91,12 +92,12 @@ scales_add_defaults <- function(scales, data, aesthetics, env) {
scale_name <- paste("scale", aes, type, sep="_")
# Skip aesthetics with no scales (e.g. group, order, etc)
- scale_f <- find_global(scale_name, env)
+ scale_f <- find_global(scale_name, env, mode = "function")
if (is.null(scale_f)) next
scales$add(scale_f())
}
-
+
}
# Add missing but required scales.
@@ -109,25 +110,25 @@ scales_add_missing <- function(plot, aesthetics, env) {
for (aes in aesthetics) {
scale_name <- paste("scale", aes, "continuous", sep="_")
- scale_f <- find_global(scale_name, env)
+ scale_f <- find_global(scale_name, env, mode = "function")
plot$scales$add(scale_f())
}
}
-# Look for object first in parent environment and if not found, then in
+# Look for object first in parent environment and if not found, then in
# ggplot2 namespace environment. This makes it possible to override default
# scales by setting them in the parent environment.
-find_global <- function(name, env) {
- if (exists(name, env)) {
- return(get(name, env))
+find_global <- function(name, env, mode = "any") {
+ if (exists(name, envir = env, mode = mode)) {
+ return(get(name, envir = env, mode = mode))
}
nsenv <- asNamespace("ggplot2")
- if (exists(name, nsenv)) {
- return(get(name, nsenv))
+ if (exists(name, envir = nsenv, mode = mode)) {
+ return(get(name, envir = nsenv, mode = mode))
}
-
+
NULL
}
@@ -135,27 +136,27 @@ find_global <- function(name, env) {
# Determine default type of a scale
scale_type <- function(x) UseMethod("scale_type")
-#' @S3method scale_type default
+#' @export
scale_type.default <- function(x) {
message("Don't know how to automatically pick scale for object of type ",
paste(class(x), collapse = "/"), ". Defaulting to continuous")
"continuous"
}
-#' @S3method scale_type logical
+#' @export
scale_type.logical <- function(x) "discrete"
-#' @S3method scale_type character
+#' @export
scale_type.character <- function(x) "discrete"
-#' @S3method scale_type factor
+#' @export
scale_type.factor <- function(x) "discrete"
-#' @S3method scale_type POSIXt
+#' @export
scale_type.POSIXt <- function(x) "datetime"
-#' @S3method scale_type Date
+#' @export
scale_type.Date <- function(x) "date"
-#' @S3method scale_type numeric
+#' @export
scale_type.numeric <- function(x) "continuous"
diff --git a/R/stat-.r b/R/stat-.r
index 525db8d..3ea4b43 100644
--- a/R/stat-.r
+++ b/R/stat-.r
@@ -1,48 +1,48 @@
Stat <- proto(TopLevel, expr={
- objname <- ""
+ objname <- ""
desc <- ""
# Should the values produced by the statistic also be transformed
- # in the second pass when recently added statistics are trained to
+ # in the second pass when recently added statistics are trained to
# the scales
retransform <- TRUE
-
+
default_geom <- function(.) Geom
default_aes <- function(.) aes()
default_pos <- function(.) .$default_geom()$default_pos()
required_aes <- c()
-
+
aesthetics <- list()
calculate <- function(., data, scales, ...) {}
calculate_groups <- function(., data, scales, ...) {
if (empty(data)) return(data.frame())
-
+
force(data)
force(scales)
# # Alternative approach: cleaner, but much slower
# # Compute statistic for each group
# stats <- ddply(data, "group", function(group) {
- # .$calculate(group, scales, ...)
+ # .$calculate(group, scales, ...)
# })
# stats$ORDER <- seq_len(nrow(stats))
- #
+ #
# # Combine statistics with original columns
# unique <- ddply(data, .(group), uniquecols)
# stats <- merge(stats, unique, by = "group")
# stats[stats$ORDER, ]
-
+
groups <- split(data, data$group)
- stats <- lapply(groups, function(group)
+ stats <- lapply(groups, function(group)
.$calculate(data = group, scales = scales, ...))
-
+
stats <- mapply(function(new, old) {
if (empty(new)) return(data.frame())
unique <- uniquecols(old)
missing <- !(names(unique) %in% names(new))
cbind(
- new,
+ new,
unique[rep(1, nrow(new)), missing,drop=FALSE]
)
}, stats, groups, SIMPLIFY=FALSE)
@@ -55,14 +55,14 @@ Stat <- proto(TopLevel, expr={
cat("stat_", .$objname ,": ", sep="") # , clist(.$parameters())
if (newline) cat("\n")
}
-
+
parameters <- function(.) {
params <- formals(get("calculate", .))
params[setdiff(names(params), c(".","data","scales"))]
}
-
+
class <- function(.) "stat"
-
+
new <- function(., mapping=aes(), data=NULL, geom=NULL, position=NULL, ...){
do.call("layer", list(mapping=mapping, data=data, geom=geom, stat=., position=position, ...))
}
diff --git a/R/stat-bin.r b/R/stat-bin.r
index e7bbaca..3b26f2c 100644
--- a/R/stat-bin.r
+++ b/R/stat-bin.r
@@ -1,18 +1,18 @@
#' Bin data.
-#'
+#'
#' Missing values are currently silently dropped.
#'
-#' @section Aesthetics:
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat", "bin")}
#'
#' @inheritParams stat_identity
#' @param binwidth Bin width to use. Defaults to 1/30 of the range of the
#' data
-#' @param breaks Actual breaks to use. Overrides bin width and origin
-#' @param origin Origin of first bin
-#' @param width Width of bars when used with categorical data
-#' @param right If \code{TRUE}, right-closed, left-open, if \code{FALSE},
-#" the default, right-open, left-closed.
+#' @param breaks Actual breaks to use. Overrides bin width and origin
+#' @param origin Origin of first bin
+#' @param width Width of bars when used with categorical data
+#' @param right If \code{TRUE}, right-closed, left-open, if \code{FALSE},
+#' the default, right-open, left-closed.
#' @param drop If TRUE, remove all bins with zero counts
#' @return New data frame with additional columns:
#' \item{count}{number of points in bin}
@@ -24,36 +24,36 @@
#' \donttest{
#' simple <- data.frame(x = rep(1:10, each = 2))
#' base <- ggplot(simple, aes(x))
-#' # By default, right = TRUE, and intervals are of the form (a, b]
-#' base + stat_bin(binwidth = 1, drop = FALSE, right = TRUE, col = "black")
-#' # If right = FALSE intervals are of the form [a, b)
+#' # By default, right = FALSE intervals are of the form [a, b)
#' base + stat_bin(binwidth = 1, drop = FALSE, right = FALSE, col = "black")
-#'
+#' # If right = TRUE, and intervals are of the form (a, b]
+#' base + stat_bin(binwidth = 1, drop = FALSE, right = TRUE, col = "black")
+#'
#' m <- ggplot(movies, aes(x=rating))
#' m + stat_bin()
#' m + stat_bin(binwidth=0.1)
#' m + stat_bin(breaks=seq(4,6, by=0.1))
#' # See geom_histogram for more histogram examples
-#'
+#'
#' # To create a unit area histogram, use aes(y = ..density..)
#' (linehist <- m + stat_bin(aes(y = ..density..), binwidth=0.1,
#' geom="line", position="identity"))
#' linehist + stat_density(colour="blue", fill=NA)
-#'
+#'
#' # Also works with categorical variables
#' ggplot(movies, aes(x=mpaa)) + stat_bin()
#' qplot(mpaa, data=movies, stat="bin")
#' }
-stat_bin <- function (mapping = NULL, data = NULL, geom = "bar", position = "stack",
-width = 0.9, drop = FALSE, right = FALSE, binwidth = NULL, origin = NULL, breaks = NULL, ...) {
- StatBin$new(mapping = mapping, data = data, geom = geom, position = position,
+stat_bin <- function (mapping = NULL, data = NULL, geom = "bar", position = "stack",
+width = 0.9, drop = FALSE, right = FALSE, binwidth = NULL, origin = NULL, breaks = NULL, ...) {
+ StatBin$new(mapping = mapping, data = data, geom = geom, position = position,
width = width, drop = drop, right = right, binwidth = binwidth, origin = origin, breaks = breaks, ...)
}
StatBin <- proto(Stat, {
objname <- "bin"
informed <- FALSE
-
+
calculate_groups <- function(., data, ...) {
if (!is.null(data$y) || !is.null(match.call()$y)) {
# Deprecate this behavior
@@ -69,7 +69,7 @@ StatBin <- proto(Stat, {
.$informed <- FALSE
.super$calculate_groups(., data, ...)
}
-
+
calculate <- function(., data, scales, binwidth=NULL, origin=NULL, breaks=NULL, width=0.9, drop = FALSE, right = FALSE, ...) {
range <- scale_dimension(scales$x, c(0, 0))
@@ -77,18 +77,18 @@ StatBin <- proto(Stat, {
message("stat_bin: binwidth defaulted to range/30. Use 'binwidth = x' to adjust this.")
.$informed <- TRUE
}
-
+
bin(data$x, data$weight, binwidth=binwidth, origin=origin, breaks=breaks, range=range, width=width, drop = drop, right = right)
}
default_aes <- function(.) aes(y = ..count..)
required_aes <- c("x")
default_geom <- function(.) GeomBar
-
+
})
bin <- function(x, weight=NULL, binwidth=NULL, origin=NULL, breaks=NULL, range=NULL, width=0.9, drop = FALSE, right = TRUE) {
-
+
if (length(na.omit(x)) == 0) return(data.frame())
if (is.null(weight)) weight <- rep(1, length(x))
weight[is.na(weight)] <- 0
@@ -99,29 +99,29 @@ bin <- function(x, weight=NULL, binwidth=NULL, origin=NULL, breaks=NULL, range=N
if (is.integer(x)) {
bins <- x
x <- sort(unique(bins))
- width <- width
+ width <- width
} else if (diff(range) == 0) {
width <- width
bins <- x
- } else { # if (is.numeric(x))
+ } else { # if (is.numeric(x))
if (is.null(breaks)) {
if (is.null(origin)) {
- breaks <- fullseq(range, binwidth, pad = TRUE)
+ breaks <- fullseq(range, binwidth, pad = TRUE)
} else {
breaks <- seq(origin, max(range) + binwidth, binwidth)
}
}
-
+
# Adapt break fuzziness from base::hist - this protects from floating
# point rounding errors
diddle <- 1e-07 * stats::median(diff(breaks))
if (right) {
fuzz <- c(-diddle, rep.int(diddle, length(breaks) - 1))
} else {
- fuzz <- c(rep.int(-diddle, length(breaks) - 1), diddle)
+ fuzz <- c(rep.int(-diddle, length(breaks) - 1), diddle)
}
fuzzybreaks <- sort(breaks) + fuzz
-
+
bins <- cut(x, fuzzybreaks, include.lowest=TRUE, right = right)
left <- breaks[-length(breaks)]
right <- breaks[-1]
@@ -134,11 +134,11 @@ bin <- function(x, weight=NULL, binwidth=NULL, origin=NULL, breaks=NULL, range=N
x = x,
width = width
)
-
+
if (sum(results$count, na.rm = TRUE) == 0) {
return(results)
}
-
+
res <- within(results, {
count[is.na(count)] <- 0
density <- count / width / sum(abs(count), na.rm=TRUE)
diff --git a/R/stat-bin2d.r b/R/stat-bin2d.r
index b9b34dc..ce0ad7c 100644
--- a/R/stat-bin2d.r
+++ b/R/stat-bin2d.r
@@ -1,10 +1,10 @@
#' Count number of observation in rectangular bins.
-#'
-#' @section Aesthetics:
+#'
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat", "bin2d")}
#'
#' @inheritParams stat_identity
-#' @param bins numeric vector giving number of bins in both vertical and
+#' @param bins numeric vector giving number of bins in both vertical and
#' horizontal directions. Set to 30 by default.
#' @param drop if \code{TRUE} removes all cells with 0 counts.
#' @seealso \code{\link{stat_binhex}} for hexagonal binning
@@ -14,31 +14,31 @@
#' d <- ggplot(diamonds, aes(carat, price))
#' d + stat_bin2d()
#' d + geom_bin2d()
-#'
+#'
#' # You can control the size of the bins by specifying the number of
#' # bins in each direction:
#' d + stat_bin2d(bins = 10)
#' d + stat_bin2d(bins = 30)
-#'
+#'
#' # Or by specifying the width of the bins
#' d + stat_bin2d(binwidth = c(1, 1000))
#' d + stat_bin2d(binwidth = c(.1, 500))
-#'
+#'
#' # Or with a list of breaks
#' x <- seq(min(diamonds$carat), max(diamonds$carat), by = 0.1)
#' y <- seq(min(diamonds$price), max(diamonds$price), length = 50)
#' d + stat_bin2d(breaks = list(x = x, y = y))
-#'
+#'
#' # With qplot
-#' qplot(x, y, data = diamonds, geom="bin2d",
+#' qplot(x, y, data = diamonds, geom="bin2d",
#' xlim = c(4, 10), ylim = c(4, 10))
#' qplot(x, y, data = diamonds, geom="bin2d", binwidth = c(0.1, 0.1),
#' xlim = c(4, 10), ylim = c(4, 10))
#' }
-stat_bin2d <- function (mapping = NULL, data = NULL, geom = NULL, position = "identity",
+stat_bin2d <- function (mapping = NULL, data = NULL, geom = NULL, position = "identity",
bins = 30, drop = TRUE, ...) {
-
- StatBin2d$new(mapping = mapping, data = data, geom = geom, position = position,
+
+ StatBin2d$new(mapping = mapping, data = data, geom = geom, position = position,
bins = bins, drop = drop, ...)
}
@@ -50,23 +50,23 @@ StatBin2d <- proto(Stat, {
default_geom <- function(.) GeomRect
calculate <- function(., data, scales, binwidth = NULL, bins = 30, breaks = NULL, origin = NULL, drop = TRUE, ...) {
-
+
range <- list(
x = scale_dimension(scales$x, c(0, 0)),
y = scale_dimension(scales$y, c(0, 0))
)
-
+
# Determine origin, if omitted
if (is.null(origin)) {
origin <- c(NA, NA)
} else {
stopifnot(is.numeric(origin))
stopifnot(length(origin) == 2)
- }
+ }
originf <- function(x) if (is.integer(x)) -0.5 else min(x, na.rm = TRUE)
if (is.na(origin[1])) origin[1] <- originf(data$x)
if (is.na(origin[2])) origin[2] <- originf(data$y)
-
+
# Determine binwidth, if omitted
if (is.null(binwidth)) {
binwidth <- c(NA, NA)
@@ -79,11 +79,11 @@ StatBin2d <- proto(Stat, {
binwidth[2] <- 1
} else {
binwidth[2] <- diff(range$y) / bins
- }
+ }
}
stopifnot(is.numeric(binwidth))
stopifnot(length(binwidth) == 2)
-
+
# Determine breaks, if omitted
if (is.null(breaks)) {
breaks <- list(
@@ -92,20 +92,20 @@ StatBin2d <- proto(Stat, {
)
} else {
stopifnot(is.list(breaks))
- stopifnot(length(breaks) == 2)
+ stopifnot(length(breaks) == 2)
stopifnot(all(sapply(breaks, is.numeric)))
}
names(breaks) <- c("x", "y")
-
+
xbin <- cut(data$x, sort(breaks$x), include.lowest = TRUE)
ybin <- cut(data$y, sort(breaks$y), include.lowest = TRUE)
-
+
if (is.null(data$weight)) data$weight <- 1
-
+
counts <- as.data.frame(
xtabs(weight ~ xbin + ybin, data), responseName = "count")
if (drop) counts <- subset(counts, count > 0)
-
+
within(counts,{
xint <- as.numeric(xbin)
xmin <- breaks$x[xint]
@@ -114,8 +114,8 @@ StatBin2d <- proto(Stat, {
yint <- as.numeric(ybin)
ymin <- breaks$y[yint]
ymax <- breaks$y[yint + 1]
-
+
density <- count / sum(count, na.rm = TRUE)
})
- }
+ }
})
diff --git a/R/stat-bindot.r b/R/stat-bindot.r
index 36194dc..e544d13 100644
--- a/R/stat-bindot.r
+++ b/R/stat-bindot.r
@@ -1,9 +1,9 @@
#' Bin data for dot plot.
-#'
+#'
#' Missing values are currently silently dropped.
#' If weights are used, they must be integer values.
#'
-#' @section Aesthetics:
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat", "bindot")}
#'
#' @inheritParams stat_identity
@@ -17,9 +17,9 @@
#' determines positions of the bins for each group separately. "all" determines
#' positions of the bins with all the data taken together; this is used for
#' aligning dot stacks across multiple groups.
-#' @param origin When \code{method} is "histodot", origin of first bin
+#' @param origin When \code{method} is "histodot", origin of first bin
#' @param right When \code{method} is "histodot", should intervals be closed
-#' on the right (a, b], or not [a, b)
+#' on the right (a, b], or not [a, b)
#' @param width When \code{binaxis} is "y", the spacing of the dot stacks
#' for dodging.
#' @param na.rm If \code{FALSE} (the default), removes missing values with
@@ -33,7 +33,7 @@
#' width of each bin if method is "histodot"}
#' \item{count}{number of points in bin}
#' \item{ncount}{count, scaled to maximum of 1}
-#' \item{density}{density of points in bin, scaled to integrate to 1,
+#' \item{density}{density of points in bin, scaled to integrate to 1,
#' if method is "histodot"}
#' \item{ndensity}{density, scaled to maximum of 1, if method is "histodot"}
#' @seealso See \code{\link{geom_dotplot}} for examples.
@@ -54,10 +54,10 @@ binpositions = "bygroup", drop = FALSE, right = TRUE, na.rm = FALSE, ...) {
StatBindot <- proto(Stat, {
objname <- "bindot"
informed <- FALSE
-
+
calculate_groups <- function(., data, na.rm = FALSE, binwidth = NULL, binaxis = "x",
method = "dotdensity", binpositions = "bygroup", ...) {
- data <- remove_missing(data, na.rm, c(binaxis, "weight"), name="stat_bindot",
+ data <- remove_missing(data, na.rm, c(binaxis, "weight"), name="stat_bindot",
finite = TRUE)
.$informed <- FALSE
@@ -166,7 +166,7 @@ StatBindot <- proto(Stat, {
default_aes <- function(.) aes(y = ..count..)
required_aes <- c("x")
default_geom <- function(.) GeomDotplot
-
+
})
# This does density binning, but does not collapse each bin with a count.
diff --git a/R/stat-binhex.r b/R/stat-binhex.r
index e6a3dc7..2a5e361 100644
--- a/R/stat-binhex.r
+++ b/R/stat-binhex.r
@@ -1,10 +1,10 @@
#' Bin 2d plane into hexagons.
-#'
-#' @section Aesthetics:
+#'
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat", "binhex")}
#'
#' @seealso \code{\link{stat_bin2d}} for rectangular binning
-#' @param bins numeric vector specifying number of bins in both x and y
+#' @param bins numeric vector specifying number of bins in both x and y
#' directions. Set to 30 by default.
#' @inheritParams stat_identity
#' @param na.rm If \code{FALSE} (the default), removes missing values with
@@ -15,24 +15,24 @@
#' d <- ggplot(diamonds, aes(carat, price))
#' d + stat_binhex()
#' d + geom_hex()
-#'
+#'
#' # You can control the size of the bins by specifying the number of
#' # bins in each direction:
#' d + stat_binhex(bins = 10)
#' d + stat_binhex(bins = 30)
-#'
+#'
#' # Or by specifying the width of the bins
#' d + stat_binhex(binwidth = c(1, 1000))
#' d + stat_binhex(binwidth = c(.1, 500))
-#'
+#'
#' # With qplot
#' qplot(x, y, data = diamonds, geom="hex", xlim = c(4, 10), ylim = c(4, 10))
#' qplot(x, y, data = diamonds, geom="hex", xlim = c(4, 10), ylim = c(4, 10),
#' binwidth = c(0.1, 0.1))
#' }
-stat_binhex <- function (mapping = NULL, data = NULL, geom = "hex", position = "identity",
-bins = 30, na.rm = FALSE, ...) {
- StatBinhex$new(mapping = mapping, data = data, geom = geom, position = position,
+stat_binhex <- function (mapping = NULL, data = NULL, geom = "hex", position = "identity",
+bins = 30, na.rm = FALSE, ...) {
+ StatBinhex$new(mapping = mapping, data = data, geom = geom, position = position,
bins = bins, na.rm = na.rm, ...)
}
@@ -42,58 +42,58 @@ StatBinhex <- proto(Stat, {
default_aes <- function(.) aes(fill = ..count..)
required_aes <- c("x", "y")
default_geom <- function(.) GeomHex
-
-
+
+
calculate <- function(., data, scales, binwidth = NULL, bins = 30, na.rm = FALSE, ...) {
try_require("hexbin")
data <- remove_missing(data, na.rm, c("x", "y"), name="stat_hexbin")
if (is.null(binwidth)) {
- binwidth <- c(
+ binwidth <- c(
diff(scale_dimension(scales$x, c(0, 0))) / bins,
diff(scale_dimension(scales$y, c(0, 0))) / bins
)
}
-
+
hexBin(data$x, data$y, binwidth)
}
-
+
})
# Bin 2d plane into hexagons
# Wrapper around \code{\link[hexbin]{hcell2xy}} that returns a data frame
-#
+#
# @param x positions
# @param y positions
# @param numeric vector of length 2 giving binwidth in x and y directions
# @keyword internal
hexBin <- function(x, y, binwidth) {
try_require("hexbin")
-
+
# Convert binwidths into bounds + nbins
xbnds <- c(
- round_any(min(x), binwidth[1], floor) - 1e-6,
+ round_any(min(x), binwidth[1], floor) - 1e-6,
round_any(max(x), binwidth[1], ceiling) + 1e-6
)
xbins <- diff(xbnds) / binwidth[1]
ybnds <- c(
- round_any(min(y), binwidth[2], floor) - 1e-6,
+ round_any(min(y), binwidth[2], floor) - 1e-6,
round_any(max(y), binwidth[2], ceiling) + 1e-6
)
ybins <- diff(ybnds) / binwidth[2]
-
+
# Call hexbin
hb <- hexbin(
- x, xbnds = xbnds, xbins = xbins,
- y, ybnds = ybnds, shape = ybins / xbins,
+ x, xbnds = xbnds, xbins = xbins,
+ y, ybnds = ybnds, shape = ybins / xbins,
)
-
+
# Convert to data frame
data.frame(
- hcell2xy(hb),
- count = hb at count,
+ hcell2xy(hb),
+ count = hb at count,
density = hb at count / sum(hb at count, na.rm=TRUE)
)
}
diff --git a/R/stat-boxplot.r b/R/stat-boxplot.r
index a9b2405..12eb748 100644
--- a/R/stat-boxplot.r
+++ b/R/stat-boxplot.r
@@ -1,6 +1,6 @@
#' Calculate components of box and whisker plot.
-#'
-#' @section Aesthetics:
+#'
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat", "boxplot")}
#'
#' @param coef length of the whiskers as multiple of IQR. Defaults to 1.5
@@ -10,7 +10,7 @@
#' @return A data frame with additional columns:
#' \item{width}{width of boxplot}
#' \item{ymin}{lower whisker = smallest observation greater than or equal to lower hinge - 1.5 * IQR}
-#' \item{lower}{lower hinge, 25\% quantile}
+#' \item{lower}{lower hinge, 25\% quantile}
#' \item{notchlower}{lower edge of notch = median - 1.58 * IQR / sqrt(n)}
#' \item{middle}{median, 50\% quantile}
#' \item{notchupper}{upper edge of notch = median + 1.58 * IQR / sqrt(n)}
@@ -20,29 +20,29 @@
#' @export
#' @examples
#' # See geom_boxplot for examples
-stat_boxplot <- function (mapping = NULL, data = NULL, geom = "boxplot", position = "dodge",
-na.rm = FALSE, coef = 1.5, ...) {
- StatBoxplot$new(mapping = mapping, data = data, geom = geom,
+stat_boxplot <- function (mapping = NULL, data = NULL, geom = "boxplot", position = "dodge",
+na.rm = FALSE, coef = 1.5, ...) {
+ StatBoxplot$new(mapping = mapping, data = data, geom = geom,
position = position, na.rm = na.rm, coef = coef, ...)
}
-
+
StatBoxplot <- proto(Stat, {
objname <- "boxplot"
-
+
required_aes <- c("x", "y")
default_geom <- function(.) GeomBoxplot
-
+
calculate_groups <- function(., data, na.rm = FALSE, width = NULL, ...) {
- data <- remove_missing(data, na.rm, c("y", "weight"), name="stat_boxplot",
+ data <- remove_missing(data, na.rm, c("y", "weight"), name="stat_boxplot",
finite = TRUE)
data$weight <- data$weight %||% 1
width <- width %||% resolution(data$x) * 0.75
-
+
.super$calculate_groups(., data, na.rm = na.rm, width = width, ...)
}
-
+
calculate <- function(., data, scales, width=NULL, na.rm = FALSE, coef = 1.5, ...) {
- with(data, {
+ with(data, {
qs <- c(0, 0.25, 0.5, 0.75, 1)
if (length(unique(weight)) != 1) {
try_require("quantreg")
@@ -51,16 +51,16 @@ StatBoxplot <- proto(Stat, {
stats <- as.numeric(quantile(y, qs))
}
names(stats) <- c("ymin", "lower", "middle", "upper", "ymax")
-
+
iqr <- diff(stats[c(2, 4)])
-
+
outliers <- y < (stats[2] - coef * iqr) | y > (stats[4] + coef * iqr)
if (any(outliers)) {
stats[c(1, 5)] <- range(c(stats[2:4], y[!outliers]), na.rm=TRUE)
}
-
+
if (length(unique(x)) > 1) width <- diff(range(x)) * 0.9
-
+
df <- as.data.frame(as.list(stats))
df$outliers <- I(list(y[outliers]))
@@ -76,7 +76,8 @@ StatBoxplot <- proto(Stat, {
transform(df,
x = if (is.factor(x)) x[1] else mean(range(x)),
- width = width
+ width = width,
+ relvarwidth = sqrt(n)
)
})
}
diff --git a/R/stat-contour.r b/R/stat-contour.r
index fc0a774..239c5ff 100644
--- a/R/stat-contour.r
+++ b/R/stat-contour.r
@@ -1,6 +1,6 @@
#' Calculate contours of 3d data.
-#'
-#' @section Aesthetics:
+#'
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat", "contour")}
#'
#' @inheritParams stat_identity
@@ -15,15 +15,15 @@
#' library(reshape2) # for melt
#' volcano3d <- melt(volcano)
#' names(volcano3d) <- c("x", "y", "z")
-#'
+#'
#' # Basic plot
#' v <- ggplot(volcano3d, aes(x, y, z = z))
#' v + stat_contour()
-#'
+#'
#' # Setting bins creates evenly spaced contours in the range of the data
#' v + stat_contour(bins = 2)
#' v + stat_contour(bins = 10)
-#'
+#'
#' # Setting binwidth does the same thing, parameterised by the distance
#' # between contours
#' v + stat_contour(binwidth = 2)
@@ -31,30 +31,30 @@
#' v + stat_contour(binwidth = 10)
#' v + stat_contour(binwidth = 2, size = 0.5, colour = "grey50") +
#' stat_contour(binwidth = 10, size = 1)
-#'
+#'
#' # Add aesthetic mappings
#' v + stat_contour(aes(size = ..level..))
#' v + stat_contour(aes(colour = ..level..))
-#'
+#'
#' # Change scale
-#' v + stat_contour(aes(colour = ..level..), size = 2) +
+#' v + stat_contour(aes(colour = ..level..), size = 2) +
#' scale_colour_gradient(low = "brown", high = "white")
-#'
+#'
#' # Set aesthetics to fixed value
#' v + stat_contour(colour = "red")
#' v + stat_contour(size = 2, linetype = 4)
-#'
+#'
#' # Try different geoms
#' v + stat_contour(geom="polygon", aes(fill=..level..))
#' v + geom_tile(aes(fill = z)) + stat_contour()
-#'
+#'
#' # Use qplot instead
#' qplot(x, y, z = z, data = volcano3d, geom = "contour")
#' qplot(x, y, z = z, data = volcano3d, stat = "contour", geom = "path")
#' }
-stat_contour <- function (mapping = NULL, data = NULL, geom = "path", position = "identity",
-na.rm = FALSE, ...) {
- StatContour$new(mapping = mapping, data = data, geom = geom,
+stat_contour <- function (mapping = NULL, data = NULL, geom = "path", position = "identity",
+na.rm = FALSE, ...) {
+ StatContour$new(mapping = mapping, data = data, geom = geom,
position = position, na.rm = na.rm, ...)
}
@@ -76,11 +76,11 @@ StatContour <- proto(Stat, {
if (is.null(breaks)) {
breaks <- fullseq(range(data$z), binwidth)
}
-
+
contour_lines(data, breaks, complete = complete)
}
-
+
default_geom <- function(.) GeomPath
default_aes <- function(.) aes(order = ..level..)
required_aes <- c("x", "y", "z")
@@ -97,8 +97,8 @@ contour_lines <- function(data, breaks, complete = FALSE) {
z <- tapply(data$z, data[c("x", "y")], identity)
cl <- contourLines(
- x = sort(unique(data$x)), y = sort(unique(data$y)), z = z,
- levels = breaks)
+ x = sort(unique(data$x)), y = sort(unique(data$y)), z = z,
+ levels = breaks)
if (length(cl) == 0) {
warning("Not possible to generate contour data", call. = FALSE)
@@ -137,7 +137,7 @@ poly_dir <- function(x, y) {
# To fix breaks and complete the polygons, we need to add 0-4 corner points.
#
# contours <- ddply(contours, "piece", mutate, dir = poly_dir(x, y))
-# qplot(x, y, data = contours, geom = "path", group = piece,
+# qplot(x, y, data = contours, geom = "path", group = piece,
# colour = factor(dir))
# last_plot() + facet_wrap(~ level)
diff --git a/R/stat-density-2d.r b/R/stat-density-2d.r
index 217181f..88dcc42 100644
--- a/R/stat-density-2d.r
+++ b/R/stat-density-2d.r
@@ -1,6 +1,6 @@
#' 2d density estimation.
#'
-#' @section Aesthetics:
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat", "density2d")}
#'
#' @param contour If \code{TRUE}, contour the results of the 2d density
@@ -18,24 +18,24 @@
#' library("MASS")
#' data(geyser, "MASS")
#'
-#' m <- ggplot(geyser, aes(x = duration, y = waiting)) +
+#' m <- ggplot(geyser, aes(x = duration, y = waiting)) +
#' geom_point() + xlim(0.5, 6) + ylim(40, 110)
#' m + geom_density2d()
-#'
-#' dens <- kde2d(geyser$duration, geyser$waiting, n = 50,
+#'
+#' dens <- kde2d(geyser$duration, geyser$waiting, n = 50,
#' lims = c(0.5, 6, 40, 110))
#' densdf <- data.frame(expand.grid(duration = dens$x, waiting = dens$y),
#' z = as.vector(dens$z))
#' m + geom_contour(aes(z=z), data=densdf)
-#'
+#'
#' m + geom_density2d() + scale_y_log10()
#' m + geom_density2d() + coord_trans(y="log10")
-#'
+#'
#' m + stat_density2d(aes(fill = ..level..), geom="polygon")
-#'
-#' qplot(duration, waiting, data=geyser, geom=c("point","density2d")) +
+#'
+#' qplot(duration, waiting, data=geyser, geom=c("point","density2d")) +
#' xlim(0.5, 6) + ylim(40, 110)
-#'
+#'
#' # If you map an aesthetic to a categorical variable, you will get a
#' # set of contours for each value of that variable
#' set.seed(4393)
@@ -45,28 +45,28 @@
#' qplot(carat, price, data = dsmall, geom = "density2d", colour = cut)
#' d <- ggplot(dsmall, aes(carat, price)) + xlim(1,3)
#' d + geom_point() + geom_density2d()
-#'
+#'
#' # If we turn contouring off, we can use use geoms like tiles:
#' d + stat_density2d(geom="tile", aes(fill = ..density..), contour = FALSE)
#' last_plot() + scale_fill_gradient(limits=c(1e-5,8e-4))
-#'
+#'
#' # Or points:
#' d + stat_density2d(geom="point", aes(size = ..density..), contour = FALSE)
#' }
-stat_density2d <- function (mapping = NULL, data = NULL, geom = "density2d", position = "identity",
+stat_density2d <- function (mapping = NULL, data = NULL, geom = "density2d", position = "identity",
na.rm = FALSE, contour = TRUE, n = 100, ...) {
- StatDensity2d$new(mapping = mapping, data = data, geom = geom,
+ StatDensity2d$new(mapping = mapping, data = data, geom = geom,
position = position, na.rm = na.rm, contour = contour, n = n, ...)
}
StatDensity2d <- proto(Stat, {
objname <- "density2d"
-
+
default_geom <- function(.) GeomDensity2d
default_aes <- function(.) aes(colour = "#3366FF", size = 0.5)
required_aes <- c("x", "y")
-
+
calculate <- function(., data, scales, na.rm = FALSE, contour = TRUE, n = 100, ...) {
df <- data.frame(data[, c("x", "y")])
df <- remove_missing(df, na.rm, name = "stat_density2d", finite = TRUE)
@@ -75,14 +75,14 @@ StatDensity2d <- proto(Stat, {
lims = c(scale_dimension(scales$x), scale_dimension(scales$y)), ...))
df <- with(dens, data.frame(expand.grid(x = x, y = y), z = as.vector(z)))
df$group <- data$group[1]
-
+
if (contour) {
- StatContour$calculate(df, scales, ...)
+ StatContour$calculate(df, scales, ...)
} else {
names(df) <- c("x", "y", "density", "group")
df$level <- 1
df$piece <- 1
df
}
- }
+ }
})
diff --git a/R/stat-density.r b/R/stat-density.r
index 00502ba..3a39db6 100644
--- a/R/stat-density.r
+++ b/R/stat-density.r
@@ -1,6 +1,6 @@
#' 1d kernel density estimate.
#'
-#' @section Aesthetics:
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat", "density")}
#'
#' @param adjust see \code{\link{density}} for details
@@ -24,95 +24,95 @@
#' \donttest{
#' m <- ggplot(movies, aes(x = rating))
#' m + geom_density()
-#'
+#'
#' # Adjust parameters
#' m + geom_density(kernel = "rectangular")
-#' m + geom_density(kernel = "biweight")
+#' m + geom_density(kernel = "biweight")
#' m + geom_density(kernel = "epanechnikov")
#' m + geom_density(adjust=1/5) # Very rough
#' m + geom_density(adjust=5) # Very smooth
-#'
+#'
#' # Adjust aesthetics
#' m + geom_density(aes(fill=factor(Drama)), size=2)
#' # Scale so peaks have same height:
#' m + geom_density(aes(fill=factor(Drama), y = ..scaled..), size=2)
-#'
+#'
#' m + geom_density(colour="darkgreen", size=2)
#' m + geom_density(colour="darkgreen", size=2, fill=NA)
#' m + geom_density(colour="darkgreen", size=2, fill="green")
-#'
+#'
#' # Change scales
#' (m <- ggplot(movies, aes(x=votes)) + geom_density(trim = TRUE))
#' m + scale_x_log10()
#' m + coord_trans(x="log10")
#' m + scale_x_log10() + coord_trans(x="log10")
-#'
+#'
#' # Also useful with
#' m + stat_bin()
-#'
+#'
#' # Make a volcano plot
-#' ggplot(diamonds, aes(x = price)) +
-#' stat_density(aes(ymax = ..density.., ymin = -..density..),
-#' fill = "grey50", colour = "grey50",
-#' geom = "ribbon", position = "identity") +
-#' facet_grid(. ~ cut) +
+#' ggplot(diamonds, aes(x = price)) +
+#' stat_density(aes(ymax = ..density.., ymin = -..density..),
+#' fill = "grey50", colour = "grey50",
+#' geom = "ribbon", position = "identity") +
+#' facet_grid(. ~ cut) +
#' coord_flip()
-#'
+#'
#' # Stacked density plots
#' # If you want to create a stacked density plot, you need to use
#' # the 'count' (density * n) variable instead of the default density
-#'
+#'
#' # Loses marginal densities
#' qplot(rating, ..density.., data=movies, geom="density", fill=mpaa, position="stack")
#' # Preserves marginal densities
#' qplot(rating, ..count.., data=movies, geom="density", fill=mpaa, position="stack")
-#'
+#'
#' # You can use position="fill" to produce a conditional density estimate
#' qplot(rating, ..count.., data=movies, geom="density", fill=mpaa, position="fill")
-#'
+#'
#' # Need to be careful with weighted data
#' m <- ggplot(movies, aes(x=rating, weight=votes))
#' m + geom_histogram(aes(y = ..count..)) + geom_density(fill=NA)
-#'
+#'
#' m <- ggplot(movies, aes(x=rating, weight=votes/sum(votes)))
#' m + geom_histogram(aes(y=..density..)) + geom_density(fill=NA, colour="black")
-#'
+#'
#' library(plyr) # to access round_any
#' movies$decade <- round_any(movies$year, 10)
-#' m <- ggplot(movies, aes(x=rating, colour=decade, group=decade))
+#' m <- ggplot(movies, aes(x=rating, colour=decade, group=decade))
#' m + geom_density(fill=NA)
#' m + geom_density(fill=NA) + aes(y = ..count..)
-#'
+#'
#' # Use qplot instead
#' qplot(length, data=movies, geom="density", weight=rating)
#' qplot(length, data=movies, geom="density", weight=rating/sum(rating))
#' }
-stat_density <- function (mapping = NULL, data = NULL, geom = "area", position = "stack",
-adjust = 1, kernel = "gaussian", trim = FALSE, na.rm = FALSE, ...) {
+stat_density <- function (mapping = NULL, data = NULL, geom = "area", position = "stack",
+adjust = 1, kernel = "gaussian", trim = FALSE, na.rm = FALSE, ...) {
StatDensity$new(mapping = mapping, data = data, geom = geom, position = position,
adjust = adjust, kernel = kernel, trim = trim, na.rm = na.rm, ...)
}
-
+
StatDensity <- proto(Stat, {
objname <- "density"
calculate <- function(., data, scales, adjust=1, kernel="gaussian", trim=FALSE, na.rm = FALSE, ...) {
- data <- remove_missing(data, na.rm, "x", name = "stat_density",
+ data <- remove_missing(data, na.rm, "x", name = "stat_density",
finite = TRUE)
-
+
n <- nrow(data)
if (n < 3) return(data.frame())
if (is.null(data$weight)) data$weight <- rep(1, n) / n
range <- scale_dimension(scales$x, c(0, 0))
xgrid <- seq(range[1], range[2], length=200)
-
+
dens <- density(data$x, adjust=adjust, kernel=kernel, weight=data$weight, from=range[1], to=range[2])
densdf <- as.data.frame(dens[c("x","y")])
densdf$scaled <- densdf$y / max(densdf$y, na.rm = TRUE)
if (trim) densdf <- subset(densdf, x > min(data$x, na.rm = TRUE) & x < max(data$x, na.rm = TRUE))
-
+
densdf$count <- densdf$y * n
rename(densdf, c(y = "density"), warn_missing = FALSE)
}
diff --git a/R/stat-ecdf.r b/R/stat-ecdf.r
index 8d0ef07..792fcc6 100644
--- a/R/stat-ecdf.r
+++ b/R/stat-ecdf.r
@@ -1,5 +1,5 @@
#' Empirical Cumulative Density Function
-#'
+#'
#' @inheritParams stat_identity
#' @param n if NULL, do not interpolate. If not NULL, this is the number
#' of points to interpolate with.
@@ -10,10 +10,10 @@
#' @examples
#' \donttest{
#' qplot(rnorm(1000), stat = "ecdf", geom = "step")
-#'
+#'
#' df <- data.frame(x = c(rnorm(100, 0, 3), rnorm(100, 0, 10)),
#' g = gl(2, 100))
-#'
+#'
#' ggplot(df, aes(x, colour = g)) + stat_ecdf()
#' }
stat_ecdf <- function (mapping = NULL, data = NULL, geom = "step", position = "identity", n = NULL, ...) {
@@ -22,7 +22,7 @@ stat_ecdf <- function (mapping = NULL, data = NULL, geom = "step", position = "i
StatEcdf <- proto(Stat, {
objname <- "ecdf"
-
+
calculate <- function(., data, scales, n = NULL, ...) {
# If n is NULL, use raw values; otherwise interpolate
diff --git a/R/stat-ellipse.R b/R/stat-ellipse.R
new file mode 100644
index 0000000..861da58
--- /dev/null
+++ b/R/stat-ellipse.R
@@ -0,0 +1,102 @@
+#' Plot data ellipses.
+#'
+#' @param level The confidence level at which to draw an ellipse (default is 0.95),
+#' or, if \code{type="euclid"}, the radius of the circle to be drawn.
+#' @param type The type of ellipse.
+#' The default \code{"t"} assumes a multivariate t-distribution, and
+#' \code{"norm"} assumes a multivariate normal distribution.
+#' \code{"euclid"} draws a circle with the radius equal to \code{level},
+#' representing the euclidian distance from the center.
+#' This ellipse probably won't appear circular unless \code{coord_fixed()} is applied.
+#' @param segments The number of segments to be used in drawing the ellipse.
+#' @param na.rm If \code{FALSE} (the default), removes missing values with
+#' a warning. If \code{TRUE} silently removes missing values.
+#' @inheritParams stat_identity
+#'
+#' @details The method for calculating the ellipses has been modified from car::ellipse (Fox and Weisberg, 2011)
+#'
+#' @references
+#' John Fox and Sanford Weisberg (2011). An {R} Companion to Applied Regression, Second Edition. Thousand Oaks CA: Sage. URL: http://socserv.socsci.mcmaster.ca/jfox/Books/Companion
+#'
+#' @export
+#' @importFrom MASS cov.trob
+#'
+#' @examples
+#' ggplot(faithful, aes(waiting, eruptions))+
+#' geom_point()+
+#' stat_ellipse()
+#'
+#' ggplot(faithful, aes(waiting, eruptions, color = eruptions > 3))+
+#' geom_point()+
+#' stat_ellipse()
+#'
+#' ggplot(faithful, aes(waiting, eruptions, color = eruptions > 3))+
+#' geom_point()+
+#' stat_ellipse(type = "norm", linetype = 2)+
+#' stat_ellipse(type = "t")
+#'
+#' ggplot(faithful, aes(waiting, eruptions, color = eruptions > 3))+
+#' geom_point()+
+#' stat_ellipse(type = "norm", linetype = 2)+
+#' stat_ellipse(type = "euclid", level = 3)+
+#' coord_fixed()
+#'
+#' ggplot(faithful, aes(waiting, eruptions, color = eruptions > 3))+
+#' stat_ellipse(geom = "polygon")
+
+stat_ellipse <- function(mapping = NULL, data = NULL, geom = "path", position = "identity", type = "t", level = 0.95, segments = 51, na.rm = FALSE, ...) {
+ StatEllipse$new(mapping = mapping, data = data, geom = geom, position = position, type = type, level = level, segments = segments, na.rm = na.rm, ...)
+}
+
+StatEllipse <- proto(Stat, {
+ objname <- "ellipse"
+
+ required_aes <- c("x", "y")
+ default_geom <- function(.) GeomPath
+
+ calculate_groups <- function(., data, scales, ...){
+ .super$calculate_groups(., data, scales,...)
+ }
+ calculate <- function(., data, scales, type = "t", level = 0.95, segments = 51, na.rm = FALSE, ...){
+ data <- remove_missing(data, na.rm, vars = c("x","y"), name = "stat_ellipse", finite = TRUE)
+ ellipse <- calculate_ellipse(data=data, vars= c("x","y"), type=type, level=level, segments=segments)
+ return(ellipse)
+ }
+})
+
+calculate_ellipse <- function(data, vars, type, level, segments){
+ dfn <- 2
+ dfd <- nrow(data) - 1
+
+ if (!type %in% c("t", "norm", "euclid")){
+ message("Unrecognized ellipse type")
+ ellipse <- rbind(as.numeric(c(NA, NA)))
+ } else if (dfd < 3){
+ message("Too few points to calculate an ellipse")
+ ellipse <- rbind(as.numeric(c(NA, NA)))
+ } else {
+ if (type == "t"){
+ v <- cov.trob(data[,vars])
+ } else if (type == "norm"){
+ v <- cov.wt(data[,vars])
+ } else if (type == "euclid"){
+ v <- cov.wt(data[,vars])
+ v$cov <- diag(rep(min(diag(v$cov)), 2))
+ }
+ shape <- v$cov
+ center <- v$center
+ chol_decomp <- chol(shape)
+ if (type == "euclid"){
+ radius <- level/max(chol_decomp)
+ } else {
+ radius <- sqrt(dfn * qf(level, dfn, dfd))
+ }
+ angles <- (0:segments) * 2 * pi/segments
+ unit.circle <- cbind(cos(angles), sin(angles))
+ ellipse <- t(center + radius * t(unit.circle %*% chol_decomp))
+ }
+
+ ellipse <- as.data.frame(ellipse)
+ colnames(ellipse) <- vars
+ return(ellipse)
+}
diff --git a/R/stat-function.r b/R/stat-function.r
index 8153618..db3da09 100644
--- a/R/stat-function.r
+++ b/R/stat-function.r
@@ -1,6 +1,6 @@
#' Superimpose a function.
#'
-#' @section Aesthetics:
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat", "function")}
#'
#' @param fun function to use
@@ -28,20 +28,22 @@
#' # With qplot
#' qplot(c(-5, 5), stat = "function", fun = dnorm, geom = "line")
#' # Or
-#' qplot(c(-5, 5), geom = "blank") + stat_function(fun = dnorm)
-#' # To specify a different mean or sd, use the args parameter to supply new values
-#' ggplot(data.frame(x = c(-5, 5)), aes(x)) + stat_function(fun = dnorm, args = list(mean = 2, sd = .5))
+#' qplot(c(-5, 5), geom = "blank") + stat_function(fun = dnorm)
+#' # To specify a different mean or sd, use the args parameter to supply new values
+#' ggplot(data.frame(x = c(-5, 5)), aes(x)) +
+#' stat_function(fun = dnorm, args = list(mean = 2, sd = .5))
#'
#' # Two functions on the same plot
#' f <- ggplot(data.frame(x = c(0, 10)), aes(x))
-#' f + stat_function(fun = sin, colour = "red") + stat_function(fun = cos, colour = "blue")
+#' f + stat_function(fun = sin, colour = "red") +
+#' stat_function(fun = cos, colour = "blue")
#'
#' # Using a custom function
#' test <- function(x) {x ^ 2 + x + 20}
#' f + stat_function(fun = test)
-stat_function <- function (mapping = NULL, data = NULL, geom = "path", position = "identity",
-fun, n = 101, args = list(), ...) {
- StatFunction$new(mapping = mapping, data = data, geom = geom,
+stat_function <- function (mapping = NULL, data = NULL, geom = "path", position = "identity",
+fun, n = 101, args = list(), ...) {
+ StatFunction$new(mapping = mapping, data = data, geom = geom,
position = position, fun = fun, n = n, args = args, ...)
}
@@ -50,14 +52,14 @@ StatFunction <- proto(Stat, {
default_geom <- function(.) GeomPath
default_aes <- function(.) aes(y = ..y..)
-
+
calculate <- function(., data, scales, fun, n=101, args = list(), ...) {
range <- scale_dimension(scales$x, c(0, 0))
xseq <- seq(range[1], range[2], length=n)
-
+
data.frame(
x = xseq,
y = do.call(fun, c(list(xseq), args))
)
- }
+ }
})
diff --git a/R/stat-identity.r b/R/stat-identity.r
index 41961f6..95f422a 100644
--- a/R/stat-identity.r
+++ b/R/stat-identity.r
@@ -1,6 +1,6 @@
#' Identity statistic.
-#'
-#' @section Aesthetics:
+#'
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat", "identity")}
#'
#' @param mapping The aesthetic mapping, usually constructed with
@@ -8,12 +8,12 @@
#' at the layer level if you are overriding the plot defaults.
#' @param data A layer specific dataset - only needed if you want to override
#' the plot defaults.
-#' @param geom The geometric object to use display the data
+#' @param geom The geometric object to use display the data
#' @param position The position adjustment to use for overlappling points
#' on this layer
#' @param width The width of the tiles.
#' @param height The height of the tiles.
-#' @param ... other arguments passed on to \code{\link{layer}}. This can
+#' @param ... other arguments passed on to \code{\link{layer}}. This can
#' include aesthetics whose values you want to set, not map. See
#' \code{\link{layer}} for more details.
#' @export
@@ -22,7 +22,7 @@
stat_identity <- function (mapping = NULL, data = NULL, geom = "point",
position = "identity", width = NULL, height = NULL, ...) {
- StatIdentity$new(mapping = mapping, data = data, geom = geom,
+ StatIdentity$new(mapping = mapping, data = data, geom = geom,
position = position, width = width, height = height,...)
}
@@ -35,7 +35,7 @@ StatIdentity <- proto(Stat, {
if (!is.null(height)) data$height <- height
data
}
-
+
desc_outputs <- list()
-
+
})
diff --git a/R/stat-qq.r b/R/stat-qq.r
index b1aebbe..a1dd7a7 100644
--- a/R/stat-qq.r
+++ b/R/stat-qq.r
@@ -1,6 +1,6 @@
#' Calculation for quantile-quantile plot.
-#'
-#' @section Aesthetics:
+#'
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat", "qq")}
#'
#' @param distribution Distribution function to use, if x not specified
@@ -18,32 +18,32 @@
#' # From ?qqplot
#' y <- rt(200, df = 5)
#' qplot(sample = y, stat="qq")
-#'
+#'
#' # qplot is smart enough to use stat_qq if you use sample
#' qplot(sample = y)
#' qplot(sample = precip)
-#'
+#'
#' qplot(sample = y, dist = qt, dparams = list(df = 5))
-#'
+#'
#' df <- data.frame(y)
#' ggplot(df, aes(sample = y)) + stat_qq()
#' ggplot(df, aes(sample = y)) + geom_point(stat = "qq")
-#'
+#'
#' # Use fitdistr from MASS to estimate distribution params
#' library(MASS)
#' params <- as.list(fitdistr(y, "t")$estimate)
#' ggplot(df, aes(sample = y)) + stat_qq(dist = qt, dparam = params)
-#'
+#'
#' # Using to explore the distribution of a variable
#' qplot(sample = mpg, data = mtcars)
-#' qplot(sample = mpg, data = mtcars, colour = factor(cyl))
+#' qplot(sample = mpg, data = mtcars, colour = factor(cyl))
#' }
-stat_qq <- function (mapping = NULL, data = NULL, geom = "point", position = "identity",
-distribution = qnorm, dparams = list(), na.rm = FALSE, ...) {
- StatQq$new(mapping = mapping, data = data, geom = geom, position = position,
+stat_qq <- function (mapping = NULL, data = NULL, geom = "point", position = "identity",
+distribution = qnorm, dparams = list(), na.rm = FALSE, ...) {
+ StatQq$new(mapping = mapping, data = data, geom = geom, position = position,
distribution = distribution, dparams = dparams, na.rm = na.rm, ...)
}
-
+
StatQq <- proto(Stat, {
objname <- "qq"
@@ -52,11 +52,11 @@ StatQq <- proto(Stat, {
required_aes <- c("sample")
calculate <- function(., data, scales, quantiles = NULL, distribution = qnorm, dparams = list(), na.rm = FALSE) {
- data <- remove_missing(data, na.rm, "sample", name = "stat_qq")
+ data <- remove_missing(data, na.rm, "sample", name = "stat_qq")
sample <- sort(data$sample)
n <- length(sample)
-
+
# Compute theoretical quantiles
if (is.null(quantiles)) {
quantiles <- ppoints(n)
@@ -65,9 +65,9 @@ StatQq <- proto(Stat, {
}
theoretical <- safe.call(distribution, c(list(p = quantiles), dparams))
-
+
data.frame(sample, theoretical)
}
-
-
+
+
})
diff --git a/R/stat-quantile.r b/R/stat-quantile.r
index 2ea2ce8..02f6303 100644
--- a/R/stat-quantile.r
+++ b/R/stat-quantile.r
@@ -1,6 +1,6 @@
#' Continuous quantiles.
#'
-#' @section Aesthetics:
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat", "quantile")}
#'
#' @param quantiles conditional quantiles of y to calculate and display
@@ -21,33 +21,33 @@
#' m + stat_quantile(quantiles = 0.5)
#' q10 <- seq(0.05, 0.95, by=0.05)
#' m + stat_quantile(quantiles = q10)
-#'
+#'
#' # You can also use rqss to fit smooth quantiles
#' m + stat_quantile(method = "rqss")
-#' # Note that rqss doesn't pick a smoothing constant automatically, so
+#' # Note that rqss doesn't pick a smoothing constant automatically, so
#' # you'll need to tweak lambda yourself
#' m + stat_quantile(method = "rqss", lambda = 10)
#' m + stat_quantile(method = "rqss", lambda = 100)
-#'
+#'
#' # Use 'votes' as weights for the quantile calculation
#' m + stat_quantile(aes(weight=votes))
-#'
+#'
#' # Change scale
#' m + stat_quantile(aes(colour = ..quantile..), quantiles = q10)
#' m + stat_quantile(aes(colour = ..quantile..), quantiles = q10) +
#' scale_colour_gradient2(midpoint = 0.5)
-#'
+#'
#' # Set aesthetics to fixed value
#' m + stat_quantile(colour = "red", size = 2, linetype = 2)
-#'
+#'
#' # Use qplot instead
#' qplot(year, rating, data=movies, geom="quantile")
#' }
-stat_quantile <- function (mapping = NULL, data = NULL, geom = "quantile", position = "identity",
-quantiles = c(0.25, 0.5, 0.75), formula = NULL, method = "rq",
-na.rm = FALSE, ...) {
- StatQuantile$new(mapping = mapping, data = data, geom = geom,
- position = position, quantiles = quantiles, formula = formula,
+stat_quantile <- function (mapping = NULL, data = NULL, geom = "quantile", position = "identity",
+quantiles = c(0.25, 0.5, 0.75), formula = NULL, method = "rq",
+na.rm = FALSE, ...) {
+ StatQuantile$new(mapping = mapping, data = data, geom = geom,
+ position = position, quantiles = quantiles, formula = formula,
method = method, na.rm = na.rm, ...)
}
@@ -63,11 +63,11 @@ StatQuantile <- proto(Stat, {
...) {
try_require("quantreg")
-
+
if (is.null(formula)) {
if (method == "rqss") {
try_require("MatrixModels")
- formula <- eval(substitute(y ~ qss(x, lambda = lambda)),
+ formula <- eval(substitute(y ~ qss(x, lambda = lambda)),
list(lambda = lambda))
} else {
formula <- y ~ x
@@ -75,8 +75,8 @@ StatQuantile <- proto(Stat, {
message("Smoothing formula not specified. Using: ",
deparse(formula))
}
-
- if (is.null(data$weight)) data$weight <- 1
+
+ if (is.null(data$weight)) data$weight <- 1
if (is.null(xseq)) {
xmin <- min(data$x, na.rm = TRUE)
@@ -88,18 +88,18 @@ StatQuantile <- proto(Stat, {
data <- as.data.frame(data)
data <- remove_missing(data, na.rm, c("x", "y"), name = "stat_quantile")
method <- match.fun(method)
-
- ldply(quantiles, quant_pred, data = data, method = method,
+
+ ldply(quantiles, quant_pred, data = data, method = method,
formula = formula, weight = weight, grid = grid, ...)
}
})
quant_pred <- function(quantile, data, method, formula, weight, grid, ...) {
model <- method(formula, data = data, tau = quantile, weight = weight, ...)
-
+
grid$y <- predict(model, newdata = grid)
grid$quantile <- quantile
grid$group <- paste(data$group[1], quantile, sep = "-")
-
+
grid
}
diff --git a/R/stat-smooth-methods.r b/R/stat-smooth-methods.r
index f659354..36b9ea3 100644
--- a/R/stat-smooth-methods.r
+++ b/R/stat-smooth-methods.r
@@ -1,6 +1,6 @@
# Prediction data frame
# Get predictions with standard errors into data frame
-#
+#
# @keyword internal
# @alias predictdf.default
# @alias predictdf.glm
@@ -8,7 +8,7 @@
# @alias predictdf.locfit
predictdf <- function(model, xseq, se, level) UseMethod("predictdf")
-#' @S3method predictdf default
+#' @export
predictdf.default <- function(model, xseq, se, level) {
pred <- stats::predict(model, newdata = data.frame(x = xseq), se = se,
level = level, interval = if(se) "confidence" else "none")
@@ -19,21 +19,21 @@ predictdf.default <- function(model, xseq, se, level) {
data.frame(x = xseq, fit, se = pred$se)
} else {
data.frame(x = xseq, y = as.vector(pred))
- }
+ }
}
-#' @S3method predictdf glm
+#' @export
predictdf.glm <- function(model, xseq, se, level) {
- pred <- stats::predict(model, newdata = data.frame(x = xseq), se = se,
+ pred <- stats::predict(model, newdata = data.frame(x = xseq), se = se,
type = "link")
-
+
if (se) {
std <- qnorm(level / 2 + 0.5)
data.frame(
- x = xseq,
+ x = xseq,
y = model$family$linkinv(as.vector(pred$fit)),
- ymin = model$family$linkinv(as.vector(pred$fit - std * pred$se)),
- ymax = model$family$linkinv(as.vector(pred$fit + std * pred$se)),
+ ymin = model$family$linkinv(as.vector(pred$fit - std * pred$se)),
+ ymax = model$family$linkinv(as.vector(pred$fit + std * pred$se)),
se = as.vector(pred$se)
)
} else {
@@ -41,7 +41,7 @@ predictdf.glm <- function(model, xseq, se, level) {
}
}
-#' @S3method predictdf loess
+#' @export
predictdf.loess <- function(model, xseq, se, level) {
pred <- stats::predict(model, newdata = data.frame(x = xseq), se = se)
@@ -56,10 +56,10 @@ predictdf.loess <- function(model, xseq, se, level) {
}
}
-#' @S3method predictdf locfit
+#' @export
predictdf.locfit <- function(model, xseq, se, level) {
pred <- predict(model, newdata = data.frame(x = xseq), se.fit = se)
-
+
if (se) {
y = pred$fit
ymin = y - pred$se.fit
diff --git a/R/stat-smooth.r b/R/stat-smooth.r
index 430eb29..ee83288 100644
--- a/R/stat-smooth.r
+++ b/R/stat-smooth.r
@@ -1,23 +1,23 @@
#' Add a smoother.
-#'
+#'
#' Aids the eye in seeing patterns in the presence of overplotting.
#'
-#' Calculation is performed by the (currently undocumented)
+#' Calculation is performed by the (currently undocumented)
#' \code{predictdf} generic function and its methods. For most methods
#' the confidence bounds are computed using the \code{\link{predict}}
-#' method - the exceptions are \code{loess} which uses a t-based
+#' method - the exceptions are \code{loess} which uses a t-based
#' approximation, and for \code{glm} where the normal confidence interval
#' is constructed on the link scale, and then back-transformed to the response
#' scale.
#'
-#' @section Aesthetics:
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat", "smooth")}
#'
#' @param method smoothing method (function) to use, eg. lm, glm, gam, loess,
-#' rlm. For datasets with n < 1000 default is \code{\link{loess}}. For datasets
+#' rlm. For datasets with n < 1000 default is \code{\link{loess}}. For datasets
#' with 1000 or more observations defaults to gam, see \code{\link[mgcv]{gam}}
#' for more details.
-#' @param formula formula to use in smoothing function, eg. \code{y ~ x},
+#' @param formula formula to use in smoothing function, eg. \code{y ~ x},
#' \code{y ~ poly(x, 2)}, \code{y ~ log(x)}
#' @param se display confidence interval around smooth? (TRUE by default, see
#' level to control
@@ -29,12 +29,12 @@
#' a warning. If \code{TRUE} silently removes missing values.
#' @param ... other arguments are passed to smoothing function
#' @inheritParams stat_identity
-#' @return a data.frame with additional columns
+#' @return a data.frame with additional columns
#' \item{y}{predicted value}
#' \item{ymin}{lower pointwise confidence interval around the mean}
#' \item{ymax}{upper pointwise confidence interval around the mean}
#' \item{se}{standard error}
-#' @seealso
+#' @seealso
#' \code{\link{lm}} for linear smooths,
#' \code{\link{glm}} for generalised linear smooths,
#' \code{\link{loess}} for local smooths
@@ -42,66 +42,66 @@
#' @examples
#' \donttest{
#' c <- ggplot(mtcars, aes(qsec, wt))
-#' c + stat_smooth()
+#' c + stat_smooth()
#' c + stat_smooth() + geom_point()
-#'
+#'
#' # Adjust parameters
#' c + stat_smooth(se = FALSE) + geom_point()
-#'
-#' c + stat_smooth(span = 0.9) + geom_point()
+#'
+#' c + stat_smooth(span = 0.9) + geom_point()
#' c + stat_smooth(level = 0.99) + geom_point()
-#' c + stat_smooth(method = "lm") + geom_point()
-#'
+#' c + stat_smooth(method = "lm") + geom_point()
+#'
#' library(splines)
#' library(MASS)
#' c + stat_smooth(method = "lm", formula = y ~ ns(x,3)) +
-#' geom_point()
-#' c + stat_smooth(method = rlm, formula= y ~ ns(x,3)) + geom_point()
-#'
-#' # The default confidence band uses a transparent colour.
-#' # This currently only works on a limited number of graphics devices
+#' geom_point()
+#' c + stat_smooth(method = rlm, formula= y ~ ns(x,3)) + geom_point()
+#'
+#' # The default confidence band uses a transparent colour.
+#' # This currently only works on a limited number of graphics devices
#' # (including Quartz, PDF, and Cairo) so you may need to set the
#' # fill colour to a opaque colour, as shown below
#' c + stat_smooth(fill = "grey50", size = 2, alpha = 1)
#' c + stat_smooth(fill = "blue", size = 2, alpha = 1)
-#'
+#'
#' # The colour of the line can be controlled with the colour aesthetic
#' c + stat_smooth(fill="blue", colour="darkblue", size=2)
#' c + stat_smooth(fill="blue", colour="darkblue", size=2, alpha = 0.2)
-#' c + geom_point() +
+#' c + geom_point() +
#' stat_smooth(fill="blue", colour="darkblue", size=2, alpha = 0.2)
-#'
+#'
#' # Smoothers for subsets
#' c <- ggplot(mtcars, aes(y=wt, x=mpg)) + facet_grid(. ~ cyl)
-#' c + stat_smooth(method=lm) + geom_point()
-#' c + stat_smooth(method=lm, fullrange = TRUE) + geom_point()
-#'
+#' c + stat_smooth(method=lm) + geom_point()
+#' c + stat_smooth(method=lm, fullrange = TRUE) + geom_point()
+#'
#' # Geoms and stats are automatically split by aesthetics that are factors
#' c <- ggplot(mtcars, aes(y=wt, x=mpg, colour=factor(cyl)))
-#' c + stat_smooth(method=lm) + geom_point()
-#' c + stat_smooth(method=lm, aes(fill = factor(cyl))) + geom_point()
-#' c + stat_smooth(method=lm, fullrange=TRUE, alpha = 0.1) + geom_point()
-#'
+#' c + stat_smooth(method=lm) + geom_point()
+#' c + stat_smooth(method=lm, aes(fill = factor(cyl))) + geom_point()
+#' c + stat_smooth(method=lm, fullrange=TRUE, alpha = 0.1) + geom_point()
+#'
#' # Use qplot instead
#' qplot(qsec, wt, data=mtcars, geom=c("smooth", "point"))
-#'
+#'
#' # Example with logistic regression
#' data("kyphosis", package="rpart")
#' qplot(Age, Kyphosis, data=kyphosis)
#' qplot(Age, data=kyphosis, facets = . ~ Kyphosis, binwidth = 10)
#' qplot(Age, Kyphosis, data=kyphosis, position="jitter")
#' qplot(Age, Kyphosis, data=kyphosis, position=position_jitter(height=0.1))
-#'
+#'
#' qplot(Age, as.numeric(Kyphosis) - 1, data = kyphosis) +
#' stat_smooth(method="glm", family="binomial")
#' qplot(Age, as.numeric(Kyphosis) - 1, data=kyphosis) +
#' stat_smooth(method="glm", family="binomial", formula = y ~ ns(x, 2))
#' }
-stat_smooth <- function (mapping = NULL, data = NULL, geom = "smooth", position = "identity",
-method = "auto", formula = y ~ x, se = TRUE, n = 80, fullrange = FALSE,
-level = 0.95, na.rm = FALSE, ...) {
- StatSmooth$new(mapping = mapping, data = data, geom = geom, position = position,
- method = method, formula = formula, se = se, n = n, fullrange = fullrange,
+stat_smooth <- function (mapping = NULL, data = NULL, geom = "smooth", position = "identity",
+method = "auto", formula = y ~ x, se = TRUE, n = 80, fullrange = FALSE,
+level = 0.95, na.rm = FALSE, ...) {
+ StatSmooth$new(mapping = mapping, data = data, geom = geom, position = position,
+ method = method, formula = formula, se = se, n = n, fullrange = fullrange,
level = level, na.rm = na.rm, ...)
}
@@ -110,9 +110,9 @@ StatSmooth <- proto(Stat, {
calculate_groups <- function(., data, scales, method="auto", formula=y~x, ...) {
rows <- daply(data, .(group), function(df) length(unique(df$x)))
-
+
if (all(rows == 1) && length(rows) > 1) {
- message("geom_smooth: Only one unique x value each group.",
+ message("geom_smooth: Only one unique x value each group.",
"Maybe you want aes(group = 1)?")
return(data.frame())
}
@@ -120,7 +120,7 @@ StatSmooth <- proto(Stat, {
# Figure out what type of smoothing to do: loess for small datasets,
# gam with a cubic regression basis for large data
# This is based on the size of the _largest_ group.
- if (is.character(method) && method == "auto") {
+ if (identical(method, "auto")) {
groups <- count(data, "group")
if (max(groups$freq) < 1000) {
@@ -129,7 +129,6 @@ StatSmooth <- proto(Stat, {
' so using loess.',
' Use \'method = x\' to change the smoothing method.')
} else {
- try_require("mgcv")
method <- "gam"
formula <- y ~ s(x, bs = "cs")
message('geom_smooth: method="auto" and size of largest group is >=1000,',
@@ -137,41 +136,42 @@ StatSmooth <- proto(Stat, {
' Use \'method = x\' to change the smoothing method.')
}
}
+ if (identical(method, "gam")) try_require("mgcv")
.super$calculate_groups(., data, scales, method = method, formula = formula, ...)
}
-
+
calculate <- function(., data, scales, method="auto", formula=y~x, se = TRUE, n=80, fullrange=FALSE, xseq = NULL, level=0.95, na.rm = FALSE, ...) {
data <- remove_missing(data, na.rm, c("x", "y"), name="stat_smooth")
if (length(unique(data$x)) < 2) {
# Not enough data to perform fit
return(data.frame())
}
-
+
if (is.null(data$weight)) data$weight <- 1
-
+
if (is.null(xseq)) {
if (is.integer(data$x)) {
if (fullrange) {
xseq <- scale_dimension(scales$x, c(0, 0))
} else {
xseq <- sort(unique(data$x))
- }
+ }
} else {
if (fullrange) {
range <- scale_dimension(scales$x, c(0, 0))
} else {
- range <- range(data$x, na.rm=TRUE)
- }
+ range <- range(data$x, na.rm=TRUE)
+ }
xseq <- seq(range[1], range[2], length=n)
- }
+ }
}
if (is.character(method)) method <- match.fun(method)
-
- method.special <- function(...)
+
+ method.special <- function(...)
method(formula, data=data, weights=weight, ...)
model <- safe.call(method.special, list(...), names(formals(method)))
-
+
predictdf(model, xseq, se, level)
}
diff --git a/R/stat-spoke.r b/R/stat-spoke.r
index 8525dfc..79a11ef 100644
--- a/R/stat-spoke.r
+++ b/R/stat-spoke.r
@@ -1,6 +1,6 @@
#' Convert angle and radius to xend and yend.
#'
-#' @section Aesthetics:
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat", "spoke")}
#'
#' @inheritParams stat_identity
@@ -12,12 +12,12 @@
#' df <- expand.grid(x = 1:10, y=1:10)
#' df$angle <- runif(100, 0, 2*pi)
#' df$speed <- runif(100, 0, 0.5)
-#'
+#'
#' qplot(x, y, data=df) + stat_spoke(aes(angle=angle), radius = 0.5)
#' last_plot() + scale_y_reverse()
-#'
+#'
#' qplot(x, y, data=df) + stat_spoke(aes(angle=angle, radius=speed))
-stat_spoke <- function (mapping = NULL, data = NULL, geom = "segment", position = "identity", ...) {
+stat_spoke <- function (mapping = NULL, data = NULL, geom = "segment", position = "identity", ...) {
StatSpoke$new(mapping = mapping, data = data, geom = geom, position = position, ...)
}
@@ -35,5 +35,5 @@ StatSpoke <- proto(Stat, {
default_aes <- function(.) aes(xend = ..xend.., yend = ..yend..)
required_aes <- c("x", "y", "angle", "radius")
default_geom <- function(.) GeomSegment
-
+
})
diff --git a/R/stat-sum.r b/R/stat-sum.r
index af4dd42..7de2d30 100644
--- a/R/stat-sum.r
+++ b/R/stat-sum.r
@@ -1,9 +1,9 @@
#' Sum unique values. Useful for overplotting on scatterplots.
-#'
-#' @section Aesthetics:
+#'
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat", "sum")}
#'
-#' @seealso \code{\link{ggfluctuation}} for a fluctuation diagram,
+#' @seealso \code{\link{ggfluctuation}} for a fluctuation diagram,
#' @inheritParams stat_identity
#' @return a data.frame with additional columns
#' \item{n}{number of observations at position}
@@ -24,7 +24,7 @@
#' # by overall proportion
#' d + stat_sum(aes(group = 1))
#' d + stat_sum(aes(group = 1)) + scale_size(range = c(3, 10))
-#' d + stat_sum(aes(group = 1)) + scale_area(range = c(3, 10))
+#' d + stat_sum(aes(group = 1)) + scale_size_area(max_size = 10)
#'
#' # by cut
#' d + stat_sum(aes(group = cut))
@@ -33,29 +33,29 @@
#' # by clarity
#' d + stat_sum(aes(group = clarity))
#' d + stat_sum(aes(group = clarity, colour = cut))
-#'
+#'
#' # Instead of proportions, can also use sums
#' d + stat_sum(aes(size = ..n..))
-#'
+#'
#' # Can also weight by another variable
#' d + stat_sum(aes(group = 1, weight = price))
#' d + stat_sum(aes(group = 1, weight = price, size = ..n..))
-#'
+#'
#' # Or using qplot
#' qplot(cut, clarity, data = diamonds)
-#' qplot(cut, clarity, data = diamonds, stat = "sum", group = 1)
+#' qplot(cut, clarity, data = diamonds, stat = "sum", group = 1)
#' }
-stat_sum <- function (mapping = NULL, data = NULL, geom = "point", position = "identity", ...) {
+stat_sum <- function (mapping = NULL, data = NULL, geom = "point", position = "identity", ...) {
StatSum$new(mapping = mapping, data = data, geom = geom, position = position, ...)
}
-
+
StatSum <- proto(Stat, {
objname <- "sum"
default_aes <- function(.) aes(size = ..prop..)
required_aes <- c("x", "y")
default_geom <- function(.) GeomPoint
-
+
calculate_groups <- function(., data, scales, ...) {
if (is.null(data$weight)) data$weight <- 1
diff --git a/R/stat-summary-2d.r b/R/stat-summary-2d.r
index 9b8678c..ac2ff9b 100644
--- a/R/stat-summary-2d.r
+++ b/R/stat-summary-2d.r
@@ -1,11 +1,11 @@
#' Apply function for 2D rectangular bins.
#'
-#' @section Aesthetics:
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat", "summary2d")}
#'
#' \code{stat_summary2d} is 2D version of \code{\link{stat_summary}}. The data are devided by \code{x} and \code{y}.
#' \code{z} in each cell is passed to arbitral summary function.
-#'
+#'
#' \code{stat_summary2d} requires the following aesthetics:
#'
#' \itemize{
@@ -13,7 +13,7 @@
#' \item \code{y}: vertical position
#' \item \code{z}: value passed to the summary function
#' }
-#'
+#'
#' @seealso \code{\link{stat_summary_hex}} for hexagonal summarization. \code{\link{stat_bin2d}} for the binning options.
#' @title Apply funciton for 2D rectangular bins.
#' @inheritParams stat_identity
@@ -31,10 +31,10 @@
#' d + stat_summary2d(fun = function(x) sum(x^2))
#' d + stat_summary2d(fun = var)
#' }
-stat_summary2d <- function (mapping = NULL, data = NULL, geom = NULL, position = "identity",
+stat_summary2d <- function (mapping = NULL, data = NULL, geom = NULL, position = "identity",
bins = 30, drop = TRUE, fun = mean, ...) {
- StatSummary2d$new(mapping = mapping, data = data, geom = geom, position = position,
+ StatSummary2d$new(mapping = mapping, data = data, geom = geom, position = position,
bins = bins, drop = drop, fun = fun, ...)
}
@@ -48,7 +48,7 @@ StatSummary2d <- proto(Stat, {
calculate <- function(., data, scales, binwidth = NULL, bins = 30, breaks = NULL, origin = NULL, drop = TRUE, fun = mean, ...) {
data <- remove_missing(data, FALSE, c("x", "y", "z"), name="stat_summary2d")
-
+
range <- list(
x = scale_dimension(scales$x, c(0, 0)),
y = scale_dimension(scales$y, c(0, 0))
@@ -60,11 +60,11 @@ StatSummary2d <- proto(Stat, {
} else {
stopifnot(is.numeric(origin))
stopifnot(length(origin) == 2)
- }
+ }
originf <- function(x) if (is.integer(x)) -0.5 else min(x)
if (is.na(origin[1])) origin[1] <- originf(data$x)
if (is.na(origin[2])) origin[2] <- originf(data$y)
-
+
# Determine binwidth, if omitted
if (is.null(binwidth)) {
binwidth <- c(NA, NA)
@@ -77,7 +77,7 @@ StatSummary2d <- proto(Stat, {
binwidth[2] <- 1
} else {
binwidth[2] <- diff(range$y) / bins
- }
+ }
}
stopifnot(is.numeric(binwidth))
stopifnot(length(binwidth) == 2)
@@ -90,7 +90,7 @@ StatSummary2d <- proto(Stat, {
)
} else {
stopifnot(is.list(breaks))
- stopifnot(length(breaks) == 2)
+ stopifnot(length(breaks) == 2)
stopifnot(all(sapply(breaks, is.numeric)))
}
names(breaks) <- c("x", "y")
@@ -102,7 +102,7 @@ StatSummary2d <- proto(Stat, {
ans <- ddply(data.frame(data, xbin, ybin), .(xbin, ybin), function(d) data.frame(value = fun(d$z, ...)))
if (drop) ans <- na.omit(ans)
-
+
within(ans,{
xint <- as.numeric(xbin)
xmin <- breaks$x[xint]
diff --git a/R/stat-summary-hex.r b/R/stat-summary-hex.r
index eae0891..580650c 100644
--- a/R/stat-summary-hex.r
+++ b/R/stat-summary-hex.r
@@ -1,11 +1,11 @@
##' Apply function for 2D hexagonal bins.
##'
-##' @section Aesthetics:
+##' @section Aesthetics:
##' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat", "summaryhex")}
##'
##' \code{stat_summary2d} is hexagonal version of \code{\link{stat_summary}}. The data are devided by \code{x} and \code{y}.
##' \code{z} in each cell is passed to arbitral summary function.
-##'
+##'
##' \code{stat_summary-hex} requires the following aesthetics:
##'
##' \itemize{
@@ -13,7 +13,7 @@
##' \item \code{y}: vertical position
##' \item \code{z}: value passed to the summary function
##' }
-##'
+##'
##' @seealso \code{\link{stat_summary2d}} for rectangular summarization. \code{\link{stat_bin2d}} for the hexagon-ing options.
##' @title Apply funciton for 2D hexagonal bins.
##' @inheritParams stat_identity
@@ -25,14 +25,14 @@
##' @examples
##' d <- ggplot(diamonds, aes(carat, depth, z = price))
##' d + stat_summary_hex()
-##'
+##'
##' # Specifying function
##' d + stat_summary_hex(fun = function(x) sum(x^2))
##' d + stat_summary_hex(fun = var, na.rm = TRUE)
-stat_summary_hex <- function (mapping = NULL, data = NULL, geom = "hex", position = "identity",
+stat_summary_hex <- function (mapping = NULL, data = NULL, geom = "hex", position = "identity",
bins = 30, drop = TRUE, fun = mean, ...) {
-
- StatSummaryhex$new(mapping = mapping, data = data, geom = geom, position = position,
+
+ StatSummaryhex$new(mapping = mapping, data = data, geom = geom, position = position,
bins = bins, drop = drop, fun = fun, ...)
}
@@ -42,43 +42,43 @@ StatSummaryhex <- proto(Stat, {
default_aes <- function(.) aes(fill = ..value..)
required_aes <- c("x", "y", "z")
default_geom <- function(.) GeomHex
-
+
calculate <- function(., data, scales, binwidth = NULL, bins = 30, drop = TRUE, fun = mean, ...) {
try_require("hexbin")
data <- remove_missing(data, FALSE, c("x", "y", "z"), name="stat_summary_hex")
if (is.null(binwidth)) {
- binwidth <- c(
+ binwidth <- c(
diff(scale_dimension(scales$x, c(0, 0))) / bins,
diff(scale_dimension(scales$y, c(0, 0))) / bins
)
}
try_require("hexbin")
-
+
# Convert binwidths into bounds + nbins
x <- data$x
y <- data$y
-
+
xbnds <- c(
- round_any(min(x), binwidth[1], floor) - 1e-6,
+ round_any(min(x), binwidth[1], floor) - 1e-6,
round_any(max(x), binwidth[1], ceiling) + 1e-6
)
xbins <- diff(xbnds) / binwidth[1]
-
+
ybnds <- c(
- round_any(min(y), binwidth[1], floor) - 1e-6,
+ round_any(min(y), binwidth[1], floor) - 1e-6,
round_any(max(y), binwidth[2], ceiling) + 1e-6
)
ybins <- diff(ybnds) / binwidth[2]
-
+
# Call hexbin
hb <- hexbin(
- x, xbnds = xbnds, xbins = xbins,
+ x, xbnds = xbnds, xbins = xbins,
y, ybnds = ybnds, shape = ybins / xbins,
IDs = TRUE
)
-
+
value <- tapply(data$z, hb at cID, fun, ...)
# Convert to data frame
diff --git a/R/stat-summary.r b/R/stat-summary.r
index 18e67a8..d36d3d1 100644
--- a/R/stat-summary.r
+++ b/R/stat-summary.r
@@ -1,19 +1,21 @@
#' Summarise y values at every unique x.
#'
#' \code{stat_summary} allows for tremendous flexibilty in the specification
-#' of summary functions. The summary function can either operate on a data
-#' frame (with argument name \code{fun.data}) or on a vector (\code{fun.y},
-#' \code{fun.ymax}, \code{fun.ymin}).
-#'
+#' of summary functions. The summary function can either supply individual
+#' summary functions for each of y, ymin and ymax (with \code{fun.y},
+#' \code{fun.ymax}, \code{fun.ymin}), or return a data frame containing any
+#' number of aesthetiics with with \code{fun.data}. All summary functions
+#' are called with a single vector of values, \code{x}.
+#'
#' A simple vector function is easiest to work with as you can return a single
#' number, but is somewhat less flexible. If your summary function operates
#' on a data.frame it should return a data frame with variables that the geom
#' can use.
#'
-#' @section Aesthetics:
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat", "summary")}
#'
-#' @seealso \code{\link{geom_errorbar}}, \code{\link{geom_pointrange}},
+#' @seealso \code{\link{geom_errorbar}}, \code{\link{geom_pointrange}},
#' \code{\link{geom_linerange}}, \code{\link{geom_crossbar}} for geoms to
#' display summarised data
#' @inheritParams stat_identity
@@ -32,7 +34,7 @@
#' # Basic operation on a small dataset
#' d <- qplot(cyl, mpg, data=mtcars)
#' d + stat_summary(fun.data = "mean_cl_boot", colour = "red")
-#'
+#'
#' p <- qplot(cyl, mpg, data = mtcars, stat="summary", fun.y = "mean")
#' p
#' # Don't use ylim to zoom into a summary plot - this throws the
@@ -40,46 +42,48 @@
#' p + ylim(15, 30)
#' # Instead use coord_cartesian
#' p + coord_cartesian(ylim = c(15, 30))
-#'
-#' # You can supply individual functions to summarise the value at
+#'
+#' # You can supply individual functions to summarise the value at
#' # each x:
-#'
+#'
#' stat_sum_single <- function(fun, geom="point", ...) {
-#' stat_summary(fun.y=fun, colour="red", geom=geom, size = 3, ...)
+#' stat_summary(fun.y=fun, colour="red", geom=geom, size = 3, ...)
#' }
-#'
+#'
#' d + stat_sum_single(mean)
#' d + stat_sum_single(mean, geom="line")
#' d + stat_sum_single(median)
#' d + stat_sum_single(sd)
-#'
-#' d + stat_summary(fun.y = mean, fun.ymin = min, fun.ymax = max,
+#'
+#' d + stat_summary(fun.y = mean, fun.ymin = min, fun.ymax = max,
#' colour = "red")
-#'
+#'
#' d + aes(colour = factor(vs)) + stat_summary(fun.y = mean, geom="line")
-#'
+#'
#' # Alternatively, you can supply a function that operates on a data.frame.
#' # A set of useful summary functions is provided from the Hmisc package:
-#'
+#'
#' stat_sum_df <- function(fun, geom="crossbar", ...) {
#' stat_summary(fun.data=fun, colour="red", geom=geom, width=0.2, ...)
#' }
-#'
-#' d + stat_sum_df("mean_cl_boot")
-#' d + stat_sum_df("mean_sdl")
-#' d + stat_sum_df("mean_sdl", mult=1)
-#' d + stat_sum_df("median_hilow")
-#'
+#'
+#' # The crossbar geom needs grouping to be specified when used with
+#' # a continuous x axis.
+#' d + stat_sum_df("mean_cl_boot", mapping = aes(group = cyl))
+#' d + stat_sum_df("mean_sdl", mapping = aes(group = cyl))
+#' d + stat_sum_df("mean_sdl", mult = 1, mapping = aes(group = cyl))
+#' d + stat_sum_df("median_hilow", mapping = aes(group = cyl))
+#'
#' # There are lots of different geoms you can use to display the summaries
-#'
-#' d + stat_sum_df("mean_cl_normal")
+#'
+#' d + stat_sum_df("mean_cl_normal", mapping = aes(group = cyl))
#' d + stat_sum_df("mean_cl_normal", geom = "errorbar")
#' d + stat_sum_df("mean_cl_normal", geom = "pointrange")
#' d + stat_sum_df("mean_cl_normal", geom = "smooth")
-#'
+#'
#' # Summaries are more useful with a bigger data set:
#' mpg2 <- subset(mpg, cyl != 5L)
-#' m <- ggplot(mpg2, aes(x=cyl, y=hwy)) +
+#' m <- ggplot(mpg2, aes(x=cyl, y=hwy)) +
#' geom_point() +
#' stat_summary(fun.data = "mean_sdl", geom = "linerange",
#' colour = "red", size = 2, mult = 1) +
@@ -94,31 +98,31 @@
#' m2
#' # Notice how the overplotting skews off visual perception of the mean
#' # supplementing the raw data with summary statistics is _very_ important
-#'
+#'
#' # Next, we'll look at votes on a log scale.
-#'
-#' # Transforming the scale means the data are transformed
+#'
+#' # Transforming the scale means the data are transformed
#' # first, after which statistics are computed:
#' m2 + scale_y_log10()
#' # Transforming the coordinate system occurs after the
-#' # statistic has been computed. This means we're calculating the summary on the raw data
+#' # statistic has been computed. This means we're calculating the summary on the raw data
#' # and stretching the geoms onto the log scale. Compare the widths of the
#' # standard errors.
#' m2 + coord_trans(y="log10")
#' }
-stat_summary <- function (mapping = NULL, data = NULL, geom = "pointrange", position = "identity", ...) {
+stat_summary <- function (mapping = NULL, data = NULL, geom = "pointrange", position = "identity", ...) {
StatSummary$new(mapping = mapping, data = data, geom = geom, position = position, ...)
}
-
+
StatSummary <- proto(Stat, {
objname <- "summary"
default_geom <- function(.) GeomPointrange
required_aes <- c("x", "y")
-
+
calculate_groups <- function(., data, scales, fun.data = NULL, fun.y = NULL, fun.ymax = NULL, fun.ymin = NULL, na.rm = FALSE, ...) {
data <- remove_missing(data, na.rm, c("x", "y"), name = "stat_summary")
-
+
if (!missing(fun.data)) {
# User supplied function that takes complete data frame as input
fun.data <- match.fun(fun.data)
@@ -128,7 +132,7 @@ StatSummary <- proto(Stat, {
} else {
# User supplied individual vector functions
fs <- compact(list(ymin = fun.ymin, y = fun.y, ymax = fun.ymax))
-
+
fun <- function(df, ...) {
res <- llply(fs, function(f) do.call(f, list(df$y, ...)))
names(res) <- names(fs)
@@ -138,35 +142,35 @@ StatSummary <- proto(Stat, {
summarise_by_x(data, fun, ...)
}
-
-
+
+
})
# Summarise a data.frame by parts
# Summarise a data frame by unique value of x
-#
-# This function is used by \code{\link{stat_summary}} to break a
+#
+# This function is used by \code{\link{stat_summary}} to break a
# data.frame into pieces, summarise each piece, and join the pieces
# back together, retaining original columns unaffected by the summary.
-#
+#
# @param \code{\link{data.frame}} to summarise
# @param vector to summarise by
# @param summary function (must take and return a data.frame)
# @param other arguments passed on to summary function
# @keyword internal
summarise_by_x <- function(data, summary, ...) {
- summary <- ddply(data, .(group, x), summary, ...)
- unique <- ddply(data, .(group, x), uniquecols)
+ summary <- ddply(data, c("group", "x"), summary, ...)
+ unique <- ddply(data, c("group", "x"), uniquecols)
unique$y <- NULL
-
+
merge(summary, unique, by = c("x", "group"))
}
#' Wrap up a selection of summary functions from Hmisc to make it easy to use
#' with \code{\link{stat_summary}}.
-#'
+#'
#' See the Hmisc documentation for details of their options.
-#'
+#'
#' @param x a numeric vector
#' @param ... other arguments passed on to the respective Hmisc function.
#' @seealso \code{\link[Hmisc]{smean.cl.boot}},
@@ -178,25 +182,25 @@ NULL
wrap_hmisc <- function(fun) {
function(x, ...) {
try_require("Hmisc")
-
+
result <- safe.call(fun, list(x = x, ...))
rename(
- data.frame(t(result)),
+ data.frame(t(result)),
c(Median = "y", Mean = "y", Lower = "ymin", Upper = "ymax"),
warn_missing = FALSE
- )
+ )
}
}
-#' @export
+#' @export
#' @rdname hmisc
mean_cl_boot <- wrap_hmisc("smean.cl.boot")
-#' @export
+#' @export
#' @rdname hmisc
mean_cl_normal <- wrap_hmisc("smean.cl.normal")
-#' @export
+#' @export
#' @rdname hmisc
mean_sdl <- wrap_hmisc("smean.sdl")
-#' @export
+#' @export
#' @rdname hmisc
median_hilow <- wrap_hmisc("smedian.hilow")
@@ -206,7 +210,7 @@ median_hilow <- wrap_hmisc("smedian.hilow")
#' @param mult number of multiples of standard error
#' @seealso for use with \code{\link{stat_summary}}
#' @export
-mean_se <- function(x, mult = 1) {
+mean_se <- function(x, mult = 1) {
x <- na.omit(x)
se <- mult * sqrt(var(x) / length(x))
mean <- mean(x)
diff --git a/R/stat-unique.r b/R/stat-unique.r
index 53c73d1..a97eefa 100644
--- a/R/stat-unique.r
+++ b/R/stat-unique.r
@@ -1,6 +1,6 @@
#' Remove duplicates.
#'
-#' @section Aesthetics:
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat", "unique")}
#'
#' @export
@@ -8,15 +8,15 @@
#' @examples
#' ggplot(mtcars, aes(vs, am)) + geom_point(alpha = 0.1)
#' ggplot(mtcars, aes(vs, am)) + geom_point(alpha = 0.1, stat="unique")
-stat_unique <- function (mapping = NULL, data = NULL, geom = "point", position = "identity", ...) {
+stat_unique <- function (mapping = NULL, data = NULL, geom = "point", position = "identity", ...) {
StatUnique$new(mapping = mapping, data = data, geom = geom, position = position, ...)
}
-
+
StatUnique <- proto(Stat, {
- objname <- "unique"
+ objname <- "unique"
desc <- "Remove duplicates"
-
+
default_geom <- function(.) GeomPoint
-
+
calculate_groups <- function(., data, scales, ...) unique(data)
})
diff --git a/R/stat-vline.r b/R/stat-vline.r
index c9eb899..69a1314 100644
--- a/R/stat-vline.r
+++ b/R/stat-vline.r
@@ -6,7 +6,7 @@
#' @export
#' @examples
#' # see geom_abline
-stat_abline <- function (mapping = NULL, data = NULL, geom = "abline", position = "identity", ...) {
+stat_abline <- function (mapping = NULL, data = NULL, geom = "abline", position = "identity", ...) {
StatAbline$new(mapping = mapping, data = data, geom = geom, position = position, ...)
}
@@ -28,7 +28,7 @@ StatAbline <- proto(Stat, {
}
unique(data)
}
-
+
default_geom <- function(.) GeomAbline
})
@@ -40,9 +40,9 @@ StatAbline <- proto(Stat, {
#' @export
#' @examples
#' # see geom_vline
-stat_vline <- function (mapping = NULL, data = NULL, geom = "vline", position = "identity",
+stat_vline <- function (mapping = NULL, data = NULL, geom = "vline", position = "identity",
xintercept, ...) {
- StatVline$new(mapping = mapping, data = data, geom = geom, position = position,
+ StatVline$new(mapping = mapping, data = data, geom = geom, position = position,
xintercept = xintercept, ...)
}
@@ -54,13 +54,13 @@ StatVline <- proto(Stat, {
stop("stat_vline now uses xintercept instead of intercept")
}
data <- compute_intercept(data, xintercept, "x")
-
+
unique(within(data, {
x <- xintercept
xend <- xintercept
}))
}
-
+
required_aes <- c()
default_geom <- function(.) GeomVline
})
@@ -73,12 +73,12 @@ StatVline <- proto(Stat, {
#' @export
#' @examples
#' # see geom_hline
-stat_hline <- function (mapping = NULL, data = NULL, geom = "hline", position = "identity",
+stat_hline <- function (mapping = NULL, data = NULL, geom = "hline", position = "identity",
yintercept, ...) {
- StatHline$new(mapping = mapping, data = data, geom = geom, position = position,
+ StatHline$new(mapping = mapping, data = data, geom = geom, position = position,
yintercept = yintercept, ...)
}
-
+
StatHline <- proto(Stat, {
calculate <- function(., data, scales, yintercept = NULL, intercept, ...) {
if (!missing(intercept)) {
@@ -86,19 +86,19 @@ StatHline <- proto(Stat, {
}
data <- compute_intercept(data, yintercept, "y")
-
+
unique(within(data, {
y <- yintercept
yend <- yintercept
}))
}
-
- objname <- "hline"
+
+ objname <- "hline"
desc <- "Add a horizontal line"
-
+
required_aes <- c()
default_geom <- function(.) GeomHline
-
+
examples <- function(.) {
# See geom_hline for examples
}
@@ -106,19 +106,19 @@ StatHline <- proto(Stat, {
# Compute intercept for vline and hline from data and parameters
-#
+#
# @keyword internal
compute_intercept <- function(data, intercept, var = "x") {
ivar <- paste(var, "intercept", sep = "")
if (is.null(intercept)) {
# Intercept comes from data, default to 0 if not set
if (is.null(data[[ivar]])) data[[ivar]] <- 0
-
+
} else if (is.numeric(intercept)) {
# Intercept is a numeric vector of positions
data <- data[rep(1, length(intercept)), ]
data[[ivar]] <- intercept
-
+
} else if (is.character(intercept) || is.function(intercept)) {
# Intercept is a function
f <- match.fun(intercept)
@@ -126,9 +126,9 @@ compute_intercept <- function(data, intercept, var = "x") {
data[[ivar]] <- f(data[[var]])
data
}
- data <- ddply(data, .(group), trans)
+ data <- ddply(data, "group", trans)
} else {
- stop("Invalid intercept type: should be a numeric vector, a function",
+ stop("Invalid intercept type: should be a numeric vector, a function",
", or a name of a function", call. = FALSE)
}
data
diff --git a/R/stat-ydensity.r b/R/stat-ydensity.r
index c5ac5cc..6989246 100644
--- a/R/stat-ydensity.r
+++ b/R/stat-ydensity.r
@@ -1,6 +1,6 @@
#' 1d kernel density estimate along y axis, for violin plot.
#'
-#' @section Aesthetics:
+#' @section Aesthetics:
#' \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat", "ydensity")}
#'
#' @inheritParams stat_density
@@ -45,7 +45,7 @@ StatYdensity <- proto(Stat, {
# choose how violins are scaled relative to each other
scale <- match.arg(scale, c("area", "equal", "count", "width"))
if (scale == "equal") {
- gg_dep("0.9.2", "scale=\"area\" is deprecated; in the future, use scale=\"equal\" instead.")
+ gg_dep("0.9.2", "Use scale=\"equal\" instead.")
scale <- "area"
}
diff --git a/R/summary.r b/R/summary.r
index 2da4bb0..e66a6a9 100644
--- a/R/summary.r
+++ b/R/summary.r
@@ -1,5 +1,5 @@
#' Displays a useful description of a ggplot object
-#'
+#'
#' @param object ggplot2 object to summarise
#' @param ... other arguments ignored (for compatibility with generic)
#' @keywords internal
@@ -12,29 +12,29 @@ summary.ggplot <- function(object, ...) {
paste(strwrap(x, exdent = 2), collapse = "\n"),
"\n", sep =""
)
-
+
defaults <- function() {
paste(mapply(function(x, n) {
paste(n, deparse(x), sep="=")
}, object$mapping, names(object$mapping)), collapse=", ")
}
-
+
# cat("Title: ", object$title, "\n", sep="")
# cat("-----------------------------------\n")
if (!is.null(object$data)) {
output <- paste(
- "data: ", paste(names(object$data), collapse=", "),
- " [", nrow(object$data), "x", ncol(object$data), "] ",
+ "data: ", paste(names(object$data), collapse=", "),
+ " [", nrow(object$data), "x", ncol(object$data), "] ",
"\n", sep="")
cat(wrap(output))
}
if (length(object$mapping) > 0) {
- cat("mapping: ", clist(object$mapping), "\n", sep="")
+ cat("mapping: ", clist(object$mapping), "\n", sep="")
}
if (object$scales$n() > 0) {
cat("scales: ", paste(object$scales$input(), collapse = ", "), "\n")
}
-
+
cat("faceting: ")
print(object$facet)
@@ -42,4 +42,4 @@ summary.ggplot <- function(object, ...) {
cat("-----------------------------------\n")
invisible(lapply(object$layers, function(x) {print(x); cat("\n")}))
-}
+}
diff --git a/R/templates.r b/R/templates.r
index ee080b9..2f32fb3 100644
--- a/R/templates.r
+++ b/R/templates.r
@@ -1,207 +1,46 @@
-#' Make a parallel coordinates plot.
-#'
-#' One way to think about a parallel coordinates plot, is as plotting
-#' the data after it has been transformed to gain a new variable. This
-#' function does this using \code{\link[reshape2]{melt}}.
-#'
-#' This gives us enormous flexibility as we have separated out the
-#' type of drawing (lines by tradition) and can now use any of the existing
-#' geom functions. In particular this makes it very easy to create parallel
-#' boxplots, as shown in the example.
-#'
-#' @param data data frame
-#' @param vars variables to include in parallel coordinates plot
-#' @param ... other arguments passed on plot creation
-#' @export
-#' @examples
-#' \dontrun{
-#' ggpcp(mtcars) + geom_line()
-#' ggpcp(mtcars, vars=names(mtcars[2:6])) + geom_line()
-#' ggpcp(mtcars) + geom_boxplot(aes(group=variable))
+#' Plot templates.
#'
-#' p <- ggpcp(mtcars, vars=names(mtcars[2:6]))
-#' p + geom_line()
-#' p + geom_line(aes(colour=mpg))
-#' }
-ggpcp <- function(data, vars=names(data), ...) {
- gg_dep("0.9.1", "ggpcp is deprecated.")
- scaled <- as.data.frame(lapply(data[, vars], rescale01))
- data <- cunion(scaled, data)
-
- data$ROWID <- 1:nrow(data)
- molten <- melt(data, m=vars)
+#' These plot templates are deprecated in an attempt to make ggplot2 as
+#' streamlined as possible, and to avoid bugs in these poorly tested
+#' functions. See the \pkg{GGally} package for some alternatives.
+#'
+#' @name plot-templates
+#' @keywords internal
+NULL
- ggplot(molten, aes_string(x = "variable", y = "value", group = "ROWID"),
- ...)
+#' @export
+#' @rdname plot-templates
+ggpcp <- function(data, vars=names(data), ...) {
+ gg_dep("0.9.1", "ggpcp")
}
-#' Create a fluctuation plot.
-#'
-#' A fluctutation diagram is a graphical representation of a contingency
-#' table. This function only supports 2D contingency tables
-#' at present but extension to higher dimensions should be
-#' relatively straightforward.
-#'
-#' With the default size fluctuation diagram, area is proportional to the
-#' count (length of sides proportional to sqrt(count)).
-#'
-#' @param table a table of values, or a data frame with three columns,
-#' the last column being frequency
-#' @param type "size", or "colour" to create traditional heatmap
-#' @param floor don't display cells smaller than this value
-#' @param ceiling round cells to at most this value
-#' @param na.rm If \code{TRUE}, silently remove missing values.
#' @export
-#' @examples
-#' \dontrun{
-#' ggfluctuation(table(movies$Action, movies$Comedy))
-#' ggfluctuation(table(movies$Action, movies$mpaa))
-#' ggfluctuation(table(movies$Action, movies$Comedy), type="colour")
-#' ggfluctuation(table(warpbreaks$breaks, warpbreaks$tension))
-#' }
+#' @rdname plot-templates
ggfluctuation <- function(table, type="size", floor=0, ceiling=max(table$freq, na.rm=TRUE)) {
- gg_dep("0.9.1", "ggfluctuation is deprecated.")
- if (is.table(table)) table <- as.data.frame(t(table))
-
- oldnames <- names(table)
- names(table) <- c("x","y", "result")
-
- table <- transform(table,
- x = as.factor(x),
- y = as.factor(y),
- freq = result
- )
-
- if (type =="size") {
- table <- transform(table,
- freq = sqrt(pmin(freq, ceiling) / ceiling),
- border = ifelse(is.na(freq), "grey90", ifelse(freq > ceiling, "grey30", "grey50"))
- )
- table[is.na(table$freq), "freq"] <- 1
- table <- subset(table, freq * ceiling >= floor)
- }
-
- if (type=="size") {
- nx <- length(levels(table$x))
- ny <- length(levels(table$y))
-
- p <- ggplot(table,
- aes_string(x="x", y="y", height="freq", width="freq", fill="border")) +
- geom_tile(colour="white") +
- scale_fill_identity() +
- theme(aspect.ratio = ny / nx)
-
- # geom_rect(aes(xmin = as.numeric(x), ymin = as.numeric(y), xmax = as.numeric(x) + freq, ymax = as.numeric(y) + freq), colour="white") +
-
- } else {
- p <- ggplot(table, aes_string(x="x", y="y", fill="freq")) +
- geom_tile(colour="grey50") +
- scale_fill_gradient2(low="white", high="darkgreen")
- }
-
- p$xlabel <- oldnames[1]
- p$ylabel <- oldnames[2]
- p
+ gg_dep("0.9.1", "ggfluctuation")
}
-#' Create a plot to illustrate patterns of missing values.
-#'
-#' The missing values plot is a useful tool to get a rapid
-#' overview of the number and pattern of missing values in a
-#' dataset. Its strength
-#' is much more apparent when used with interactive graphics, as you can
-#' see in Mondrian (\url{http://rosuda.org/mondrian}) where this plot was
-#' copied from.
-#'
-#' @param data input data.frame
-#' @param avoid whether missings should be stacked or dodged, see
-#' \code{\link{geom_bar}} for more details
-#' @param order if \code{TRUE}, order variables by number of missings
-#' @param missing.only if \code{TRUE}, only display variables with some
-#' missing data
-#' @seealso \code{\link{ggstructure}}, \code{\link{ggorder}}
#' @export
-#' @examples
-#' \dontrun{
-#' mmissing <- movies
-#' mmissing[sample(nrow(movies), 1000), sample(ncol(movies), 5)] <- NA
-#' ggmissing(mmissing)
-#' ggmissing(mmissing, order=FALSE, missing.only = FALSE)
-#' ggmissing(mmissing, avoid="dodge") + scale_y_sqrt()
-#' }
+#' @rdname plot-templates
ggmissing <- function(data, avoid="stack", order=TRUE, missing.only = TRUE) {
- gg_dep("0.9.1", "ggmissing is deprecated.")
- missings <- mapply(function(var, name) cbind(as.data.frame(table(missing=factor(is.na(var), levels=c(TRUE, FALSE), labels=c("yes", "no")))), variable=name),
- data, names(data), SIMPLIFY=FALSE
- )
- df <- do.call("rbind", missings)
-
- prop <- df[df$missing == "yes", "Freq"] / (df[df$missing == "no", "Freq"] + df[df$missing == "yes", "Freq"])
- df$prop <- rep(prop, each=2)
-
- if (order) {
- var <- df$variable
- var <- factor(var, levels = levels(var)[order(1 - prop)])
- df$variable <- var
- }
-
- if (missing.only) {
- df <- df[df$prop > 0 & df$prop < 1, , drop=FALSE]
- df$variable <- factor(df$variable)
- }
-
- ggplot(df, aes_string(y="Freq", x="variable", fill="missing")) + geom_bar(position=avoid)
+ gg_dep("0.9.1", "ggmissing")
}
-#' A plot which aims to reveal gross structural anomalies in the data.
-#'
-#' @param data data set to plot
#' @export
-#' @examples
-#' \dontrun{
-#' ggstructure(mtcars)
-#' }
+#' @rdname plot-templates
ggstructure <- function(data) {
- gg_dep("0.9.1", "ggstructure is deprecated.")
- ggpcp(data) +
- aes_string(y="ROWID", fill="value", x="variable") +
- geom_tile() +
- scale_y_continuous("row number", expand = c(0, 1)) +
- scale_fill_gradient2(low="blue", mid="white", high="red", midpoint=0)
+ gg_dep("0.9.1", "ggstructure")
}
-#' A plot to investigate the order in which observations were recorded.
-#'
-#' @param data data set to plot
#' @export
+#' @rdname plot-templates
ggorder <- function(data) {
- gg_dep("0.9.1", "ggorder is deprecated.")
- ggpcp(data) +
- aes_string(x="ROWID", group="variable", y="value") +
- facet_grid(. ~ variable) +
- geom_line() +
- scale_x_continuous("row number")
+ gg_dep("0.9.1", "ggorder")
}
-# Distribution plot.
-ggdist <- function(data, vars=names(data), facets = . ~ .) {
- gg_dep("0.9.1", "ggdist is deprecated.")
- cat <- sapply(data[vars], is.factor)
- facets <- deparse(substitute(facets))
-
- grid.newpage()
- pushViewport(viewport(layout=grid.layout(ncol = ncol(data))))
-
- mapply(function(name, cat, i) {
- p <- ggplot(data) +
- facet_grid(facets) +
- aes_string(x=name, y=1) +
- geom_bar()
-
- pushViewport(viewport(layout.pos.col=i))
- grid.draw(ggplotGrob(p))
- popViewport()
- }, names(data[vars]), cat, 1:ncol(data[vars]))
- invisible()
-
+#' @export
+#' @rdname plot-templates
+plotmatrix <- function(data, mapping=aes(), colour="black") {
+ gg_dep("0.9.2", "Please use GGally::ggpairs.")
}
+
diff --git a/R/theme-defaults.r b/R/theme-defaults.r
index 85d6e46..f84800c 100644
--- a/R/theme-defaults.r
+++ b/R/theme-defaults.r
@@ -1,9 +1,56 @@
-#' A theme with grey background and white gridlines.
+#' ggplot2 themes
+#'
+#' Themes set the general aspect of the plot such as the colour of the
+#' background, gridlines, the size and colour of fonts.
#'
#' @param base_size base font size
#' @param base_family base font family
-#' @aliases theme_gray theme_grey
-#' @export theme_gray theme_grey
+#'
+#' @details \describe{
+#'
+#' \item{\code{theme_gray}}{
+#' The signature ggplot2 theme with a grey background and white gridlines,
+#' designed to put the data forward yet make comparisons easy.}
+#'
+#' \item{\code{theme_bw}}{
+#' The classic dark-on-light ggplot2 theme. May work better for presentations
+#' displayed with a projector.}
+#'
+#' \item{\code{theme_linedraw}}{
+#' A theme with only black lines of various widths on white backgrounds,
+#' reminiscent of a line drawings. Serves a purpose similar to \code{theme_bw}.
+#' Note that this theme has some very thin lines (<< 1 pt) which some journals
+#' may refuse.}
+#'
+#' \item{\code{theme_light}}{
+#' A theme similar to \code{theme_linedraw} but with light grey lines and axes,
+#' to direct more attention towards the data.}
+#'
+#' \item{\code{theme_minimal}}{
+#' A minimalistic theme with no background annotations.}
+#'
+#' \item{\code{theme_classic}}{
+#' A classic-looking theme, with x and y axis lines and no gridlines.}
+#'
+#' }
+#'
+#' @examples
+#' p <- ggplot(mtcars) + geom_point(aes(x = wt, y = mpg,
+#' colour=factor(gear))) + facet_wrap(~am)
+#'
+#' p
+#' p + theme_gray()
+#' p + theme_bw()
+#' p + theme_linedraw()
+#' p + theme_light()
+#' p + theme_minimal()
+#' p + theme_classic()
+#'
+#' @name ggtheme
+NULL
+
+#' @export
+#' @rdname ggtheme
theme_grey <- function(base_size = 12, base_family = "") {
theme(
# Elements in this first block aren't used directly, but are inherited
@@ -46,6 +93,8 @@ theme_grey <- function(base_size = 12, base_family = "") {
panel.grid.major = element_line(colour = "white"),
panel.grid.minor = element_line(colour = "grey95", size = 0.25),
panel.margin = unit(0.25, "lines"),
+ panel.margin.x = NULL,
+ panel.margin.y = NULL,
strip.background = element_rect(fill = "grey80", colour = NA),
strip.text.x = element_text(),
@@ -58,14 +107,12 @@ theme_grey <- function(base_size = 12, base_family = "") {
complete = TRUE
)
}
+#' @export
+#' @rdname ggtheme
theme_gray <- theme_grey
-
-#' A theme with white background and black gridlines.
-#'
-#' @param base_size base font size
-#' @param base_family base font family
#' @export
+#' @rdname ggtheme
theme_bw <- function(base_size = 12, base_family = "") {
# Starts with theme_grey and then modify some parts
theme_grey(base_size = base_size, base_family = base_family) %+replace%
@@ -77,16 +124,50 @@ theme_bw <- function(base_size = 12, base_family = "") {
panel.border = element_rect(fill = NA, colour = "grey50"),
panel.grid.major = element_line(colour = "grey90", size = 0.2),
panel.grid.minor = element_line(colour = "grey98", size = 0.5),
- strip.background = element_rect(fill = "grey80", colour = "grey50"),
- strip.background = element_rect(fill = "grey80", colour = "grey50")
+ strip.background = element_rect(fill = "grey80", colour = "grey50", size = 0.2)
)
}
-#' A minimalistic theme with no background annotations.
-#'
-#' @param base_size base font size
-#' @param base_family base font family
#' @export
+#' @rdname ggtheme
+theme_linedraw <- function(base_size = 12, base_family = "") {
+ # Starts with theme_grey and then modify some parts
+ theme_grey(base_size = base_size, base_family = base_family) %+replace%
+ theme(
+ axis.text = element_text(colour = "black", size = rel(0.8)),
+ axis.ticks = element_line(colour = "black", size = 0.25),
+ legend.key = element_rect(colour = "black", size = 0.25),
+ panel.background = element_rect(fill = "white", colour = NA),
+ panel.border = element_rect(fill = NA, colour = "black", size = 0.5),
+ panel.grid.major = element_line(colour = "black", size = 0.05),
+ panel.grid.minor = element_line(colour = "black", size = 0.01),
+ strip.background = element_rect(fill = "black", colour = NA),
+ strip.text.x = element_text(colour = "white"),
+ strip.text.y = element_text(colour = "white", angle = -90)
+ )
+}
+
+#' @export
+#' @rdname ggtheme
+theme_light <- function(base_size = 12, base_family = "") {
+ # Starts with theme_grey and then modify some parts
+ theme_grey(base_size = base_size, base_family = base_family) %+replace%
+ theme(
+ axis.ticks = element_line(colour = "grey70", size = 0.25),
+ legend.key = element_rect(fill = "white", colour = "grey50", size = 0.25),
+ panel.background = element_rect(fill = "white", colour = NA),
+ panel.border = element_rect(fill = NA, colour = "grey70", size = 0.5),
+ panel.grid.major = element_line(colour = "grey85", size = 0.25),
+ panel.grid.minor = element_line(colour = "grey93", size = 0.125),
+ strip.background = element_rect(fill = "grey70", colour = NA),
+ strip.text.x = element_text(colour = "white"),
+ strip.text.y = element_text(colour = "white", angle = -90)
+ )
+
+}
+
+#' @export
+#' @rdname ggtheme
theme_minimal <- function(base_size = 12, base_family = "") {
# Starts with theme_bw and then modify some parts
theme_bw(base_size = base_size, base_family = base_family) %+replace%
@@ -100,17 +181,16 @@ theme_minimal <- function(base_size = 12, base_family = "") {
)
}
-#' A classic-looking theme, with x and y axis lines and no gridlines.
-#'
-#' @param base_size base font size
-#' @param base_family base font family
#' @export
+#' @rdname ggtheme
theme_classic <- function(base_size = 12, base_family = ""){
theme_bw(base_size = base_size, base_family = base_family) %+replace%
theme(
panel.border = element_blank(),
axis.line = element_line(colour = "black"),
panel.grid.major = element_blank(),
- panel.grid.minor = element_blank()
+ panel.grid.minor = element_blank(),
+ strip.background = element_rect(colour = "black", size = 0.5),
+ legend.key = element_blank()
)
}
diff --git a/R/theme-elements.r b/R/theme-elements.r
index c95becc..7b1350c 100644
--- a/R/theme-elements.r
+++ b/R/theme-elements.r
@@ -1,18 +1,18 @@
#' Theme element: blank.
#' This theme element draws nothing, and assigns no space
-#'
+#'
#' @export
element_blank <- function() {
structure(
list(),
class = c("element_blank", "element")
- )
+ )
}
#' Theme element: rectangle.
-#'
+#'
#' Most often used for backgrounds and borders.
-#'
+#'
#' @param fill fill colour
#' @param colour border colour
#' @param size border size
@@ -30,7 +30,7 @@ element_rect <- function(fill = NULL, colour = NULL, size = NULL,
}
#' Theme element: line.
-#'
+#'
#' @param colour line colour
#' @param size line size
#' @param linetype line type
@@ -49,7 +49,7 @@ element_line <- function(colour = NULL, size = NULL, linetype = NULL,
#' Theme element: text.
-#'
+#'
#' @param family font family
#' @param face font face ("plain", "italic", "bold", "bold.italic")
#' @param colour text colour
@@ -73,7 +73,7 @@ element_text <- function(family = NULL, face = NULL, colour = NULL,
}
-#' @S3method print element
+#' @export
print.element <- function(x, ...) str(x)
@@ -87,7 +87,7 @@ rel <- function(x) {
structure(x, class = "rel")
}
-#' @S3method print rel
+#' @export
print.rel <- function(x, ...) print(noquote(paste(x, " *", sep = "")))
#' Reports whether x is a rel object
@@ -104,35 +104,35 @@ is.rel <- function(x) inherits(x, "rel")
#'
#' @export
theme_blank <- function(...) {
- gg_dep("0.9.1", "'theme_blank' is deprecated. Use 'element_blank' instead.")
+ gg_dep("0.9.1", "Use 'element_blank' instead.")
element_blank(...)
}
#' @rdname theme_blank
#' @export
theme_rect <- function(...) {
- gg_dep("0.9.1", "theme_rect is deprecated. Use 'element_rect' instead.")
+ gg_dep("0.9.1", "Use 'element_rect' instead.")
element_rect(...)
}
#' @rdname theme_blank
#' @export
theme_line <- function(...) {
- gg_dep("0.9.1", "theme_line is deprecated. Use 'element_line' instead.")
+ gg_dep("0.9.1", "Use 'element_line' instead.")
element_line(...)
}
#' @rdname theme_blank
#' @export
theme_segment <- function(...) {
- gg_dep("0.9.1", "theme_segment is deprecated. Use 'element_line' instead.")
+ gg_dep("0.9.1", "Use 'element_line' instead.")
element_line(...)
}
#' @rdname theme_blank
#' @export
theme_text <- function(...) {
- gg_dep("0.9.1", "theme_text is deprecated. Use 'element_text' instead.")
+ gg_dep("0.9.1", "Use 'element_text' instead.")
element_text(...)
}
@@ -163,10 +163,10 @@ element_grob <- function(element, ...)
UseMethod("element_grob")
-#' @S3method element_grob element_blank
+#' @export
element_grob.element_blank <- function(element, ...) zeroGrob()
-#' @S3method element_grob element_rect
+#' @export
element_grob.element_rect <- function(element, x = 0.5, y = 0.5,
width = 1, height = 1,
fill = NULL, colour = NULL, size = NULL, linetype = NULL, ...) {
@@ -180,7 +180,7 @@ element_grob.element_rect <- function(element, x = 0.5, y = 0.5,
}
-#' @S3method element_grob element_text
+#' @export
element_grob.element_text <- function(element, label = "", x = NULL, y = NULL,
family = NULL, face = NULL, colour = NULL, size = NULL,
hjust = NULL, vjust = NULL, angle = NULL, lineheight = NULL,
@@ -194,17 +194,17 @@ element_grob.element_text <- function(element, label = "", x = NULL, y = NULL,
stop("Text element requires non-NULL value for 'angle'.")
}
angle <- angle %% 360
-
+
if (angle == 90) {
- xp <- vj
+ xp <- 1 - vj
yp <- hj
} else if (angle == 180) {
xp <- 1 - hj
- yp <- vj
+ yp <- 1 - vj
} else if (angle == 270) {
xp <- vj
yp <- 1 - hj
- }else {
+ } else {
xp <- hj
yp <- vj
}
@@ -229,7 +229,7 @@ element_grob.element_text <- function(element, label = "", x = NULL, y = NULL,
}
-#' @S3method element_grob element_line
+#' @export
element_grob.element_line <- function(element, x = 0:1, y = 0:1,
colour = NULL, size = NULL, linetype = NULL, lineend = NULL,
default.units = "npc", id.lengths = NULL, ...) {
@@ -306,6 +306,8 @@ el_def <- function(class = NULL, inherit = NULL, description = NULL) {
panel.background = el_def("element_rect", "rect"),
panel.border = el_def("element_rect", "rect"),
panel.margin = el_def("unit"),
+ panel.margin.x = el_def("unit", "panel.margin"),
+ panel.margin.y = el_def("unit", "panel.margin"),
panel.grid.major.x = el_def("element_line", "panel.grid.major"),
panel.grid.major.y = el_def("element_line", "panel.grid.major"),
panel.grid.minor.x = el_def("element_line", "panel.grid.minor"),
diff --git a/R/theme.r b/R/theme.r
index 69f5d13..aa7e7ff 100644
--- a/R/theme.r
+++ b/R/theme.r
@@ -1,8 +1,8 @@
#' Get, set and update themes.
-#'
+#'
#' Use \code{theme_update} to modify a small number of elements of the current
#' theme or use \code{theme_set} to completely override it.
-#'
+#'
#' @param ... named list of theme settings
#' @seealso \code{\link{\%+replace\%}} and \code{\link{+.gg}}
#' @export
@@ -17,10 +17,10 @@
#' qplot(mpg, wt, data = mtcars)
#' theme_set(old)
#' theme_get()
-#'
-#' qplot(mpg, wt, data=mtcars, colour=mpg) +
+#'
+#' qplot(mpg, wt, data=mtcars, colour=mpg) +
#' theme(legend.position=c(0.95, 0.95), legend.justification = c(1, 1))
-#' last_plot() +
+#' last_plot() +
#' theme(legend.background = element_rect(fill = "white", colour = "white", size = 3))
theme_update <- function(...) {
# Make a call to theme, then add to theme
@@ -32,16 +32,16 @@ theme_update <- function(...) {
#' @export
is.theme <- function(x) inherits(x, "theme")
-#' @S3method print theme
+#' @export
print.theme <- function(x, ...) str(x)
#' Set theme elements
-#'
-#'
+#'
+#'
#' Use this function to modify theme settings.
#'
#' Theme elements can inherit properties from other theme elements.
-#' For example, \code{axis.title.x} inherits from \code{axis.title},
+#' For example, \code{axis.title.x} inherits from \code{axis.title},
#' which in turn inherits from \code{text}. All text elements inherit
#' directly or indirectly from \code{text}; all lines inherit from
#' \code{line}, and all rectangular objects inherit from \code{rect}.
@@ -54,7 +54,7 @@ print.theme <- function(x, ...) str(x)
#'
#' @section Theme elements:
#' The individual theme elements are:
-#'
+#'
#' \tabular{ll}{
#' line \tab all line elements
#' (\code{element_line}) \cr
@@ -114,8 +114,8 @@ print.theme <- function(x, ...) str(x)
#' (\code{element_text}; inherits from \code{title}) \cr
#' legend.title.align \tab alignment of legend title
#' (number from 0 (left) to 1 (right)) \cr
-#' legend.position \tab the position of legends.
-#' ("left", "right", "bottom", "top", or two-element
+#' legend.position \tab the position of legends
+#' ("none", "left", "right", "bottom", "top", or two-element
#' numeric vector) \cr
#' legend.direction \tab layout of items in legends
#' ("horizontal" or "vertical") \cr
@@ -124,7 +124,7 @@ print.theme <- function(x, ...) str(x)
#' legend.box \tab arrangement of multiple legends
#' ("horizontal" or "vertical") \cr
#' legend.box.just \tab justification of each legend within the overall
-#' bounding box, when there are multiple legends
+#' bounding box, when there are multiple legends
#' ("top", "bottom", "left", or "right")\cr
#'
#' panel.background \tab background of plotting area, drawn underneath plot
@@ -135,6 +135,10 @@ print.theme <- function(x, ...) str(x)
#' (\code{element_rect}; inherits from \code{rect}) \cr
#' panel.margin \tab margin around facet panels
#' (\code{unit}) \cr
+#' panel.margin.x \tab horizontal margin around facet panels
+#' (\code{unit}; inherits from \code{panel.margin}) \cr
+#' panel.margin.y \tab vertical margin around facet panels
+#' (\code{unit}; inherits from \code{panel.margin}) \cr
#' panel.grid \tab grid lines
#' (\code{element_line}; inherits from \code{line}) \cr
#' panel.grid.major \tab major grid lines
@@ -177,11 +181,15 @@ print.theme <- function(x, ...) str(x)
#' @seealso \code{\link{+.gg}}
#' @seealso \code{\link{\%+replace\%}}
#' @seealso \code{\link{rel}}
+#' @seealso \code{\link{element_blank}}
+#' @seealso \code{\link{element_line}}
+#' @seealso \code{\link{element_rect}}
+#' @seealso \code{\link{element_text}}
#' @export
#' @examples
#' \donttest{
#' p <- qplot(mpg, wt, data = mtcars)
-#' p
+#' p
#' p + theme(panel.background = element_rect(colour = "pink"))
#' p + theme_bw()
#'
@@ -189,11 +197,11 @@ print.theme <- function(x, ...) str(x)
#' p <- ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point()
#' # Calculate slope and intercept of line of best fit
#' coef(lm(mpg ~ wt, data = mtcars))
-#' p + geom_abline(intercept = 37, slope = -5)
+#' p + geom_abline(intercept = 37, slope = -5)
#' # Calculate correlation coefficient
#' with(mtcars, cor(wt, mpg, use = "everything", method = "pearson"))
#' #annotate the plot
-#' p + geom_abline(intercept = 37, slope = -5) +
+#' p + geom_abline(intercept = 37, slope = -5) +
#' geom_text(data = data.frame(), aes(4.5, 30, label = "Pearson-R = -.87"))
#'
#' # Change the axis labels
@@ -202,7 +210,7 @@ print.theme <- function(x, ...) str(x)
#' p + xlab("Vehicle Weight") + ylab("Miles per Gallon")
#' # Or
#' p + labs(x = "Vehicle Weight", y = "Miles per Gallon")
-#'
+#'
#' # Change title appearance
#' p <- p + labs(title = "Vehicle Weight-Gas Mileage Relationship")
#' # Set title to twice the base font size
@@ -213,10 +221,10 @@ print.theme <- function(x, ...) str(x)
#' DF <- data.frame(x = rnorm(400))
#' m <- ggplot(DF, aes(x = x)) + geom_histogram()
#' # Default is theme_grey()
-#' m
+#' m
#' # Compare with
#' m + theme_bw()
-#'
+#'
#' # Manipulate Axis Attributes
#' library(grid) # for unit
#' m + theme(axis.line = element_line(size = 3, colour = "red", linetype = "dotted"))
@@ -271,7 +279,7 @@ print.theme <- function(x, ...) str(x)
#' k + theme(strip.text.x = element_text(colour = "red", angle = 45, size = 10,
#' hjust = 0.5, vjust = 0.5))
#' k + theme(panel.margin = unit(5, "lines"))
-#' k + theme(panel.margin = unit(0, "lines"))
+#' k + theme(panel.margin.y = unit(0, "lines"))
#'
#'
#' # Modify a theme and save it
@@ -323,16 +331,14 @@ theme <- function(..., complete = FALSE) {
#'
#' @export
opts <- function(...) {
- gg_dep("0.9.1", "'opts' is deprecated. Use 'theme' instead.")
+ gg_dep("0.9.1", "Use 'theme' instead.")
# Add check for deprecated elements
extra <- NULL
elements <- list(...)
if (!is.null(elements[["title"]])) {
# This is kind of a hack, but fortunately it will be removed in future versions
- gg_dep("0.9.1", paste(sep = "\n",
- 'Setting the plot title with opts(title="...") is deprecated.',
- ' Use labs(title="...") or ggtitle("...") instead.'))
+ gg_dep("0.9.1", 'Use labs(title="...") or ggtitle("...") instead.')
title <- elements$title
elements$title <- NULL
@@ -508,14 +514,14 @@ update_theme <- function(oldtheme, newtheme) {
##' update_element(x, noargument = 12)
##' # Or multiple arguments with the same name
##' update_element(x, size = 12, size = 15)
-##'
+##'
##' # Will look up element if given name
##' update_element("axis.text.x", colour = 20)
##' # Throws error if incorrectly named
##' update_element("axis.text", colour = 20)
##' }
update_element <- function(name, ...) {
- gg_dep("0.9.1", "update_element is deprecated. Use '+.gg' instead.")
+ gg_dep("0.9.1", "Use '+.gg' instead.")
if (is.character(name)) {
ele <- theme_get()[[name]]
if (is.null(ele)) {
@@ -544,7 +550,7 @@ update_element <- function(name, ...) {
#' t$axis.text.x
#' calc_element('axis.text.x', t, verbose = TRUE)
#'
-#' # This reports that axis.text.x inherits from axis.text,
+#' # This reports that axis.text.x inherits from axis.text,
#' # which inherits from text. You can view each of them with:
#' t$axis.text.x
#' t$axis.text
diff --git a/R/translate-qplot-base.r b/R/translate-qplot-base.r
index cfa90aa..4863dbf 100644
--- a/R/translate-qplot-base.r
+++ b/R/translate-qplot-base.r
@@ -1,36 +1,36 @@
#' Translating between qplot and base graphics
-#'
+#'
#' There are two types of graphics functions in base graphics, those that draw
#' complete graphics and those that add to existing graphics.
-#'
+#'
#' qplot() has been designed to mimic plot(), and can do the job of all other
#' high-level plotting commands. There are only two graph types from base
#' graphics that cannot be replicated with ggplot2: filled.contour() and
#' persp()
#'
-#' @name translate_qplot_base
+#' @name translate_qplot_base
#' @examples
#' \donttest{
-#'
+#'
#' # High-level plotting commands
-#'
+#'
#' x <- runif(10)
#' y <- 1:10
#' plot(x, y); dotchart(x, y)
#' qplot(x, y)
-#'
+#'
#' plot(x, y, type = "l")
#' qplot(x, y, geom = "line")
#'
#' plot(x, y, type = "s")
#' qplot(x, y, geom = "step")
-#'
+#'
#' plot(x, y, type = "b")
#' qplot(x, y, geom = c("point", "line"))
#'
#' boxplot(x, y)
#' qplot(x, y, geom = "boxplot")
-#'
+#'
#' hist(x)
#' qplot(x, geom = "histogram")
#'
@@ -48,20 +48,20 @@
#'
#' # qplot() often requires data in a slightly different format to the base
#' # graphics functions. For example, the bar geom works with untabulated data,
-#' # not tabulated data like barplot(); the tile and contour geoms expect data
+#' # not tabulated data like barplot(); the tile and contour geoms expect data
#' # in a data frame, not a matrix like image() and contour().
#' barplot(table(x))
#' qplot(x, geom = "bar")
-#'
+#'
#' barplot(x)
#' qplot(seq_along(x), x, geom = "bar", stat = "identity")
-#'
+#'
#' # image(x)
#' # qplot(X1, X2, data = melt(x), geom = "tile", fill = value)
-#'
+#'
#' # contour(x)
#' # qplot(X1, X2, data = melt(x), geom = "contour", fill = value)
-#'
+#'
#' # Generally, the base graphics functions work with individual vectors, not
#' # data frames like ggplot2. qplot() will try to construct a data frame if one
#' # is not specified, but it is not always possible. If you get strange errors,
@@ -69,17 +69,17 @@
#' df <- data.frame(x = x, y = y)
#' with(df, plot(x, y))
#' qplot(x, y, data = df)
-#'
+#'
#' # By default, qplot() maps values to aesthetics with a scale. To override
#' # this behaviour and set aesthetics, overriding the defaults, you need to use I().
#' plot(x, y, col = "red", cex = 1)
#' qplot(x, y, colour = I("red"), size = I(1))
-#'
+#'
#' # Low-level drawing
-#'
+#'
#' # The low-level drawing functions which add to an existing plot are equivalent
#' # to adding a new layer in ggplot2.
-#'
+#'
#' # Base function ggplot2 layer
#' # curve() geom_curve()
#' # hline() geom_hline()
@@ -94,47 +94,47 @@
#' # abline(lm(y ~ x)) geom_smooth(method = "lm")
#' # lines(density(x)) geom_density()
#' # lines(loess(x, y)) geom_smooth()
-#'
+#'
#' plot(x, y)
#' lines(x, y)
-#'
+#'
#' qplot(x, y) + geom_line()
#'
#' # Or, building up piece-meal
#' qplot(x, y)
#' last_plot() + geom_line()
-#'
+#'
#' # Legends, axes and grid lines
-#'
+#'
#' # In ggplot2, the appearance of legends and axes is controlled by the scales.
#' # Axes are produced by the x and y scales, while all other scales produce legends.
#' # See ?theme for help changing the appearance of axes and legends.
-#' # The appearance of grid lines is controlled by the grid.major and grid.minor
+#' # The appearance of grid lines is controlled by the grid.major and grid.minor
#' # theme options, and their position by the breaks of the x and y scales.
-#'
+#'
#' # Colour palettes
-#'
+#'
#' # Instead of global colour palettes, ggplot2 has scales for individual plots. Much
#' # of the time you can rely on the default colour scale (which has somewhat better
#' # perceptual properties), but if you want to reuse an existing colour palette, you
#' # can use scale_colour_manual(). You will need to make sure that the colour
#' # is a factor for this to work.
-#'
+#'
#' palette(rainbow(5))
#' plot(1:5, 1:5, col = 1:5, pch = 19, cex = 4)
#'
#' qplot(1:5, 1:5, col = factor(1:5), size = I(4))
#' last_plot() + scale_colour_manual(values = rainbow(5))
#'
-#' # In ggplot2, you can also use palettes with continuous values,
+#' # In ggplot2, you can also use palettes with continuous values,
#' # with intermediate values being linearly interpolated.
#'
#' qplot(0:100, 0:100, col = 0:100, size = I(4)) +
#' scale_colour_gradientn(colours = rainbow(7))
#' last_plot() + scale_colour_gradientn(colours = terrain.colors(7))
-#'
+#'
#' # Graphical parameters
-#'
+#'
#' # The majority of par settings have some analogue within the theme system, or
#' # in the defaults of the geoms and scales. The appearance plot border drawn
#' # by box() can be controlled in a similar way by the panel.background and
diff --git a/R/translate-qplot-ggplot.r b/R/translate-qplot-ggplot.r
index 48e18d5..86de942 100644
--- a/R/translate-qplot-ggplot.r
+++ b/R/translate-qplot-ggplot.r
@@ -1,5 +1,5 @@
#' Translating between qplot and ggplot
-#'
+#'
#' Within ggplot2, there are two basic methods to create plots, with qplot()
#' and ggplot(). qplot() is designed primarily for interactive use: it makes
#' a number of assumptions that speed most cases, but when designing multilayered
@@ -10,19 +10,19 @@
#' @name translate_qplot_ggplot
#' @examples
#'
-#' # By default, qplot() assumes that you want a scatterplot,
+#' # By default, qplot() assumes that you want a scatterplot,
#' # i.e., you want to use geom_point()
#' # qplot(x, y, data = data)
#' # ggplot(data, aes(x, y)) + geom_point()
#'
#' # Using Aesthetics
-#'
+#'
#' # If you map additional aesthetics, these will be added to the defaults. With
#' # qplot() there is no way to use different aesthetic mappings (or data) in
#' # different layers
#' # qplot(x, y, data = data, shape = shape, colour = colour)
#' # ggplot(data, aes(x, y, shape = shape, colour = colour)) + geom_point()
-#' #
+#' #
#' # Aesthetic parameters in qplot() always try to map the aesthetic to a
#' # variable. If the argument is not a variable but a value, effectively a new column
#' # is added to the original dataset with that value. To set an aesthetic to a
@@ -30,49 +30,49 @@
#' # qplot(), or pass it as a parameter to the layer.
#' # qplot(x, y, data = data, colour = I("red"))
#' # ggplot(data, aes(x, y)) + geom_point(colour = "red")
-#'
+#'
#' # Changing the geom parameter changes the geom added to the plot
#' # qplot(x, y, data = data, geom = "line")
#' # ggplot(data, aes(x, y)) + geom_line()
#'
#' # Not all geoms require both x and y, e.g., geom_bar() and geom_histogram().
-#' # For these two geoms, if the y aesthetic is not supplied, both qplot and
+#' # For these two geoms, if the y aesthetic is not supplied, both qplot and
#' # ggplot commands default to "count" on the y-axis
#' # ggplot(data, aes(x)) + geom_bar()
#' # qplot(x, data = data, geom = "bar")
-#'
+#'
#' # If a vector of multiple geom names is supplied to the geom argument, each
#' # geom will be added in turn
#' # qplot(x, y, data = data, geom = c("point", "smooth"))
#' # ggplot(data, aes(x, y)) + geom_point() + geom_smooth()
-#'
+#'
#' # Unlike the rest of ggplot2, stats and geoms are independent
#' # qplot(x, y, data = data, stat = "bin")
#' # ggplot(data, aes(x, y)) + geom_point(stat = "bin")
-#' #
+#' #
#' # Any layer parameters will be passed on to all layers. Most layers will ignore
#' # parameters that they don't need
#' # qplot(x, y, data = data, geom = c("point", "smooth"), method = "lm")
#' # ggplot(data, aes(x, y)) + geom_point(method = "lm") + geom_smooth(method = "lm")
-#'
+#'
#' # Scales and axes
#'
#' # You can control basic properties of the x and y scales with the xlim, ylim,
#' # xlab and ylab arguments
#' # qplot(x, y, data = data, xlim = c(1, 5), xlab = "my label")
-#' # ggplot(data, aes(x, y)) + geom_point() +
+#' # ggplot(data, aes(x, y)) + geom_point() +
#' # scale_x_continuous("my label", limits = c(1, 5))
-#'
+#'
#' # qplot(x, y, data = data, xlim = c(1, 5), ylim = c(10, 20))
#' # ggplot(data, aes(x, y)) + geom_point() +
#' # scale_x_continuous(limits = c(1, 5)) + scale_y_continuous(limits = c(10, 20))
-#'
+#'
#' # Like plot(), qplot() has a convenient way of log transforming the axes.
#' # qplot(x, y, data = data, log = "xy")
#' # ggplot(data, aes(x, y)) + geom_point() + scale_x_log10() + scale_y_log10()
-#' # There are many other possible transformations, but not all are
+#' # There are many other possible transformations, but not all are
#' # accessible from within qplot(), see ?scale_continuous for more
-#'
+#'
#' # Plot options
#'
#' # qplot() recognises the same options as plot does, and converts them to their
diff --git a/R/translate-qplot-gpl.r b/R/translate-qplot-gpl.r
index 02957ca..8e42dab 100644
--- a/R/translate-qplot-gpl.r
+++ b/R/translate-qplot-gpl.r
@@ -1,22 +1,22 @@
#' Translating between qplot and Graphics Production Library (GPL)
-#'
+#'
#' The Grammar of Graphics uses two specifications. A concise format is used to
#' caption figures, and a more detailed xml format stored on disk.
#'
#' @name translate_qplot_gpl
#' @examples
#'
-#' # The following example of the concise format is adapted from Figure 1.5,
+#' # The following example of the concise format is adapted from Figure 1.5,
#' # page 13, of Leland Wilkinson's "The Grammar of Graphics."
#' # Springer, 2nd edition, 2005.
-#'
+#'
#' # DATA: source("demographics")
#' # DATA: longitude, latitude = map(source("World"))
#' # TRANS: bd = max(birth - death, 0)
#' # COORD: project.mercator()
#' # ELEMENT: point(position(lon * lat), size(bd), color(color.red))
#' # ELEMENT: polygon(position(longitude * latitude))
-#'
+#'
#' # This is relatively simple to adapt to the syntax of ggplot2:
#'
#' # ggplot() is used to specify the default data and default aesthetic mappings.
@@ -25,7 +25,7 @@
#' # different world dataset, with columns lat and long. This lets us use the
#' # same aesthetic mappings for both datasets. Layers can override the default
#' # data and aesthetic mappings provided by the plot.
-#'
+#'
#' # We replace TRANS with an explicit transformation by R code.
#'
#' # ELEMENTs are replaced with layers, which explicitly specify the data
@@ -47,10 +47,10 @@
#' # Each component is added together with + to create the final plot.
#'
#' # Resulting ggplot2 code:
-#' # demographics <- transform(demographics, bd = pmax(birth - death, 0))
+#' # demographics <- transform(demographics, bd = pmax(birth - death, 0))
#' # p <- ggplot(demographic, aes(lon, lat))
#' # p <- p + geom_polyogon(data = world)
-#' # p <- p + geom_point(aes(size = bd), colour = "red")
+#' # p <- p + geom_point(aes(size = bd), colour = "red")
#' # p <- p + coord_map(projection = "mercator")
#' # print(p)
NULL
diff --git a/R/translate-qplot-lattice.r b/R/translate-qplot-lattice.r
index 45ea319..49237f9 100644
--- a/R/translate-qplot-lattice.r
+++ b/R/translate-qplot-lattice.r
@@ -1,10 +1,10 @@
#' Translating between qplot and lattice
-#'
+#'
#' The major difference between lattice and ggplot2 is that lattice uses a formula based
#' interface. ggplot2 does not because the formula does not generalise well
#' to more complicated situations.
#'
-#' @name translate_qplot_lattice
+#' @name translate_qplot_lattice
#' @examples
#' \donttest{
#' library(lattice)
@@ -26,7 +26,7 @@
#'
#' histogram(~ rating, data = movies)
#' qplot(rating, data = movies, geom = "histogram")
-#'
+#'
#' bwplot(Comedy ~ rating ,data = movies)
#' qplot(factor(Comedy), rating, data = movies, type = "boxplot")
#'
@@ -53,14 +53,14 @@
#' xyplot(wt ~ mpg, mtcars, group = cyl, auto.key = TRUE)
#' # Map directly to an aesthetic like colour, size, or shape.
#' qplot(mpg, wt, data = mtcars, colour = cyl)
-#'
+#'
#' xyplot(wt ~ mpg, mtcars, xlim = c(20,30))
#' # Works like lattice, except you can't specify a different limit
#' # for each panel/facet
#' qplot(mpg, wt, data = mtcars, xlim = c(20,30))
-#'
+#'
#' # Both lattice and ggplot2 have similar options for controlling labels on the plot.
-#'
+#'
#' xyplot(wt ~ mpg, mtcars, xlab = "Miles per gallon", ylab = "Weight",
#' main = "Weight-efficiency tradeoff")
#' qplot(mpg, wt, data = mtcars, xlab = "Miles per gallon", ylab = "Weight",
@@ -68,7 +68,7 @@
#'
#' xyplot(wt ~ mpg, mtcars, aspect = 1)
#' qplot(mpg, wt, data = mtcars, asp = 1)
-#'
+#'
#' # par.settings() is equivalent to + theme() and trellis.options.set()
#' # and trellis.par.get() to theme_set() and theme_get().
#' # More complicated lattice formulas are equivalent to rearranging the data
diff --git a/R/utilities-break.r b/R/utilities-break.r
index b0022c1..1ed9f9f 100644
--- a/R/utilities-break.r
+++ b/R/utilities-break.r
@@ -1,12 +1,12 @@
#' Cut numeric vector into intervals of equal length.
-#'
+#'
#' @param x numeric vector
#' @param n number of intervals to create, OR
#' @param length length of each interval
#' @param ... other arguments passed on to \code{\link{cut}}
#' @seealso \code{\link{cut_number}}
#' @export
-#' @examples
+#' @examples
#' table(cut_interval(1:100, n = 10))
#' table(cut_interval(1:100, n = 11))
#' table(cut_interval(1:100, length = 10))
@@ -15,7 +15,7 @@ cut_interval <- function(x, n = NULL, length = NULL, ...) {
}
#' Cut numeric vector into intervals containing equal number of points.
-#'
+#'
#' @param x numeric vector
#' @param n number of intervals to create
#' @param ... other arguments passed on to \code{\link{cut}}
@@ -32,7 +32,7 @@ breaks <- function(x, equal, nbins = NULL, binwidth = NULL) {
if ((!is.null(nbins) && !is.null(binwidth)) || (is.null(nbins) && is.null(binwidth))) {
stop("Specify exactly one of n and width")
}
-
+
rng <- range(x, na.rm = TRUE, finite = TRUE)
if (equal == "width") {
if (!is.null(binwidth)) {
@@ -48,6 +48,6 @@ breaks <- function(x, equal, nbins = NULL, binwidth = NULL) {
}
quantile(x, probs, na.rm = TRUE)
}
-
+
}
diff --git a/R/utilities-grid.r b/R/utilities-grid.r
index 109c854..490478a 100644
--- a/R/utilities-grid.r
+++ b/R/utilities-grid.r
@@ -1,6 +1,6 @@
# Name ggplot grid object
# Convenience function to name grid objects
-#
+#
# @keyword internal
ggname <- function(prefix, grob) {
grob$name <- grobName(grob, prefix)
@@ -16,7 +16,7 @@ width_cm <- function(x) {
convertWidth(x, "cm", TRUE)
} else {
stop("Unknown input")
- }
+ }
}
height_cm <- function(x) {
if (is.grob(x)) {
@@ -27,5 +27,5 @@ height_cm <- function(x) {
convertHeight(x, "cm", TRUE)
} else {
stop("Unknown input")
- }
+ }
}
diff --git a/R/utilities-layer.r b/R/utilities-layer.r
index 6905c42..fabf3d0 100644
--- a/R/utilities-layer.r
+++ b/R/utilities-layer.r
@@ -3,31 +3,31 @@
# If the \code{group} variable is not present, then a new group
# variable is generated from the interaction of all discrete (factor or
# character) vectors, excluding \code{label}.
-#
+#
# @param data.frame
# @value data.frame with group variable
# @keyword internal
add_group <- function(data) {
if (empty(data)) return(data)
-
+
if (is.null(data$group)) {
disc <- vapply(data, is.discrete, logical(1))
disc[names(disc) == "label"] <- FALSE
-
+
if (any(disc)) {
- data$group <- id(data[disc], drop = TRUE)
+ data$group <- id(data[disc], drop = TRUE)
} else {
data$group <- 1L
}
} else {
data$group <- id(data["group"], drop = TRUE)
}
-
+
data
}
order_groups <- function(data) {
if (is.null(data$order)) return(data)
-
+
data[order(data$order), ]
}
diff --git a/R/utilities-matrix.r b/R/utilities-matrix.r
index a228ea8..dedf0c9 100644
--- a/R/utilities-matrix.r
+++ b/R/utilities-matrix.r
@@ -1,58 +1,58 @@
#' Row weave.
#'
#' Weave together two (or more) matrices by row.
-#'
+#'
#' Matrices must have same dimensions.
-#'
+#'
#' @param ... matrices to weave together
#' @keywords internal
-#' @S3method rweave list
-#' @S3method rweave matrix
#X a <- matrix(1:10 * 2, ncol = 2)
#X b <- matrix(1:10 * 3, ncol = 2)
#X c <- matrix(1:10 * 5, ncol = 2)
rweave <- function(...) UseMethod("rweave")
+#' @export
rweave.list <- function(...) do.call("rweave", ...)
+#' @export
rweave.matrix <- function(...) {
matrices <- list(...)
stopifnot(equal_dims(matrices))
-
+
n <- nrow(matrices[[1]])
p <- length(matrices)
-
+
interleave <- rep(1:n, each = p) + seq(0, p - 1) * n
do.call("rbind", matrices)[interleave, , drop = FALSE]
}
# Col union
# Form the union of columns in a and b. If there are columns of the same name in both a and b, take the column from a.
-#
+#
# @param data frame a
# @param data frame b
# @keyword internal
cunion <- function(a, b) {
if (length(a) == 0) return(b)
if (length(b) == 0) return(a)
-
+
cbind(a, b[setdiff(names(b), names(a))])
}
#' Col weave
#'
#' Weave together two (or more) matrices by column
-#'
+#'
#' Matrices must have same dimensions
-#'
+#'
#' @param ... matrices to weave together
#' @keywords internal
-#' @S3method cweave list
-#' @S3method cweave matrix
cweave <- function(...) UseMethod("cweave")
+#' @export
cweave.list <- function(...) do.call("cweave", ...)
+#' @export
cweave.matrix <- function(...) {
matrices <- list(...)
stopifnot(equal_dims(matrices))
-
+
n <- ncol(matrices[[1]])
p <- length(matrices)
@@ -61,29 +61,29 @@ cweave.matrix <- function(...) {
}
#' Interleave (or zip) multiple vectors into a single vector.
-#'
+#'
#' @param ... vectors to interleave
#' @keywords internal
-#' @S3method interleave list
-#' @S3method interleave unit
-#' @S3method interleave default
interleave <- function(...) UseMethod("interleave")
+#' @export
interleave.list <- function(...) do.call("interleave", ...)
+#' @export
interleave.unit <- function(...) {
do.call("unit.c", do.call("interleave.default", llply(list(...), as.list)))
}
+#' @export
interleave.default <- function(...) {
vectors <- list(...)
-
- # Check lengths
+
+ # Check lengths
lengths <- unique(setdiff(laply(vectors, length), 1))
if (length(lengths) == 0) lengths <- 1
stopifnot(length(lengths) <= 1)
-
+
# Replicate elements of length one up to correct length
singletons <- laply(vectors, length) == 1
vectors[singletons] <- llply(vectors[singletons], rep, lengths)
-
+
# Interleave vectors
n <- lengths
p <- length(vectors)
@@ -93,15 +93,15 @@ interleave.default <- function(...) {
# Equal dims?
# Check that a list of matrices have equal dimensions
-#
+#
# @param list of matrices
# @keyword internal
equal_dims <- function(matrices) {
are.matrices <- laply(matrices, is.matrix)
stopifnot(all(are.matrices))
-
+
cols <- laply(matrices, ncol)
rows <- laply(matrices, ncol)
length(unique(cols) == 1) && length(unique(rows) == 1)
-}
+}
diff --git a/R/utilities-resolution.r b/R/utilities-resolution.r
index a3b9b39..11a0f0f 100644
--- a/R/utilities-resolution.r
+++ b/R/utilities-resolution.r
@@ -2,8 +2,8 @@
#'
#' The resolution is is the smallest non-zero distance between adjacent
#' values. If there is only one unique value, then the resolution is defined
-#' to be one.
-#'
+#' to be one.
+#'
#' If x is an integer vector, then it is assumed to represent a discrete
#' variable, and the resolution is 1.
#'
@@ -20,11 +20,11 @@
resolution <- function(x, zero = TRUE) {
if (is.integer(x) || zero_range(range(x, na.rm = TRUE)))
return(1)
-
+
x <- unique(as.numeric(x))
if (zero) {
x <- unique(c(0, x))
}
-
+
min(diff(sort(x)))
}
diff --git a/R/utilities-table.r b/R/utilities-table.r
index 537ce5c..76d87d1 100644
--- a/R/utilities-table.r
+++ b/R/utilities-table.r
@@ -1,12 +1,12 @@
compute_grob_widths <- function(grob_layout, widths) {
cols <- split(grob_layout, grob_layout$l)
do.call("unit.c", lapply(cols, compute_grob_dimensions, dims = widths))
-}
+}
compute_grob_heights <- function(grob_layout, heights) {
cols <- split(grob_layout, grob_layout$t)
do.call("unit.c", lapply(cols, compute_grob_dimensions, dims = heights))
-}
+}
compute_grob_dimensions <- function(grob_layout, dims) {
# If any don't have explicit dims, then width is NULL
@@ -14,7 +14,7 @@ compute_grob_dimensions <- function(grob_layout, dims) {
return(unit(1, "null"))
}
- grob_layout <- subset(grob_layout, type %in% names(dims))
+ grob_layout <- grob_layout[grob_layout$type %in% names(dims), , drop = FALSE]
dims <- unique(Map(function(type, pos) {
type_width <- dims[[type]]
diff --git a/R/utilities.r b/R/utilities.r
index 0350a82..9ca25c8 100644
--- a/R/utilities.r
+++ b/R/utilities.r
@@ -1,7 +1,7 @@
# Null default
# Analog of || from ruby
-#
+#
# @keyword internal
# @name nulldefault-infix
"%||%" <- function(a, b) {
@@ -25,7 +25,7 @@ check_required_aesthetics <- function(required, present, name) {
# Concatenate a named list for output
# Print a \code{list(a=1, b=2)} as \code{(a=1, b=2)}
-#
+#
# @param list to concatenate
# @keyword internal
#X clist(list(a=1, b=2))
@@ -36,7 +36,7 @@ clist <- function(l) {
# Abbreviated paste
# Alias for paste with a shorter name and convenient defaults
-#
+#
# @param character vectors to be concatenated
# @param default separator
# @param default collapser
@@ -45,20 +45,23 @@ ps <- function(..., sep="", collapse="") do.call(paste, compact(list(..., sep=se
# Quietly try to require a package
# Queitly require a package, returning an error message if that package is not installed.
-#
+#
# @param name of package
# @keyword internal
try_require <- function(package) {
- available <- suppressMessages(suppressWarnings(sapply(package, require, quietly = TRUE, character.only = TRUE, warn.conflicts=FALSE)))
- missing <- package[!available]
+ available <- suppressMessages(suppressWarnings(
+ require(package, character.only = TRUE)
+ ))
- if (length(missing) > 0)
- stop(paste(package, collapse=", "), " package required for this functionality. Please install and try again.", call. = FALSE)
+ if (!available) {
+ stop(package, " package required for this functionality. " ,
+ "Please install and try again.", call. = FALSE)
+ }
}
# Return unique columns
# This is used for figuring out which columns are constant within a group
-#
+#
# @keyword internal
uniquecols <- function(df) {
df <- df[1, sapply(df, function(x) length(unique(x)) == 1), drop=FALSE]
@@ -68,33 +71,33 @@ uniquecols <- function(df) {
# A "safe" version of do.call
# \code{safe.call} works like \code{\link{do.call}} but it will only supply arguments that exist in the function specification.
-#
+#
# If ... is present in the param list, all parameters will be passed through
# unless \code{ignore.dots = TRUE}. Positional arguments are not currently
# supported.
-#
+#
# @param function to call
# @arugments named list of parameters to be supplied to function
# @param parameter names of function
-# @param
+# @param
# @keyword internal
safe.call <- function(f, params, f.params = names(formals(f)), ignore.dots = TRUE) {
if (!ignore.dots && "..." %in% f.params) {
safe.params <- params
} else {
- safe.params <- params[intersect(f.params, names(params))]
+ safe.params <- params[intersect(f.params, names(params))]
}
do.call(f, safe.params)
}
# Convenience function to remove missing values from a data.frame
# Remove all non-complete rows, with a warning if \code{na.rm = FALSE}.
-#
+#
# ggplot is somewhat more accomodating of missing values than R generally.
-# For those stats which require complete data, missing values will be
+# For those stats which require complete data, missing values will be
# automatically removed with a warning. If \code{na.rm = TRUE} is supplied
# to the statistic, the warning will be suppressed.
-#
+#
# @param data.frame
# @param suppress warning that rows are being removed?
# @argumnets variables to check for missings in
@@ -106,7 +109,7 @@ safe.call <- function(f, params, f.params = names(formals(f)), ignore.dots = TRU
remove_missing <- function(df, na.rm=FALSE, vars = names(df), name="", finite = FALSE) {
vars <- intersect(vars, names(df))
if (name != "") name <- ps(" (", name, ")")
-
+
if (finite) {
missing <- !finite.cases(df[, vars, drop = FALSE])
str <- "non-finite"
@@ -114,10 +117,10 @@ remove_missing <- function(df, na.rm=FALSE, vars = names(df), name="", finite =
missing <- !complete.cases(df[, vars, drop = FALSE])
str <- "missing"
}
-
+
if (any(missing)) {
df <- df[!missing, ]
- if (!na.rm) warning("Removed ", sum(missing), " rows containing ", str,
+ if (!na.rm) warning("Removed ", sum(missing), " rows containing ", str,
" values", name, ".", call. = FALSE)
}
@@ -128,7 +131,7 @@ remove_missing <- function(df, na.rm=FALSE, vars = names(df), name="", finite =
finite.cases <- function(x) UseMethod("finite.cases")
# Returns a logical vector of same length as nrow(x). If all data on a row
# is finite (not NA, NaN, Inf, or -Inf) return TRUE; otherwise FALSE.
-#' @S3method finite.cases data.frame
+#' @export
finite.cases.data.frame <- function(x) {
finite_cases <- vapply(x, is.finite, logical(nrow(x)))
@@ -146,7 +149,7 @@ finite.cases.data.frame <- function(x) {
# "Invert" a list
# Keys become values, values become keys
-#
+#
# @param list to invert
# @keyword internal
invert <- function(L) {
@@ -157,7 +160,7 @@ invert <- function(L) {
# Inside
# Return logical vector indicating if x is inside the interval
-#
+#
# @keyword internal
"%inside%" <- function(x, interval) {
x >= interval[1] & x <= interval[2]
@@ -179,12 +182,12 @@ should_stop <- function(expr) {
#' A waiver object.
-#'
-#' A waiver is a "flag" object, similar to \code{NULL}, that indicates the
+#'
+#' A waiver is a "flag" object, similar to \code{NULL}, that indicates the
#' calling function should just use the default value. It is used in certain
#' functions to distinguish between displaying nothing (\code{NULL}) and
#' displaying a default value calculated elsewhere (\code{waiver()})
-#'
+#'
#' @export
#' @keywords internal
waiver <- function() structure(NULL, class="waiver")
@@ -233,6 +236,7 @@ if (packageVersion("plyr") <= package_version("1.7.1")) {
#' @param version The last version of ggplot2 where this function was good
#' (in other words, the last version where it was not deprecated).
#' @param msg The message to print.
+#' @keywords internal
#' @export
gg_dep <- function(version, msg) {
v <- as.package_version(version)
diff --git a/R/xxx-digest.r b/R/xxx-digest.r
index cef6091..e4f7570 100644
--- a/R/xxx-digest.r
+++ b/R/xxx-digest.r
@@ -3,9 +3,9 @@ bolus.proto <- function(x) x$bolus()
# Create a bolus object
# A bolus is a list suitable for digesting.
-#
+#
# Most ggplot objects have components that should be hashed when creating
-# a digest (especially since most ggplot objects are proto objects and
+# a digest (especially since most ggplot objects are proto objects and
# are also self-documenting). The bolus methods ensure that only appropriate
# components are digested.
#
@@ -28,10 +28,10 @@ bolus.proto <- function(x) x$bolus()
#X qplot(mpg, wt, data=mtcars) + xlab("blah")
#X )
#X )
-#X
+#X
#X lapply(hash_tests, function(equal) {
#X hashes <- lapply(equal, digest.ggplot)
-#X
+#X
#X if (length(unique(hashes)) != 1) {
#X lapply(equal, function(x) print(str(bolus(x))))
#X stop("Above plots not equal")
@@ -42,7 +42,7 @@ bolus.ggplot <- function(x, ...) {
if (is.null(names(x))) return(x)
x[order(names(x))]
}
-
+
with(x, list(
data = digest::digest(data),
mapping = sort.by.name(mapping),
@@ -78,10 +78,10 @@ Layer$bolus <- function(.) {
params <- c(.$geom_params, .$stat_params)
params <- params[!duplicated(params)]
if (!is.null(params) && length(params) > 1) params <- params[order(names(params))]
-
+
mapping <- .$mapping
if (!is.null(mapping)) mapping <- mapping[order(names(mapping))]
-
+
list(
geom = .$geom$objname,
stat = .$stat$objname,
diff --git a/R/zxx.r b/R/zxx.r
index e5dff81..a0d92d7 100644
--- a/R/zxx.r
+++ b/R/zxx.r
@@ -23,6 +23,10 @@ scale_fill_continuous <- scale_fill_gradient
scale_color_brewer <- scale_colour_brewer
#' @export
+#' @rdname scale_brewer
+scale_color_distiller <- scale_colour_distiller
+
+#' @export
#' @rdname scale_gradient
scale_color_continuous <- scale_colour_gradient
diff --git a/R/zzz.r b/R/zzz.r
index c53255c..5829976 100644
--- a/R/zzz.r
+++ b/R/zzz.r
@@ -3,12 +3,12 @@
tips <- c(
"Need help? Try the ggplot2 mailing list: http://groups.google.com/group/ggplot2.",
- paste("Find out what's changed in ggplot2 with\n",
- "news(Version == \"", utils::packageVersion("ggplot2"),
+ paste("Find out what's changed in ggplot2 with\n",
+ "news(Version == \"", utils::packageVersion("ggplot2"),
"\", package = \"ggplot2\")", sep = ""),
"Use suppressPackageStartupMessages to eliminate package startup messages."
- )
-
+ )
+
tip <- sample(tips, 1)
packageStartupMessage(tip)
}
diff --git a/README.md b/README.md
index b0d82b6..ecfb2a3 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,7 @@
# ggplot2
+[![Build Status](https://travis-ci.org/hadley/ggplot2.png?branch=master)](https://travis-ci.org/hadley/ggplot2)
+
ggplot2 is a plotting system for R, based on the grammar of graphics,
which tries to take the good parts of base and lattice graphics and
avoid bad parts. It takes care of many of the fiddly details
@@ -7,19 +9,12 @@ that make plotting a hassle (like drawing legends) as well as
providing a powerful model of graphics that makes it easy to produce
complex multi-layered graphics.
-To install or update, run:
+To install:
- install.packages(c("ggplot2", "plyr"))
+* the latest released version: `install.packages("ggplot2")`
+* the latest development version: `install_github("hadley/ggplot2")`
-Find out more at http://had.co.nz/ggplot2, and check out the nearly 500
-examples of ggplot in use. If you're interested, you can also sign up to
+Find out more at http://ggplot2.org, and check out the nearly 500
+examples of ggplot in use. If you're interested, you can also sign up to
the ggplot2 mailing list at http://groups.google.com/group/ggplot2, or track
development at http://github.com/hadley/ggplot2
-
-## Development
-
-To install the development version of ggplot2, it's easiest to use the `devtools` package:
-
- # install.packages("devtools")
- library(devtools)
- install_github("ggplot2")
\ No newline at end of file
diff --git a/build/partial.rdb b/build/partial.rdb
index a6ee57f..bdef9f4 100644
Binary files a/build/partial.rdb and b/build/partial.rdb differ
diff --git a/build/vignette.rds b/build/vignette.rds
new file mode 100644
index 0000000..480de61
Binary files /dev/null and b/build/vignette.rds differ
diff --git a/inst/doc/development.R b/inst/doc/development.R
new file mode 100644
index 0000000..5cfd73c
--- /dev/null
+++ b/inst/doc/development.R
@@ -0,0 +1,18 @@
+
+## ----, echo = FALSE, message = FALSE-------------------------------------
+knitr::opts_chunk$set(
+ comment = "#>",
+ error = FALSE,
+ tidy = FALSE
+)
+
+
+## ----, eval = FALSE------------------------------------------------------
+## install.packages(c("devtools", "testthat"))
+## devtools::install_github("klutometis/roxygen")
+
+
+## ----, eval = FALSE------------------------------------------------------
+## install_deps(dep = T)
+
+
diff --git a/inst/doc/development.Rmd b/inst/doc/development.Rmd
new file mode 100644
index 0000000..32ab363
--- /dev/null
+++ b/inst/doc/development.Rmd
@@ -0,0 +1,263 @@
+<!--
+%\VignetteEngine{knitr::knitr}
+%\VignetteIndexEntry{Contributing to ggplot2 development}
+-->
+
+```{r, echo = FALSE, message = FALSE}
+knitr::opts_chunk$set(
+ comment = "#>",
+ error = FALSE,
+ tidy = FALSE
+)
+```
+
+# Contributing to ggplot2 development
+
+The goal of this guide is to help you get up and contributing to ggplot2 as quickly as possible. It's still a work in progress and very rough. Your feedback is much appreciated and so are pull requests :). Rather than emailing me directly about questions, please discuss ggplot2 development issues on the [ggplot2-dev](https://groups.google.com/forum/#!forum/ggplot2-dev) mailing list. That way multiple people can learn at the same time.
+
+To contribute a change to ggplot2, you follow these steps:
+
+1. Set up a local ggplot2 development environment.
+1. Create a branch in git and make your changes.
+1. Push branch to github and issue pull request (PR).
+1. Discuss the pull request.
+1. Iterate until either we accept the PR or decide that it's not
+ a good fit for ggplot2.
+
+Each of these steps are described in more detail below. This might feel overwhelming the first time you get set up, but it gets easier with practice. If you get stuck at any point, please reach out for help on the [ggplot2-dev](https://groups.google.com/forum/#!forum/ggplot2-dev) mailing list
+
+## Basic setup
+
+If you want to do development on ggplot2 and share the changes with other people, you'll have to set up an account on GitHub. You'll make a fork of Hadley's repository and store it on GitHub. You'll also make a copy of your repository on your local machine.
+
+1. [Join github](https://github.com/join).
+
+1. [Set up git and github](https://help.github.com/articles/set-up-git).
+
+1. Fork of the main repo by going to https://github.com/hadley/ggplot2/fork.
+ A fork is a copy of ggplot2 that you can work on independently.
+ See [fork a repo](https://help.github.com/articles/fork-a-repo) for
+ more details.
+
+1. Clone your fork to your local computer (change `myname` to your account
+ name):
+
+ ```
+ git clone git at github.com:myname/ggplot2.git
+ cd ggplot2
+ ```
+
+1. Once you've done that, add the main repository as a remote and set up
+ the master branch to track the main ggplot2 repo. This will make it
+ easier to keep up to date.
+
+ ```
+ git remote add hadley git://github.com/hadley/ggplot2.git
+ git branch --set-upstream master hadley/master
+ ```
+
+Now on your local machine you have the local repository and two remote repositories: `origin` (the default), which is your personal ggplot2 repo at GitHub, and `hadley` which is Hadley's. You'll be able to push changes to your own repository only.
+
+### Development environment
+
+You'll also need a copy of the packages I use for package development. Get them by running the following R code:
+
+```{r, eval = FALSE}
+install.packages(c("devtools", "testthat"))
+devtools::install_github("klutometis/roxygen")
+```
+
+Next, install all the suggested packages that ggplot2 needs. To do this either open the ggplot2 rstudio project, or set your working directory to the ggplot2 directory, then run:
+
+```{r, eval = FALSE}
+install_deps(dep = T)
+```
+
+The key functions you'll use when working on ggplot2:
+
+* `devtools::load_all()`: loads all code into your current environment
+* `devtools::document()`: updates the roxygen comments
+* `devtools::test()`: run all unit tests
+* `devtools::check()`: runs R CMD check on the package to check for errors.
+
+If you're using Rstudio, I highly recommend learning the keyboard shortcuts for these commands. You can find them in the `Build` menu.
+
+## Making changes
+
+When you want to make changes, you should work on a new branch. Otherwise things can get a bit confusing when it comes time to merge it into the main repo with a pull request. You probably want to start with the `master` branch.
+
+```
+# Fetch the latest version of hadley/ggplot2
+git fetch hadley
+git checkout hadley/master
+```
+
+At this point it'll give you a warning about being in "detached HEAD" state. Don't worry about it. Just start a new branch with the current state as the starting point:
+
+```
+git checkout -b myfix
+```
+
+To check what branch you're currently on, run `git branch`.
+
+Now you can make your changes and commit them to this branch on your local repository. If you decide you want to start over, you can just check out `hadley/master` again, make a new branch, and begin anew.
+
+When you feel like sharing your changes, push them to your GitHub repo:
+
+```
+git push
+```
+
+Then you can submit a pull request if you want it to be integrated in the main branch.
+
+If you've been working on your for a while, it's possible that it won't merge properly because something has changed in both the main repo and in your branch. You can test it out by checking out the main branch and merging yourself.
+
+First, make a new branch called `testmerge`, based off the main branch:
+
+```
+git fetch hadley
+git checkout hadley/master
+
+git checkout -b testmerge
+```
+
+Then try merging your branch into testmerge:
+
+```
+git merge myfix
+```
+
+If there are no errors, great. You can switch back to your `myfix` branch and delete `testmerge`:
+
+```
+git checkout myfix
+git branch -D testmerge
+```
+
+If there are any merge conflicts, you may want to rebase your changes on top of the current master version, or just resolve the conflicts and commit it to your branch. Rebasing may make for a somewhat cleaner commit history, but there is a possibility of messing things up. If you want to be safe, you can just make a new branch and rebase that on top of the current master.
+
+## What makes a good pull request?
+
+<!--
+* [ ] Motivate the change in one paragraph, and include it in NEWS.
+ In parentheses, reference your github user name and this issue:
+ `(@hadley, #1234)`
+* [ ] Check pull request only includes relevant changes.
+* [ ] Use the [official style](http://adv-r.had.co.nz/Style.html).
+* [ ] Update documentation and re-run roxygen2
+* [ ] Add test, if bug in non-graphical function
+* [ ] Add visual test, if bug in graphical function
+* [ ] Add minimal example, if new graphical feature
+
+See http://docs.ggplot2.org/dev/vignettes/development.html for more details.
+--->
+
+Pull requests will be evaluated against the a seven point checklist:
+
+1. __Motivation__. Your pull request must clearly and concisely motivates the
+ need for change. Unfortunately neither Winston nor I have much time to
+ work on ggplot2 these days, so you need to describe the problem and show
+ how your pull request solves it as concisely as possible.
+
+ Also include this motivation in `NEWS` so that when a new release of
+ ggplot2 comes out it's easy for users to see what's changed. Add your
+ item at the top of the file and use markdown for formatting. The
+ news item should end with `(@yourGithubUsername, #the_issue_number)`.
+
+1. __Only related changes__. Before you submit your pull request, please
+ check to make sure that you haven't accidentally included any unrelated
+ changes. These make it harder to see exactly what's changed, and to
+ evaluate any unexpected side effects.
+
+ Each PR corresponds to a git branch, so if you expect to submit
+ multiple changes make sure to create multiple branches. If you have
+ multiple changes that depend on each other, start with the first one
+ and don't submit any others until the first one has been processed.
+
+1. __Use ggplot2 coding style__. Please follow the
+ [official ggplot2 style](http://adv-r.had.co.nz/Style.html). Maintaing
+ a consistent style across the whole code base makes it much easier to
+ jump into the code.
+
+1. If you're adding new parameters or a new function, you'll also need
+ to document them with [roxygen](https://github.com/klutometis/roxygen).
+ Make sure to re-run `devtools::document()` on the code before submitting.
+
+ Currently, ggplot2 uses the development version of roxygen2, which you
+ can get with `install_github("klutometis/roxygen")`. This will be
+ available on CRAN in the near future.
+
+1. If fixing a bug or adding a new feature to a non-graphical function,
+ please add a [testthat](https://github.com/hadley/testthat) unit test.
+
+1. If fixing a bug in the visual output, please add a visual test.
+ (Instructions to follow soon)
+
+1. If you're adding a new graphical feature, please add a short example
+ to the appropriate function.
+
+This seems like a lot of work but don't worry if your pull request isn't perfect. It's a learning process and Winston and I will be on hand to help you out. A pull request is a process, and unless you've submitted a few in the past it's unlikely that your pull request will be accepted as is.
+
+Finally, remember that ggplot2 is a mature package used by thousands of people. This means that it's extremely difficult (i.e. impossible) to change any existing functionality without breaking someone's code (or another package on CRAN). Please don't submit pull requests that change existing behaviour. Instead, think about how you can add a new feature in a minimally invasive way.
+
+## Advanced techniques
+
+### Fetching a branch from someone else's repository
+
+Sometimes you will want to fetch a branch from someone's repository, but without going to the trouble of seting it up as a remote. This is handy if you just want to quickly try out a someone's work.
+
+This will fetch a branch from someone's remote repository and check it out (replace `username` and `somebranch`):
+
+```
+git fetch https://github.com/username/ggplot2.git somebranch
+git checkout FETCH_HEAD
+```
+
+Just doing the above won't create a local branch -- you'll be in "detached HEAD" state. If you'd like to create a local branch to work on, run (you can replace `somebranch` with whatever name you like):
+
+```
+git checkout -b somebranch
+```
+
+### Adding other repositories as remotes
+
+If you often work off of someone else's repository, it can be useful to add their repo as a *remote*. This makes it easier to fetch changes in their repository. If the person's GitHub account is `otherdevel`, you would do the following:
+
+```
+git remote add otherdevel git://github.com/otherdevel/ggplot2.git
+git fetch otherdevel
+
+git checkout otherdevel/somebranch
+```
+
+If you don't want to follow them any more, run:
+
+```
+git remote rm otherdevel
+```
+
+### Delete a branch from GitHub
+
+If you pushed a branch to your GitHub repo but it's no longer needed there, you can remove it with:
+
+```
+git push origin :mybranch
+```
+
+### Visualizing the development tree
+
+GitHub has a very nice [development tree view](https://github.com/hadley/ggplot2/), but it of course only shows commits that have been pushed to GitHub. You may also want to view the tree on your local machine, to see how your local changes relate to the main tree. There are a number of programs out there that will do this.
+
+Mac:
+
+* gitk: Pretty basic, included with git. Run `gitk -a` to view all branches (by default it just shows you the current branch).
+
+* [gitx](http://gitx.laullon.com/): This is a bit nicer than gitk.
+
+* [SourceTree](http://www.sourcetreeapp.com/): This is also a nice program. Normally it costs money, but it is temporarily free from the web page or the [Mac App store](http://itunes.apple.com/us/app/sourcetree/id411678673?mt=12&ls=1).
+
+Linux:
+
+* gitk: (See gitk in Mac section)
+
+* gitg: This is nicer than gitk. By default it only shows the current branch; select "Local Branches" or "All Branches" to view others.
diff --git a/inst/doc/development.html b/inst/doc/development.html
new file mode 100644
index 0000000..4e22c7d
--- /dev/null
+++ b/inst/doc/development.html
@@ -0,0 +1,435 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
+
+<title>Contributing to ggplot2 development</title>
+
+<!-- Styles for R syntax highlighter -->
+<style type="text/css">
+ pre .operator,
+ pre .paren {
+ color: rgb(104, 118, 135)
+ }
+
+ pre .literal {
+ color: #990073
+ }
+
+ pre .number {
+ color: #099;
+ }
+
+ pre .comment {
+ color: #998;
+ font-style: italic
+ }
+
+ pre .keyword {
+ color: #900;
+ font-weight: bold
+ }
+
+ pre .identifier {
+ color: rgb(0, 0, 0);
+ }
+
+ pre .string {
+ color: #d14;
+ }
+</style>
+
+<!-- R syntax highlighter -->
+<script type="text/javascript">
+var hljs=new function(){function m(p){return p.replace(/&/gm,"&").replace(/</gm,"<")}function f(r,q,p){return RegExp(q,"m"+(r.cI?"i":"")+(p?"g":""))}function b(r){for(var p=0;p<r.childNodes.length;p++){var q=r.childNodes[p];if(q.nodeName=="CODE"){return q}if(!(q.nodeType==3&&q.nodeValue.match(/\s+/))){break}}}function h(t,s){var p="";for(var r=0;r<t.childNodes.length;r++){if(t.childNodes[r].nodeType==3){var q=t.childNodes[r].nodeValue;if(s){q=q.replace(/\n/g,"")}p+=q}else{if(t.chi [...]
+hljs.initHighlightingOnLoad();
+</script>
+
+<!-- MathJax scripts -->
+<script type="text/javascript" src="https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
+</script>
+
+
+<style type="text/css">
+body, td {
+ font-family: sans-serif;
+ background-color: white;
+ font-size: 13px;
+}
+
+body {
+ max-width: 800px;
+ margin: auto;
+ padding: 1em;
+ line-height: 20px;
+}
+
+tt, code, pre {
+ font-family: 'DejaVu Sans Mono', 'Droid Sans Mono', 'Lucida Console', Consolas, Monaco, monospace;
+}
+
+h1 {
+ font-size:2.2em;
+}
+
+h2 {
+ font-size:1.8em;
+}
+
+h3 {
+ font-size:1.4em;
+}
+
+h4 {
+ font-size:1.0em;
+}
+
+h5 {
+ font-size:0.9em;
+}
+
+h6 {
+ font-size:0.8em;
+}
+
+a:visited {
+ color: rgb(50%, 0%, 50%);
+}
+
+pre, img {
+ max-width: 100%;
+}
+
+pre code {
+ display: block; padding: 0.5em;
+}
+
+code {
+ font-size: 92%;
+ border: 1px solid #ccc;
+}
+
+code[class] {
+ background-color: #F8F8F8;
+}
+
+table, td, th {
+ border: none;
+}
+
+blockquote {
+ color:#666666;
+ margin:0;
+ padding-left: 1em;
+ border-left: 0.5em #EEE solid;
+}
+
+hr {
+ height: 0px;
+ border-bottom: none;
+ border-top-width: thin;
+ border-top-style: dotted;
+ border-top-color: #999999;
+}
+
+ at media print {
+ * {
+ background: transparent !important;
+ color: black !important;
+ filter:none !important;
+ -ms-filter: none !important;
+ }
+
+ body {
+ font-size:12pt;
+ max-width:100%;
+ }
+
+ a, a:visited {
+ text-decoration: underline;
+ }
+
+ hr {
+ visibility: hidden;
+ page-break-before: always;
+ }
+
+ pre, blockquote {
+ padding-right: 1em;
+ page-break-inside: avoid;
+ }
+
+ tr, img {
+ page-break-inside: avoid;
+ }
+
+ img {
+ max-width: 100% !important;
+ }
+
+ @page :left {
+ margin: 15mm 20mm 15mm 10mm;
+ }
+
+ @page :right {
+ margin: 15mm 10mm 15mm 20mm;
+ }
+
+ p, h2, h3 {
+ orphans: 3; widows: 3;
+ }
+
+ h2, h3 {
+ page-break-after: avoid;
+ }
+}
+</style>
+
+
+
+</head>
+
+<body>
+<!--
+%\VignetteEngine{knitr::knitr}
+%\VignetteIndexEntry{Contributing to ggplot2 development}
+-->
+
+<h1>Contributing to ggplot2 development</h1>
+
+<p>The goal of this guide is to help you get up and contributing to ggplot2 as quickly as possible. It's still a work in progress and very rough. Your feedback is much appreciated and so are pull requests :). Rather than emailing me directly about questions, please discuss ggplot2 development issues on the <a href="https://groups.google.com/forum/#!forum/ggplot2-dev">ggplot2-dev</a> mailing list. That way multiple people can learn at the same time.</p>
+
+<p>To contribute a change to ggplot2, you follow these steps:</p>
+
+<ol>
+<li>Set up a local ggplot2 development environment.</li>
+<li>Create a branch in git and make your changes.</li>
+<li>Push branch to github and issue pull request (PR).</li>
+<li>Discuss the pull request.</li>
+<li>Iterate until either we accept the PR or decide that it's not
+a good fit for ggplot2.</li>
+</ol>
+
+<p>Each of these steps are described in more detail below. This might feel overwhelming the first time you get set up, but it gets easier with practice. If you get stuck at any point, please reach out for help on the <a href="https://groups.google.com/forum/#!forum/ggplot2-dev">ggplot2-dev</a> mailing list</p>
+
+<h2>Basic setup</h2>
+
+<p>If you want to do development on ggplot2 and share the changes with other people, you'll have to set up an account on GitHub. You'll make a fork of Hadley's repository and store it on GitHub. You'll also make a copy of your repository on your local machine.</p>
+
+<ol>
+<li><p><a href="https://github.com/join">Join github</a>.</p></li>
+<li><p><a href="https://help.github.com/articles/set-up-git">Set up git and github</a>.</p></li>
+<li><p>Fork of the main repo by going to <a href="https://github.com/hadley/ggplot2/fork">https://github.com/hadley/ggplot2/fork</a>.
+A fork is a copy of ggplot2 that you can work on independently.
+See <a href="https://help.github.com/articles/fork-a-repo">fork a repo</a> for
+more details.</p></li>
+<li><p>Clone your fork to your local computer (change <code>myname</code> to your account
+name):</p>
+
+<pre><code>git clone git at github.com:myname/ggplot2.git
+cd ggplot2
+</code></pre></li>
+<li><p>Once you've done that, add the main repository as a remote and set up
+the master branch to track the main ggplot2 repo. This will make it
+easier to keep up to date.</p>
+
+<pre><code>git remote add hadley git://github.com/hadley/ggplot2.git
+git branch --set-upstream master hadley/master
+</code></pre></li>
+</ol>
+
+<p>Now on your local machine you have the local repository and two remote repositories: <code>origin</code> (the default), which is your personal ggplot2 repo at GitHub, and <code>hadley</code> which is Hadley's. You'll be able to push changes to your own repository only.</p>
+
+<h3>Development environment</h3>
+
+<p>You'll also need a copy of the packages I use for package development. Get them by running the following R code:</p>
+
+<pre><code class="r">install.packages(c("devtools", "testthat"))
+devtools::install_github("klutometis/roxygen")
+</code></pre>
+
+<p>Next, install all the suggested packages that ggplot2 needs. To do this either open the ggplot2 rstudio project, or set your working directory to the ggplot2 directory, then run:</p>
+
+<pre><code class="r">install_deps(dep = T)
+</code></pre>
+
+<p>The key functions you'll use when working on ggplot2:</p>
+
+<ul>
+<li><code>devtools::load_all()</code>: loads all code into your current environment</li>
+<li><code>devtools::document()</code>: updates the roxygen comments</li>
+<li><code>devtools::test()</code>: run all unit tests</li>
+<li><code>devtools::check()</code>: runs R CMD check on the package to check for errors.</li>
+</ul>
+
+<p>If you're using Rstudio, I highly recommend learning the keyboard shortcuts for these commands. You can find them in the <code>Build</code> menu.</p>
+
+<h2>Making changes</h2>
+
+<p>When you want to make changes, you should work on a new branch. Otherwise things can get a bit confusing when it comes time to merge it into the main repo with a pull request. You probably want to start with the <code>master</code> branch.</p>
+
+<pre><code># Fetch the latest version of hadley/ggplot2
+git fetch hadley
+git checkout hadley/master
+</code></pre>
+
+<p>At this point it'll give you a warning about being in “detached HEAD” state. Don't worry about it. Just start a new branch with the current state as the starting point:</p>
+
+<pre><code>git checkout -b myfix
+</code></pre>
+
+<p>To check what branch you're currently on, run <code>git branch</code>.</p>
+
+<p>Now you can make your changes and commit them to this branch on your local repository. If you decide you want to start over, you can just check out <code>hadley/master</code> again, make a new branch, and begin anew.</p>
+
+<p>When you feel like sharing your changes, push them to your GitHub repo:</p>
+
+<pre><code>git push
+</code></pre>
+
+<p>Then you can submit a pull request if you want it to be integrated in the main branch.</p>
+
+<p>If you've been working on your for a while, it's possible that it won't merge properly because something has changed in both the main repo and in your branch. You can test it out by checking out the main branch and merging yourself.</p>
+
+<p>First, make a new branch called <code>testmerge</code>, based off the main branch:</p>
+
+<pre><code>git fetch hadley
+git checkout hadley/master
+
+git checkout -b testmerge
+</code></pre>
+
+<p>Then try merging your branch into testmerge:</p>
+
+<pre><code>git merge myfix
+</code></pre>
+
+<p>If there are no errors, great. You can switch back to your <code>myfix</code> branch and delete <code>testmerge</code>:</p>
+
+<pre><code>git checkout myfix
+git branch -D testmerge
+</code></pre>
+
+<p>If there are any merge conflicts, you may want to rebase your changes on top of the current master version, or just resolve the conflicts and commit it to your branch. Rebasing may make for a somewhat cleaner commit history, but there is a possibility of messing things up. If you want to be safe, you can just make a new branch and rebase that on top of the current master.</p>
+
+<h2>What makes a good pull request?</h2>
+
+<!--
+* [ ] Motivate the change in one paragraph, and include it in NEWS.
+ In parentheses, reference your github user name and this issue:
+ `(@hadley, #1234)`
+* [ ] Check pull request only includes relevant changes.
+* [ ] Use the [official style](http://adv-r.had.co.nz/Style.html).
+* [ ] Update documentation and re-run roxygen2
+* [ ] Add test, if bug in non-graphical function
+* [ ] Add visual test, if bug in graphical function
+* [ ] Add minimal example, if new graphical feature
+
+See http://docs.ggplot2.org/dev/vignettes/development.html for more details.
+--->
+
+<p>Pull requests will be evaluated against the a seven point checklist:</p>
+
+<ol>
+<li><p><strong>Motivation</strong>. Your pull request must clearly and concisely motivates the
+need for change. Unfortunately neither Winston nor I have much time to
+work on ggplot2 these days, so you need to describe the problem and show
+how your pull request solves it as concisely as possible.</p>
+
+<p>Also include this motivation in <code>NEWS</code> so that when a new release of
+ggplot2 comes out it's easy for users to see what's changed. Add your
+item at the top of the file and use markdown for formatting. The
+news item should end with <code>(@yourGithubUsername, #the_issue_number)</code>.</p></li>
+<li><p><strong>Only related changes</strong>. Before you submit your pull request, please
+check to make sure that you haven't accidentally included any unrelated
+changes. These make it harder to see exactly what's changed, and to
+evaluate any unexpected side effects.</p>
+
+<p>Each PR corresponds to a git branch, so if you expect to submit
+multiple changes make sure to create multiple branches. If you have
+multiple changes that depend on each other, start with the first one
+and don't submit any others until the first one has been processed.</p></li>
+<li><p><strong>Use ggplot2 coding style</strong>. Please follow the
+<a href="http://adv-r.had.co.nz/Style.html">official ggplot2 style</a>. Maintaing
+a consistent style across the whole code base makes it much easier to
+jump into the code.</p></li>
+<li><p>If you're adding new parameters or a new function, you'll also need
+to document them with <a href="https://github.com/klutometis/roxygen">roxygen</a>.
+Make sure to re-run <code>devtools::document()</code> on the code before submitting.</p>
+
+<p>Currently, ggplot2 uses the development version of roxygen2, which you
+can get with <code>install_github("klutometis/roxygen")</code>. This will be
+available on CRAN in the near future.</p></li>
+<li><p>If fixing a bug or adding a new feature to a non-graphical function,
+please add a <a href="https://github.com/hadley/testthat">testthat</a> unit test.</p></li>
+<li><p>If fixing a bug in the visual output, please add a visual test.
+(Instructions to follow soon)</p></li>
+<li><p>If you're adding a new graphical feature, please add a short example
+to the appropriate function.</p></li>
+</ol>
+
+<p>This seems like a lot of work but don't worry if your pull request isn't perfect. It's a learning process and Winston and I will be on hand to help you out. A pull request is a process, and unless you've submitted a few in the past it's unlikely that your pull request will be accepted as is.</p>
+
+<p>Finally, remember that ggplot2 is a mature package used by thousands of people. This means that it's extremely difficult (i.e. impossible) to change any existing functionality without breaking someone's code (or another package on CRAN). Please don't submit pull requests that change existing behaviour. Instead, think about how you can add a new feature in a minimally invasive way.</p>
+
+<h2>Advanced techniques</h2>
+
+<h3>Fetching a branch from someone else's repository</h3>
+
+<p>Sometimes you will want to fetch a branch from someone's repository, but without going to the trouble of seting it up as a remote. This is handy if you just want to quickly try out a someone's work.</p>
+
+<p>This will fetch a branch from someone's remote repository and check it out (replace <code>username</code> and <code>somebranch</code>):</p>
+
+<pre><code>git fetch https://github.com/username/ggplot2.git somebranch
+git checkout FETCH_HEAD
+</code></pre>
+
+<p>Just doing the above won't create a local branch – you'll be in “detached HEAD” state. If you'd like to create a local branch to work on, run (you can replace <code>somebranch</code> with whatever name you like):</p>
+
+<pre><code>git checkout -b somebranch
+</code></pre>
+
+<h3>Adding other repositories as remotes</h3>
+
+<p>If you often work off of someone else's repository, it can be useful to add their repo as a <em>remote</em>. This makes it easier to fetch changes in their repository. If the person's GitHub account is <code>otherdevel</code>, you would do the following:</p>
+
+<pre><code>git remote add otherdevel git://github.com/otherdevel/ggplot2.git
+git fetch otherdevel
+
+git checkout otherdevel/somebranch
+</code></pre>
+
+<p>If you don't want to follow them any more, run:</p>
+
+<pre><code>git remote rm otherdevel
+</code></pre>
+
+<h3>Delete a branch from GitHub</h3>
+
+<p>If you pushed a branch to your GitHub repo but it's no longer needed there, you can remove it with:</p>
+
+<pre><code>git push origin :mybranch
+</code></pre>
+
+<h3>Visualizing the development tree</h3>
+
+<p>GitHub has a very nice <a href="https://github.com/hadley/ggplot2/">development tree view</a>, but it of course only shows commits that have been pushed to GitHub. You may also want to view the tree on your local machine, to see how your local changes relate to the main tree. There are a number of programs out there that will do this.</p>
+
+<p>Mac:</p>
+
+<ul>
+<li><p>gitk: Pretty basic, included with git. Run <code>gitk -a</code> to view all branches (by default it just shows you the current branch).</p></li>
+<li><p><a href="http://gitx.laullon.com/">gitx</a>: This is a bit nicer than gitk.</p></li>
+<li><p><a href="http://www.sourcetreeapp.com/">SourceTree</a>: This is also a nice program. Normally it costs money, but it is temporarily free from the web page or the <a href="http://itunes.apple.com/us/app/sourcetree/id411678673?mt=12&ls=1">Mac App store</a>.</p></li>
+</ul>
+
+<p>Linux:</p>
+
+<ul>
+<li><p>gitk: (See gitk in Mac section)</p></li>
+<li><p>gitg: This is nicer than gitk. By default it only shows the current branch; select “Local Branches” or “All Branches” to view others.</p></li>
+</ul>
+
+</body>
+
+</html>
diff --git a/inst/doc/release.R b/inst/doc/release.R
new file mode 100644
index 0000000..9ab4517
--- /dev/null
+++ b/inst/doc/release.R
@@ -0,0 +1,10 @@
+
+## ----, echo = FALSE, message = FALSE-------------------------------------
+knitr::opts_chunk$set(
+ comment = "#>",
+ error = FALSE,
+ tidy = FALSE
+)
+library(ggplot2)
+
+
diff --git a/inst/doc/release.Rmd b/inst/doc/release.Rmd
new file mode 100644
index 0000000..2efe4bf
--- /dev/null
+++ b/inst/doc/release.Rmd
@@ -0,0 +1,107 @@
+<!--
+%\VignetteEngine{knitr::knitr}
+%\VignetteIndexEntry{ggplot2 release process}
+-->
+
+```{r, echo = FALSE, message = FALSE}
+knitr::opts_chunk$set(
+ comment = "#>",
+ error = FALSE,
+ tidy = FALSE
+)
+library(ggplot2)
+```
+
+# Releasing a new version of ggplot2
+
+## Release candidate phase
+
+After issues resolved for a given release:
+
+1. Pass R CMD check.
+
+1. In DESCRIPTION and NEWS, remove the .99 version suffix and increment the
+ version number. For example, 0.9.2.99 becomes 0.9.3.
+
+1. Do the same for any packages that ggplot2 depends on, such as scales and
+ gtable.
+
+1. Update ggplot2's Import dependency versions to use the final release numbers
+ of scales and gtable.
+
+1. Commit these changes to a branch with `ggplot2-<version>-rc`, and push the
+ branch.
+
+1. Check packages that depend on ggplot2 with `devtools::revdep_check()` and
+ run visual tests.
+
+1. Email ggplot2, ggplot2-dev, and bcc the maintainers of packages that depend
+ on ggplot2 (`revdep_maintainers("ggplot2")`).
+
+ ```
+ Hi all,
+
+ We're very please to announce a release candidate for ggplot2 1.0.0! This
+ release celebrates the ggplot2 community: all improvements have been
+ contributed via pull requests.
+
+ We've made every effort to make sure that your existing ggplot2 graphics
+ continue to work. ggplot2 1.0.0 has passed R CMD check, all our existing
+ visual tests, and R CMD check on all dependencies. But it's still possible
+ that some bugs may have crept in, so we'd really appreciate it if you'd
+ try it out. It's easy to install the development version: first install
+ devtools, then run `devtools::install_github("hadley/ggplot2 at ggplot2-1.0.0-rc")`.
+
+ We plan to submit ggplot2 to cran in two weeks, May 9. Please let us know if
+ you have any problems - your feedback is much appreciated. (If you're pretty
+ sure you've discovered a new bug, please start a new thread or file
+ an issue on github, otherwise it's a bit hard to track what's going on).
+
+ Hadley & Winston
+ ```
+
+1. Notify cran:
+
+ ```
+ Dear CRAN maintainers,
+
+ ggplot2 1.0.0 has entered the release candidate phase and will be
+ submitted to CRAN in two weeks.
+
+ Included below is the email that I sent to the ggplot2 mailing and all
+ maintainers of packages that depend on ggplot2.
+
+ Regards,
+
+ Hadley
+ ```
+
+If problems arise during the RC period, make fixes on the branch. Those fixes
+later get merged back into master.
+
+## Release
+
+When the package is accepted on CRAN:
+
+1. Create a new release at https://github.com/hadley/ggplot2/releases.
+ The tag name should be of the form `v1.0.0`.
+
+1. If any Check out the new branch, or merge it into master. (Need to get off the
+ rc branch so it can be deleted):
+
+ ```
+ VERSION=1.0.0
+ git checkout v$VERSION
+ # Or
+ git checkout master
+ git merge v$VERSION
+ ```
+
+1. Delete the `-rc` branch, with:
+
+ ```
+ git branch -d v$VERSION-rc
+ git push origin :v$VERSION-rc
+ ```
+
+1. Once you push the tag github, travis will automatically build the website.
diff --git a/inst/doc/release.html b/inst/doc/release.html
new file mode 100644
index 0000000..7a4b608
--- /dev/null
+++ b/inst/doc/release.html
@@ -0,0 +1,243 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
+
+<title>Releasing a new version of ggplot2</title>
+
+
+
+
+
+<style type="text/css">
+body, td {
+ font-family: sans-serif;
+ background-color: white;
+ font-size: 13px;
+}
+
+body {
+ max-width: 800px;
+ margin: auto;
+ padding: 1em;
+ line-height: 20px;
+}
+
+tt, code, pre {
+ font-family: 'DejaVu Sans Mono', 'Droid Sans Mono', 'Lucida Console', Consolas, Monaco, monospace;
+}
+
+h1 {
+ font-size:2.2em;
+}
+
+h2 {
+ font-size:1.8em;
+}
+
+h3 {
+ font-size:1.4em;
+}
+
+h4 {
+ font-size:1.0em;
+}
+
+h5 {
+ font-size:0.9em;
+}
+
+h6 {
+ font-size:0.8em;
+}
+
+a:visited {
+ color: rgb(50%, 0%, 50%);
+}
+
+pre, img {
+ max-width: 100%;
+}
+
+pre code {
+ display: block; padding: 0.5em;
+}
+
+code {
+ font-size: 92%;
+ border: 1px solid #ccc;
+}
+
+code[class] {
+ background-color: #F8F8F8;
+}
+
+table, td, th {
+ border: none;
+}
+
+blockquote {
+ color:#666666;
+ margin:0;
+ padding-left: 1em;
+ border-left: 0.5em #EEE solid;
+}
+
+hr {
+ height: 0px;
+ border-bottom: none;
+ border-top-width: thin;
+ border-top-style: dotted;
+ border-top-color: #999999;
+}
+
+ at media print {
+ * {
+ background: transparent !important;
+ color: black !important;
+ filter:none !important;
+ -ms-filter: none !important;
+ }
+
+ body {
+ font-size:12pt;
+ max-width:100%;
+ }
+
+ a, a:visited {
+ text-decoration: underline;
+ }
+
+ hr {
+ visibility: hidden;
+ page-break-before: always;
+ }
+
+ pre, blockquote {
+ padding-right: 1em;
+ page-break-inside: avoid;
+ }
+
+ tr, img {
+ page-break-inside: avoid;
+ }
+
+ img {
+ max-width: 100% !important;
+ }
+
+ @page :left {
+ margin: 15mm 20mm 15mm 10mm;
+ }
+
+ @page :right {
+ margin: 15mm 10mm 15mm 20mm;
+ }
+
+ p, h2, h3 {
+ orphans: 3; widows: 3;
+ }
+
+ h2, h3 {
+ page-break-after: avoid;
+ }
+}
+</style>
+
+
+
+</head>
+
+<body>
+<!--
+%\VignetteEngine{knitr::knitr}
+%\VignetteIndexEntry{ggplot2 release process}
+-->
+
+<h1>Releasing a new version of ggplot2</h1>
+
+<h2>Release candidate phase</h2>
+
+<p>After issues resolved for a given release:</p>
+
+<ol>
+<li><p>Pass R CMD check.</p></li>
+<li><p>In DESCRIPTION and NEWS, remove the .99 version suffix and increment the
+version number. For example, 0.9.2.99 becomes 0.9.3.</p></li>
+<li><p>Do the same for any packages that ggplot2 depends on, such as scales and
+gtable.</p></li>
+<li><p>Update ggplot2's Import dependency versions to use the final release numbers
+of scales and gtable.</p></li>
+<li><p>Commit these changes to a branch with <code>ggplot2-<version>-rc</code>, and push the
+branch.</p></li>
+<li><p>Check packages that depend on ggplot2 with <code>devtools::revdep_check()</code> and
+run visual tests.</p></li>
+<li><p>Email ggplot2, ggplot2-dev, and bcc the maintainers of packages that depend
+on ggplot2 (<code>revdep_maintainers("ggplot2")</code>).</p>
+
+<pre><code>Hi all,
+
+We're very please to announce a release candidate for ggplot2 1.0.0! This
+release celebrates the ggplot2 community: all improvements have been
+contributed via pull requests.
+
+We've made every effort to make sure that your existing ggplot2 graphics
+continue to work. ggplot2 1.0.0 has passed R CMD check, all our existing
+visual tests, and R CMD check on all dependencies. But it's still possible
+that some bugs may have crept in, so we'd really appreciate it if you'd
+try it out. It's easy to install the development version: first install
+devtools, then run `devtools::install_github("hadley/ggplot2 at ggplot2-1.0.0-rc")`.
+
+We plan to submit ggplot2 to cran in two weeks, May 9. Please let us know if
+you have any problems - your feedback is much appreciated. (If you're pretty
+sure you've discovered a new bug, please start a new thread or file
+an issue on github, otherwise it's a bit hard to track what's going on).
+
+Hadley & Winston
+</code></pre></li>
+<li><p>Notify cran:</p>
+
+<pre><code>Dear CRAN maintainers,
+
+ggplot2 1.0.0 has entered the release candidate phase and will be
+submitted to CRAN in two weeks.
+
+Included below is the email that I sent to the ggplot2 mailing and all
+maintainers of packages that depend on ggplot2.
+
+Regards,
+
+Hadley
+</code></pre></li>
+</ol>
+
+<p>If problems arise during the RC period, make fixes on the branch. Those fixes
+later get merged back into master.</p>
+
+<h2>Release</h2>
+
+<p>When the package is accepted on CRAN:</p>
+
+<ol>
+<li><p>Create a new release at <a href="https://github.com/hadley/ggplot2/releases">https://github.com/hadley/ggplot2/releases</a>.
+The tag name should be of the form <code>v1.0.0</code>.</p></li>
+<li><p>If any Check out the new branch, or merge it into master. (Need to get off the
+rc branch so it can be deleted):</p>
+
+<pre><code>VERSION=1.0.0
+git checkout v$VERSION
+# Or
+git checkout master
+git merge v$VERSION
+</code></pre></li>
+<li><p>Delete the <code>-rc</code> branch, with:</p>
+
+<pre><code>git branch -d v$VERSION-rc
+git push origin :v$VERSION-rc
+</code></pre></li>
+<li><p>Once you push the tag github, travis will automatically build the website.</p></li>
+</ol>
+
+</body>
+
+</html>
diff --git a/inst/staticdocs/README.md b/inst/staticdocs/README.md
new file mode 100644
index 0000000..e69de29
diff --git a/inst/staticdocs/icons.R b/inst/staticdocs/icons.R
new file mode 100644
index 0000000..3b951af
--- /dev/null
+++ b/inst/staticdocs/icons.R
@@ -0,0 +1,422 @@
+# Coords -----------------------------------------------------------------------
+coord_cartesian <- sd_icon({
+ gTree(children = gList(
+ segmentsGrob(c(0, 0.25), c(0.25, 0), c(1, 0.25), c(0.25, 1),
+ gp=gpar(col="grey50", lwd=0.5)),
+ segmentsGrob(c(0, 0.75), c(0.75, 0), c(1, 0.75), c(0.75, 1),
+ gp=gpar(col="grey50", lwd=0.5)),
+ segmentsGrob(c(0, 0.5), c(0.5, 0), c(1, 0.5), c(0.5, 1))
+ ))
+})
+
+coord_fixed <- sd_icon({
+ textGrob("=", gp = gpar(cex=3))
+})
+
+coord_flip <- sd_icon({
+ angles <- seq(0, pi/2, length=20)[-c(1, 20)]
+ gTree(children=gList(
+ segmentsGrob(0, 0, 0, 1),
+ segmentsGrob(0, 0, 1, 0),
+ linesGrob(0.9 * sin(angles), 0.9 * cos(angles),
+ arrow=arrow(length=unit(0.05, "npc"))),
+ linesGrob(0.5 * sin(angles), 0.5 * cos(angles),
+ arrow=arrow(ends="first", length= unit(0.05, "npc")))
+ ))
+})
+
+library(maps)
+coord_map <- sd_icon({
+ nz <- data.frame(map("nz", plot=FALSE)[c("x","y")])
+ nz$x <- nz$x - min(nz$x, na.rm=TRUE)
+ nz$y <- nz$y - min(nz$y, na.rm=TRUE)
+ nz <- nz / max(nz, na.rm=TRUE)
+ linesGrob(nz$x, nz$y, default.units="npc")
+})
+
+coord_polar <- sd_icon({
+ circleGrob(r = c(0.1, 0.25, 0.45), gp = gpar(fill = NA))
+})
+
+coord_transform <- sd_icon({
+ breaks <- cumsum(1 / 2^(1:5))
+ gTree(children = gList(
+ segmentsGrob(breaks, 0, breaks, 1),
+ segmentsGrob(0, breaks, 1, breaks)
+ ))
+})
+
+# Faceting ---------------------------------------------------------------------
+
+facet_grid <- sd_icon({
+ gTree(children = gList(
+ rectGrob(0, 1, width=0.95, height=0.05, hjust=0, vjust=1,
+ gp=gpar(fill="grey60", col=NA)),
+ rectGrob(0.95, 0.95, width=0.05, height=0.95, hjust=0, vjust=1,
+ gp=gpar(fill="grey60", col=NA)),
+ segmentsGrob(c(0, 0.475), c(0.475, 0), c(1, 0.475), c(0.475, 1))
+ ))
+})
+
+facet_null <- sd_icon({
+ gTree(children = gList(
+ rectGrob(0, 1, width=0.95, height=0.05, hjust=0, vjust=1,
+ gp=gpar(fill="grey60", col=NA)),
+ rectGrob(0.95, 0.95, width=0.05, height=0.95, hjust=0, vjust=1,
+ gp=gpar(fill="grey60", col=NA)),
+ segmentsGrob(c(0, 0.475), c(0.475, 0), c(1, 0.475), c(0.475, 1))
+ ))
+})
+
+# Geoms ------------------------------------------------------------------------
+
+geom_abline <- sd_icon(linesGrob(c(0, 1), c(0.2, 0.8)))
+
+geom_bar <- sd_icon({
+ rectGrob(c(0.3, 0.7), c(0.4, 0.8), height = c(0.4, 0.8), width = 0.3,
+ vjust = 1, gp = gpar(fill = "grey20", col = NA))
+})
+
+geom_histogram <- sd_icon({
+ y <- c(0.2, 0.3, 0.5, 0.6,0.2, 0.8, 0.5, 0.3)
+ rectGrob(seq(0.1, 0.9, by = 0.1), y, height = y, width = 0.1, vjust = 1,
+ gp = gpar(fill = "grey20", col = NA))
+})
+
+geom_boxplot <- sd_icon({
+ gTree(children = gList(
+ segmentsGrob(c(0.3, 0.7), c(0.1, 0.2), c(0.3, 0.7), c(0.7, 0.95)),
+ rectGrob(c(0.3, 0.7), c(0.6, 0.8), width = 0.3, height = c(0.4, 0.4),
+ vjust = 1),
+ segmentsGrob(c(0.15, 0.55), c(0.5, 0.6), c(0.45, 0.85), c(0.5, 0.6))
+ ))
+})
+
+geom_crossbar <- sd_icon({
+ gTree(children = gList(
+ rectGrob(c(0.3, 0.7), c(0.6, 0.8), width = 0.3, height = c(0.4, 0.4), vjust = 1),
+ segmentsGrob(c(0.15, 0.55), c(0.5, 0.6), c(0.45, 0.85), c(0.5, 0.6))
+ ))
+})
+
+geom_dotplot <- sd_icon({
+ xpos <- c(1,1,2,3,3,3,4,4,5,5,5,5,6,7,7,7,8,8,9)/10
+ ypos <- c(1,2,1,1,2,3,1,2,1,2,3,4,1,1,2,3,1,2,1)/10
+ pointsGrob(x = xpos, y = ypos, pch = 19, size = unit(.1, "npc"),
+ gp = gpar(col = "black", cex = 0.5), default.units = "npc")
+})
+
+geom_errorbar <- sd_icon({
+ gTree(children = gList(
+ segmentsGrob(c(0.3, 0.7), c(0.3, 0.5), c(0.3, 0.7), c(0.7, 0.9)),
+ segmentsGrob(c(0.15, 0.55), c(0.3, 0.5), c(0.45, 0.85), c(0.3, 0.5)),
+ segmentsGrob(c(0.15, 0.55), c(0.7, 0.9), c(0.45, 0.85), c(0.7, 0.9))
+ ))
+})
+
+geom_errorbarh <- sd_icon({
+ gTree(children = gList(
+ segmentsGrob(c(0.5, 0.3), c(0.70, 0.30), c(0.9, 0.7), c(0.70, 0.30)),
+ segmentsGrob(c(0.5, 0.3), c(0.55, 0.15), c(0.5, 0.3), c(0.85, 0.45)),
+ segmentsGrob(c(0.9, 0.7), c(0.55, 0.15), c(0.9, 0.7), c(0.85, 0.45))
+ ))
+})
+
+geom_freqpoly <- sd_icon({
+ y <- c(0.2, 0.3, 0.5, 0.6,0.2, 0.8, 0.5, 0.3)
+ linesGrob(seq(0.1, 0.9, by = 0.1), y, gp = gpar(col = "grey20"))
+})
+
+geom_hline <- sd_icon({
+ linesGrob(c(0, 1), c(0.5, 0.5))
+})
+
+geom_linerange <- sd_icon({
+ segmentsGrob(c(0.3, 0.7), c(0.1, 0.2), c(0.3, 0.7), c(0.7, 0.95))
+})
+
+geom_path <- sd_icon({
+ linesGrob(c(0.2, 0.4, 0.8, 0.6, 0.5), c(0.2, 0.7, 0.4, 0.1, 0.5))
+})
+
+geom_contour <- sd_icon({
+ gTree(children = gList(
+ polygonGrob(c(0.45,0.5,0.6, 0.5), c(0.5, 0.4, 0.55, 0.6)),
+ polygonGrob(c(0.25,0.6,0.8, 0.5), c(0.5, 0.2, 0.75, 0.9),
+ gp = gpar(fill = NA))
+ ))
+})
+
+geom_density2d <- sd_icon(inherit = "geom_contour")
+
+geom_line <- sd_icon({
+ pos <- seq(0, 1, length = 5)
+ linesGrob(pos, c(0.2, 0.7, 0.4, 0.8, 0.3))
+})
+
+geom_step <- sd_icon({
+ n <- 15
+ xs <- rep(0:n, each = 2)[-2*(n + 1)] / 15
+ ys <- c(0, rep(1:n, each = 2)) / 15
+ linesGrob(xs, ys, gp = gpar(col = "grey20"))
+})
+
+geom_point <- sd_icon({
+ pos <- seq(0.1, 0.9, length = 6)
+ pointsGrob(x = pos, y = pos, pch = 19,
+ gp = gpar(col = "black", cex = 0.5), default.units = "npc")
+})
+
+geom_jitter <- sd_icon({
+ pos <- seq(0.1, 0.9, length = 6)
+ pointsGrob(x = pos, y = jitter(pos, 3), pch = 19,
+ gp = gpar(col = "black", cex = 0.5), default.units = "npc")
+})
+
+geom_pointrange <- sd_icon({
+ gTree(children = gList(
+ segmentsGrob(c(0.3, 0.7), c(0.1, 0.2), c(0.3, 0.7), c(0.7, 0.95)),
+ pointsGrob(c(0.3, 0.7), c(0.4, 0.6), pch = 19,
+ gp = gpar(col = "black", cex = 0.5), default.units = "npc")
+ ))
+})
+
+geom_polygon <- sd_icon({
+ polygonGrob(c(0.1, 0.4, 0.7, 0.9, 0.6, 0.3),
+ c(0.5, 0.8, 0.9, 0.4, 0.2, 0.3), gp = gpar(fill = "grey20", col = NA))
+})
+
+geom_quantile <- sd_icon({
+ gTree(children = gList(
+ linesGrob(c(0, 0.3, 0.5, 0.8, 1), c(0.8, 0.65, 0.6, 0.6, 0.8)),
+ linesGrob(c(0, 0.3, 0.5, 0.8, 1), c(0.55, 0.45, 0.5, 0.45, 0.55)),
+ linesGrob(c(0, 0.3, 0.5, 0.8, 1), c(0.3, 0.25, 0.4, 0.3, 0.2))
+ ))
+})
+
+geom_raster <- sd_icon({
+ rectGrob(c(0.25, 0.25, 0.75, 0.75), c(0.25, 0.75, 0.75, 0.25),
+ width = 0.5, height = c(0.67, 0.5, 0.67, 0.5),
+ gp = gpar(col = "grey20", fill = c('#804070', '#668040')))
+})
+
+geom_rect <- sd_icon({
+ rectGrob(c(0.3, 0.7), c(0.4, 0.8), height = c(0.4, 0.8), width = 0.3,
+ vjust = 1, gp = gpar(fill = "grey20", col = NA))
+})
+
+geom_ribbon <- sd_icon({
+ polygonGrob(c(0, 0.3, 0.5, 0.8, 1, 1, 0.8, 0.5, 0.3, 0),
+ c(0.5, 0.3, 0.4, 0.2, 0.3, 0.7, 0.5, 0.6, 0.5, 0.7),
+ gp = gpar(fill = "grey20", col = NA))
+})
+
+geom_area <- sd_icon({
+ polygonGrob(c(0, 0,0.3, 0.5, 0.8, 1, 1),
+ c(0, 1,0.5, 0.6, 0.3, 0.8, 0),
+ gp = gpar(fill = "grey20", col = NA))
+})
+
+geom_density <- sd_icon({
+ x <- seq(0, 1, length = 80)
+ y <- dnorm(x, mean = 0.5, sd = 0.15)
+ linesGrob(x, 0.05 + y / max(y) * 0.9, default = "npc")
+})
+
+geom_segment <- sd_icon({
+ segmentsGrob(c(0.1, 0.3, 0.5, 0.7), c(0.3, 0.5, 0.1, 0.9),
+ c(0.2, 0.5, 0.7, 0.9), c(0.8, 0.7, 0.4, 0.3))
+})
+
+geom_smooth <- sd_icon({
+ gTree(children = gList(
+ polygonGrob(c(0, 0.3, 0.5, 0.8, 1, 1, 0.8, 0.5, 0.3, 0),
+ c(0.5, 0.3, 0.4, 0.2, 0.3, 0.7, 0.5, 0.6, 0.5, 0.7),
+ gp = gpar(fill = "grey60", col = NA)),
+ linesGrob(c(0, 0.3, 0.5, 0.8, 1), c(0.6, 0.4, 0.5, 0.4, 0.6))
+ ))
+})
+
+geom_text <- sd_icon({
+ textGrob("text", rot = 45, gp = gpar(cex = 1.2))
+})
+
+geom_tile <- sd_icon({
+ rectGrob(c(0.25, 0.25, 0.75, 0.75), c(0.25, 0.75, 0.75, 0.25),
+ width = 0.5, height = c(0.67, 0.5, 0.67, 0.5),
+ gp = gpar(col = "grey20", fill = c('#804070', '#668040')))
+})
+
+geom_violin <- sd_icon({
+ y <- seq(-.3, .3, length = 40)
+ x1 <- dnorm(y, mean = -.15, sd = 0.05) +
+ 1.5 * dnorm(y, mean = 0.1, sd = 0.1)
+ x2 <- dnorm(y, mean = -.1, sd = 0.1) + dnorm(y, mean = 0.1, sd = 0.1)
+
+ y <- c(y, rev(y))
+ x1 <- c(x1, -rev(x1)) / max(8 * x1)
+ x2 <- c(x2, -rev(x2)) / max(8 * x2)
+ gp <- gpar(fill = "black")
+ gTree(children = gList(
+ polygonGrob(x1 + .30, y + .35, default = "npc", gp = gp),
+ polygonGrob(x2 + .70, y + .55, default = "npc", gp = gp))
+ )
+})
+
+geom_vline <- sd_icon({
+ linesGrob(c(0.5, 0.5), c(0, 1))
+})
+
+# Position adjustments --------------------------------------------------------
+
+position_dodge <- sd_icon({
+ y <- c(0.5, 0.3)
+ rectGrob(c(0.25, 0.75), y, width = 0.4, height = y,
+ gp = gpar(col = "grey60", fill = c('#804070', '#668040')), vjust = 1)
+})
+
+position_fill <- sd_icon({
+ y <- c(0.5, 0.8)
+ rectGrob(0.5, c(0.625, 1), width = 0.4, height = c(0.625, 0.375),
+ gp = gpar(col = "grey60", fill = c('#804070', '#668040')), vjust = 1)
+})
+
+position_identity <- sd_icon({
+ rectGrob(0.5, c(0.5, 0.3), width = 0.4, height = c(0.5, 0.3),
+ gp = gpar(col = "grey60", fill = c('#804070', '#668040')), vjust = 1)
+})
+
+position_jitter <- sd_icon(inherit = "geom_jitter" )
+
+position_stack <- sd_icon({
+ y <- c(0.5, 0.8)
+ rectGrob(0.5, c(0.5, 0.8), width = 0.4, height = c(0.5, 0.3),
+ gp = gpar(col = "grey60", fill = c('#804070', '#668040')), vjust = 1)
+})
+
+# Scales -----------------------------------------------------------------------
+
+scale_alpha <- sd_icon({
+ x <- c(0.1, 0.3, 0.5, 0.7, 0.9)
+ rectGrob(x, width=0.25,
+ gp=gpar(fill=scales::alpha("black", x), col=NA)
+ )
+})
+
+scale_colour_brewer <- sd_icon({
+ rectGrob(c(0.1, 0.3, 0.5, 0.7, 0.9), width=0.21,
+ gp=gpar(fill=RColorBrewer::brewer.pal(5, "PuOr"), col=NA)
+ )
+})
+
+scale_colour_gradient <- sd_icon({
+ g <- scale_fill_gradient()
+ scale_train(g, 1:5)
+ rectGrob(c(0.1, 0.3, 0.5, 0.7, 0.9), width=0.21,
+ gp=gpar(fill=scale_map(g, 1:5), col=NA)
+ )
+})
+
+scale_colour_gradient2 <- sd_icon({
+ g <- scale_fill_gradient2()
+ scale_train(g, 1:5 - 3)
+ rectGrob(c(0.1, 0.3, 0.5, 0.7, 0.9), width=0.21,
+ gp=gpar(fill=scale_map(g, 1:5 - 3), col=NA)
+ )
+})
+
+scale_colour_gradientn <- sd_icon({
+ g <- scale_fill_gradientn(colours = rainbow(7))
+ scale_train(g, 1:5)
+ rectGrob(c(0.1, 0.3, 0.5, 0.7, 0.9), width=0.21,
+ gp=gpar(fill = scale_map(g, 1:5), col=NA)
+ )
+})
+
+scale_colour_grey <- sd_icon({
+ rectGrob(c(0.1, 0.3, 0.5, 0.7, 0.9), width=0.21,
+ gp=gpar(fill=gray(seq(0, 1, length=5)), col=NA)
+ )
+})
+
+scale_colour_hue <- sd_icon({
+ rectGrob(c(0.1, 0.3, 0.5, 0.7, 0.9), width=0.21,
+ gp=gpar(fill=hcl(seq(0, 360, length=6)[-6], c=100, l=65), col=NA)
+ )
+})
+
+scale_identity <- sd_icon({
+ textGrob("f(x) = x", gp=gpar(cex=1.2))
+})
+
+scale_linetype <- sd_icon({
+ gTree(children=gList(
+ segmentsGrob(0, 0.25, 1, 0.25, gp=gpar(lty=1)),
+ segmentsGrob(0, 0.50, 1, 0.50, gp=gpar(lty=2)),
+ segmentsGrob(0, 0.75, 1, 0.75, gp=gpar(lty=3))
+ ))
+})
+
+scale_manual <- sd_icon({
+ textGrob("DIY", gp=gpar(cex=1.2))
+})
+
+scale_shape <- sd_icon({
+ gTree(children=gList(
+ circleGrob(0.7, 0.7, r=0.1),
+ segmentsGrob(0.2, 0.3, 0.4, 0.3),
+ segmentsGrob(0.3, 0.2, 0.3, 0.4),
+ polygonGrob(c(0.2, 0.2, 0.4, 0.4), c(0.8, 0.6, 0.6, 0.8)),
+ polygonGrob(c(0.6, 0.7, 0.8), c(0.2, 0.4, 0.2))
+ ))
+})
+
+scale_size <- sd_icon({
+ pos <- c(0.15, 0.3, 0.5, 0.75)
+ circleGrob(pos, pos, r=(c(0.1, 0.2, 0.3, 0.4)/2.5), gp=gpar(fill="grey50", col=NA))
+})
+
+scale_x_date <- sd_icon({
+ textGrob("14/10/1979", gp=gpar(cex=1))
+})
+
+scale_x_datetime <- sd_icon({
+ textGrob("14/10/1979\n10:14am", gp=gpar(cex=0.9))
+})
+
+# Statistics -------------------------------------------------------------------
+
+stat_bin <- sd_icon(inherit = "geom_histogram" )
+
+stat_bindot <- sd_icon(inherit = "geom_dotplot" )
+
+stat_boxplot <- sd_icon(inherit = "geom_boxplot" )
+
+stat_contour <- sd_icon(inherit = "geom_contour" )
+
+stat_density2d <- sd_icon(inherit = "geom_density2d" )
+
+stat_ecdf <- sd_icon(inherit = "geom_step")
+
+stat_density <- sd_icon(inherit = "geom_density" )
+
+stat_identity <- sd_icon({
+ textGrob('f(x) = x', gp = gpar(cex = 1.2))
+})
+
+stat_quantile <- sd_icon(inherit = "geom_quantile" )
+
+stat_smooth <- sd_icon(inherit = "geom_smooth" )
+
+stat_sum <- sd_icon({
+ textGrob(expression(Sigma), gp = gpar(cex = 4))
+})
+
+# The line stats will be removed in the future
+stat_abline <- sd_icon(inherit = "geom_abline" )
+
+stat_vline <- sd_icon(inherit = "geom_vline" )
+
+stat_hline <- sd_icon(inherit = "geom_hline" )
+
+stat_ydensity <- sd_icon(inherit = "geom_violin" )
diff --git a/inst/staticdocs/index.r b/inst/staticdocs/index.r
index d985fd1..9eab5b7 100644
--- a/inst/staticdocs/index.r
+++ b/inst/staticdocs/index.r
@@ -1,557 +1,224 @@
-library(staticdocs)
-list(
- readme = "",
- index = list(
- sd_section("Geoms",
- "Geoms, short for geometric objects, describe the type of plot you will produce.",
- c(
- "geom_abline",
- "geom_area",
- "geom_bar",
- "geom_bin2d",
- "geom_blank",
- "geom_boxplot",
- "geom_contour",
- "geom_crossbar",
- "geom_density",
- "geom_density2d",
- "geom_dotplot",
- "geom_errorbar",
- "geom_errorbarh",
- "geom_freqpoly",
- "geom_hex",
- "geom_histogram",
- "geom_hline",
- "geom_jitter",
- "geom_line",
- "geom_linerange",
- "geom_map",
- "geom_path",
- "geom_point",
- "geom_pointrange",
- "geom_polygon",
- "geom_quantile",
- "geom_raster",
- "geom_rect",
- "geom_ribbon",
- "geom_rug",
- "geom_segment",
- "geom_smooth",
- "geom_step",
- "geom_text",
- "geom_tile",
- "geom_violin",
- "geom_vline"
- )
- ),
- sd_section("Statistics",
- "It's often useful to transform your data before plotting, and that's what statistical transformations do.",
- c(
- "stat_bin",
- "stat_bin2d",
- "stat_bindot",
- "stat_binhex",
- "stat_boxplot",
- "stat_contour",
- "stat_density",
- "stat_density2d",
- "stat_ecdf",
- "stat_function",
- "stat_identity",
- "stat_qq",
- "stat_quantile",
- "stat_smooth",
- "stat_spoke",
- "stat_sum",
- "stat_summary",
- "stat_summary_hex",
- "stat_summary2d",
- "stat_unique",
- "stat_ydensity"
- )
- ),
- sd_section("Scales",
- "Scales control the mapping between data and aesthetics.",
- c(
- "expand_limits",
- "guides",
- "guide_legend",
- "guide_colourbar",
- "scale_alpha",
- "scale_area",
- "scale_colour_brewer",
- "scale_colour_gradient",
- "scale_colour_gradient2",
- "scale_colour_gradientn",
- "scale_colour_grey",
- "scale_colour_hue",
- "scale_identity",
- "scale_manual",
- "scale_linetype",
- "scale_shape",
- "scale_size",
- "scale_x_continuous",
- "scale_x_date",
- "scale_x_datetime",
- "scale_x_discrete",
- "labs",
- "update_labels",
- "xlim"
- )
- ),
- sd_section("Coordinate systems",
- "Coordinate systems adjust the mapping from coordinates to the 2d plane of the computer screen.",
- c(
- "coord_cartesian",
- "coord_fixed",
- "coord_flip",
- "coord_map",
- "coord_polar",
- "coord_trans"
- )
- ),
+sd_section("Geoms",
+ "Geoms, short for geometric objects, describe the type of plot you will produce.",
+ c(
+ "geom_abline",
+ "geom_area",
+ "geom_bar",
+ "geom_bin2d",
+ "geom_blank",
+ "geom_boxplot",
+ "geom_contour",
+ "geom_crossbar",
+ "geom_density",
+ "geom_density2d",
+ "geom_dotplot",
+ "geom_errorbar",
+ "geom_errorbarh",
+ "geom_freqpoly",
+ "geom_hex",
+ "geom_histogram",
+ "geom_hline",
+ "geom_jitter",
+ "geom_line",
+ "geom_linerange",
+ "geom_map",
+ "geom_path",
+ "geom_point",
+ "geom_pointrange",
+ "geom_polygon",
+ "geom_quantile",
+ "geom_raster",
+ "geom_rect",
+ "geom_ribbon",
+ "geom_rug",
+ "geom_segment",
+ "geom_smooth",
+ "geom_step",
+ "geom_text",
+ "geom_tile",
+ "geom_violin",
+ "geom_vline"
+ )
+)
- sd_section("Faceting",
- "Facets display subsets of the dataset in different panels.",
- c(
- "facet_grid",
- "facet_null",
- "facet_wrap",
- "label_both",
- "label_bquote",
- "label_parsed",
- "label_value"
- )
- ),
+sd_section("Statistics",
+ "It's often useful to transform your data before plotting, and that's what statistical transformations do.",
+ c(
+ "stat_bin",
+ "stat_bin2d",
+ "stat_bindot",
+ "stat_binhex",
+ "stat_boxplot",
+ "stat_contour",
+ "stat_density",
+ "stat_density2d",
+ "stat_ecdf",
+ "stat_function",
+ "stat_identity",
+ "stat_qq",
+ "stat_quantile",
+ "stat_smooth",
+ "stat_spoke",
+ "stat_sum",
+ "stat_summary",
+ "stat_summary_hex",
+ "stat_summary2d",
+ "stat_unique",
+ "stat_ydensity"
+ )
+)
- sd_section("Position adjustments",
- "Position adjustments can be used to fine tune positioning of objects to achieve effects like dodging, jittering and stacking.",
- c(
- "position_dodge",
- "position_fill",
- "position_identity",
- "position_stack",
- "position_jitter"
- )
- ),
- sd_section("Data",
- "Data sets included in ggplot2 and used in examples",
- c(
- "diamonds",
- "economics",
- "midwest",
- "movies",
- "mpg",
- "msleep",
- "presidential",
- "seals"
- )
- ),
- sd_section("Anotation",
- "Specialised functions for adding annotations to a plot",
- c(
- "annotate",
- "annotation_custom",
- "annotation_logticks",
- "annotation_map",
- "annotation_raster",
- "borders"
- )
- ),
- sd_section("Fortify",
- "Fortify methods make it possible to use ggplot2 with objects of
- various types, not just data frames.",
- c(
- "fortify",
- "fortify-multcomp",
- "fortify.lm",
- "fortify.map",
- "fortify.sp",
- "map_data"
- )
- ),
- sd_section("Themes",
- "Themes control non-data components of the plot",
- c(
- "add_theme",
- "calc_element",
- "element_blank",
- "element_line",
- "element_rect",
- "element_text",
- "is.rel",
- "is.theme",
- "opts",
- "rel",
- "theme",
- "theme_bw",
- "theme_grey",
- "theme_update",
- "update_element"
- )
- ),
- sd_section("Plot creation", "",
- c(
- "ggplot",
- "qplot",
- "+.gg",
- "autoplot",
- "ggplot.data.frame",
- "is.ggplot",
- "print.ggplot"
- )
- ),
- sd_section("Aesthetics",
- "",
- c(
- "aes",
- "aes_all",
- "aes_auto",
- "aes_string",
- "aes_colour_fill_alpha",
- "aes_group_order",
- "aes_linetype_size_shape",
- "aes_position"
- )
- )
-
- ),
- icons = list(
- coord_cartesian = sd_icon({
- gTree(children = gList(
- segmentsGrob(c(0, 0.25), c(0.25, 0), c(1, 0.25), c(0.25, 1),
- gp=gpar(col="grey50", lwd=0.5)),
- segmentsGrob(c(0, 0.75), c(0.75, 0), c(1, 0.75), c(0.75, 1),
- gp=gpar(col="grey50", lwd=0.5)),
- segmentsGrob(c(0, 0.5), c(0.5, 0), c(1, 0.5), c(0.5, 1))
- ))
- }),
- coord_fixed = sd_icon({
- textGrob("=", gp = gpar(cex=3))
- }),
- coord_flip = sd_icon({
- angles <- seq(0, pi/2, length=20)[-c(1, 20)]
- gTree(children=gList(
- segmentsGrob(0, 0, 0, 1),
- segmentsGrob(0, 0, 1, 0),
- linesGrob(0.9 * sin(angles), 0.9 * cos(angles),
- arrow=arrow(length=unit(0.05, "npc"))),
- linesGrob(0.5 * sin(angles), 0.5 * cos(angles),
- arrow=arrow(ends="first", length= unit(0.05, "npc")))
- ))
- }),
- coord_map = sd_icon({
- nz <- data.frame(map("nz", plot=FALSE)[c("x","y")])
- nz$x <- nz$x - min(nz$x, na.rm=TRUE)
- nz$y <- nz$y - min(nz$y, na.rm=TRUE)
- nz <- nz / max(nz, na.rm=TRUE)
- linesGrob(nz$x, nz$y, default.units="npc")
- }),
- coord_polar = sd_icon({
- circleGrob(r = c(0.1, 0.25, 0.45), gp = gpar(fill = NA))
- }),
- coord_transform = sd_icon({
- breaks <- cumsum(1 / 2^(1:5))
- gTree(children = gList(
- segmentsGrob(breaks, 0, breaks, 1),
- segmentsGrob(0, breaks, 1, breaks)
- ))
- }),
- facet_grid = sd_icon({
- gTree(children = gList(
- rectGrob(0, 1, width=0.95, height=0.05, hjust=0, vjust=1,
- gp=gpar(fill="grey60", col=NA)),
- rectGrob(0.95, 0.95, width=0.05, height=0.95, hjust=0, vjust=1,
- gp=gpar(fill="grey60", col=NA)),
- segmentsGrob(c(0, 0.475), c(0.475, 0), c(1, 0.475), c(0.475, 1))
- ))
- }),
- facet_null = sd_icon({
- gTree(children = gList(
- rectGrob(0, 1, width=0.95, height=0.05, hjust=0, vjust=1,
- gp=gpar(fill="grey60", col=NA)),
- rectGrob(0.95, 0.95, width=0.05, height=0.95, hjust=0, vjust=1,
- gp=gpar(fill="grey60", col=NA)),
- segmentsGrob(c(0, 0.475), c(0.475, 0), c(1, 0.475), c(0.475, 1))
- ))
- }),
- geom_abline = sd_icon(linesGrob(c(0, 1), c(0.2, 0.8))),
- geom_bar = sd_icon({
- rectGrob(c(0.3, 0.7), c(0.4, 0.8), height = c(0.4, 0.8), width = 0.3,
- vjust = 1, gp = gpar(fill = "grey20", col = NA))
- }),
- geom_histogram = sd_icon({
- y <- c(0.2, 0.3, 0.5, 0.6,0.2, 0.8, 0.5, 0.3)
- rectGrob(seq(0.1, 0.9, by = 0.1), y, height = y, width = 0.1, vjust = 1,
- gp = gpar(fill = "grey20", col = NA))
- }),
- geom_boxplot = sd_icon({
- gTree(children = gList(
- segmentsGrob(c(0.3, 0.7), c(0.1, 0.2), c(0.3, 0.7), c(0.7, 0.95)),
- rectGrob(c(0.3, 0.7), c(0.6, 0.8), width = 0.3, height = c(0.4, 0.4),
- vjust = 1),
- segmentsGrob(c(0.15, 0.55), c(0.5, 0.6), c(0.45, 0.85), c(0.5, 0.6))
- ))
- }),
- geom_crossbar = sd_icon({
- gTree(children = gList(
- rectGrob(c(0.3, 0.7), c(0.6, 0.8), width = 0.3, height = c(0.4, 0.4), vjust = 1),
- segmentsGrob(c(0.15, 0.55), c(0.5, 0.6), c(0.45, 0.85), c(0.5, 0.6))
- ))
- }),
- geom_dotplot = sd_icon({
- xpos <- c(1,1,2,3,3,3,4,4,5,5,5,5,6,7,7,7,8,8,9)/10
- ypos <- c(1,2,1,1,2,3,1,2,1,2,3,4,1,1,2,3,1,2,1)/10
- pointsGrob(x = xpos, y = ypos, pch = 19, size = unit(.1, "npc"),
- gp = gpar(col = "black", cex = 0.5), default.units = "npc")
- }),
- geom_errorbar = sd_icon({
- gTree(children = gList(
- segmentsGrob(c(0.3, 0.7), c(0.3, 0.5), c(0.3, 0.7), c(0.7, 0.9)),
- segmentsGrob(c(0.15, 0.55), c(0.3, 0.5), c(0.45, 0.85), c(0.3, 0.5)),
- segmentsGrob(c(0.15, 0.55), c(0.7, 0.9), c(0.45, 0.85), c(0.7, 0.9))
- ))
- }),
- geom_errorbarh = sd_icon({
- gTree(children = gList(
- segmentsGrob(c(0.5, 0.3), c(0.70, 0.30), c(0.9, 0.7), c(0.70, 0.30)),
- segmentsGrob(c(0.5, 0.3), c(0.55, 0.15), c(0.5, 0.3), c(0.85, 0.45)),
- segmentsGrob(c(0.9, 0.7), c(0.55, 0.15), c(0.9, 0.7), c(0.85, 0.45))
- ))
- }),
- geom_freqpoly = sd_icon({
- y <- c(0.2, 0.3, 0.5, 0.6,0.2, 0.8, 0.5, 0.3)
- linesGrob(seq(0.1, 0.9, by = 0.1), y, gp = gpar(col = "grey20"))
- }),
- geom_hline = sd_icon({
- linesGrob(c(0, 1), c(0.5, 0.5))
- }),
- geom_linerange = sd_icon({
- segmentsGrob(c(0.3, 0.7), c(0.1, 0.2), c(0.3, 0.7), c(0.7, 0.95))
- }),
- geom_path = sd_icon({
- linesGrob(c(0.2, 0.4, 0.8, 0.6, 0.5), c(0.2, 0.7, 0.4, 0.1, 0.5))
- }),
- geom_contour = sd_icon({
- gTree(children = gList(
- polygonGrob(c(0.45,0.5,0.6, 0.5), c(0.5, 0.4, 0.55, 0.6)),
- polygonGrob(c(0.25,0.6,0.8, 0.5), c(0.5, 0.2, 0.75, 0.9),
- gp = gpar(fill = NA))
- ))
- }),
- geom_density2d = sd_icon(inherit = "geom_contour"),
- geom_line = sd_icon({
- pos <- seq(0, 1, length = 5)
- linesGrob(pos, c(0.2, 0.7, 0.4, 0.8, 0.3))
- }),
- geom_step = sd_icon({
- n <- 15
- xs <- rep(0:n, each = 2)[-2*(n + 1)] / 15
- ys <- c(0, rep(1:n, each = 2)) / 15
- linesGrob(xs, ys, gp = gpar(col = "grey20"))
- }),
- geom_point = sd_icon({
- pos <- seq(0.1, 0.9, length = 6)
- pointsGrob(x = pos, y = pos, pch = 19,
- gp = gpar(col = "black", cex = 0.5), default.units = "npc")
- }),
- geom_jitter = sd_icon({
- pos <- seq(0.1, 0.9, length = 6)
- pointsGrob(x = pos, y = jitter(pos, 3), pch = 19,
- gp = gpar(col = "black", cex = 0.5), default.units = "npc")
- }),
- geom_pointrange = sd_icon({
- gTree(children = gList(
- segmentsGrob(c(0.3, 0.7), c(0.1, 0.2), c(0.3, 0.7), c(0.7, 0.95)),
- pointsGrob(c(0.3, 0.7), c(0.4, 0.6), pch = 19,
- gp = gpar(col = "black", cex = 0.5), default.units = "npc")
- ))
- }),
- geom_polygon = sd_icon({
- polygonGrob(c(0.1, 0.4, 0.7, 0.9, 0.6, 0.3),
- c(0.5, 0.8, 0.9, 0.4, 0.2, 0.3), gp = gpar(fill = "grey20", col = NA))
- }),
- geom_quantile = sd_icon({
- gTree(children = gList(
- linesGrob(c(0, 0.3, 0.5, 0.8, 1), c(0.8, 0.65, 0.6, 0.6, 0.8)),
- linesGrob(c(0, 0.3, 0.5, 0.8, 1), c(0.55, 0.45, 0.5, 0.45, 0.55)),
- linesGrob(c(0, 0.3, 0.5, 0.8, 1), c(0.3, 0.25, 0.4, 0.3, 0.2))
- ))
- }),
- geom_raster = sd_icon({
- rectGrob(c(0.25, 0.25, 0.75, 0.75), c(0.25, 0.75, 0.75, 0.25),
- width = 0.5, height = c(0.67, 0.5, 0.67, 0.5),
- gp = gpar(col = "grey20", fill = c('#804070', '#668040')))
- }),
- geom_rect = sd_icon({
- rectGrob(c(0.3, 0.7), c(0.4, 0.8), height = c(0.4, 0.8), width = 0.3,
- vjust = 1, gp = gpar(fill = "grey20", col = NA))
- }),
- geom_ribbon = sd_icon({
- polygonGrob(c(0, 0.3, 0.5, 0.8, 1, 1, 0.8, 0.5, 0.3, 0),
- c(0.5, 0.3, 0.4, 0.2, 0.3, 0.7, 0.5, 0.6, 0.5, 0.7),
- gp = gpar(fill = "grey20", col = NA))
- }),
- geom_area = sd_icon({
- polygonGrob(c(0, 0,0.3, 0.5, 0.8, 1, 1),
- c(0, 1,0.5, 0.6, 0.3, 0.8, 0),
- gp = gpar(fill = "grey20", col = NA))
- }),
- geom_density = sd_icon({
- x <- seq(0, 1, length = 80)
- y <- dnorm(x, mean = 0.5, sd = 0.15)
- linesGrob(x, 0.05 + y / max(y) * 0.9, default = "npc")
- }),
- geom_segment = sd_icon({
- segmentsGrob(c(0.1, 0.3, 0.5, 0.7), c(0.3, 0.5, 0.1, 0.9),
- c(0.2, 0.5, 0.7, 0.9), c(0.8, 0.7, 0.4, 0.3))
- }),
- geom_smooth = sd_icon({
- gTree(children = gList(
- polygonGrob(c(0, 0.3, 0.5, 0.8, 1, 1, 0.8, 0.5, 0.3, 0),
- c(0.5, 0.3, 0.4, 0.2, 0.3, 0.7, 0.5, 0.6, 0.5, 0.7),
- gp = gpar(fill = "grey60", col = NA)),
- linesGrob(c(0, 0.3, 0.5, 0.8, 1), c(0.6, 0.4, 0.5, 0.4, 0.6))
- ))
- }),
- geom_text = sd_icon({
- textGrob("text", rot = 45, gp = gpar(cex = 1.2))
- }),
- geom_tile = sd_icon({
- rectGrob(c(0.25, 0.25, 0.75, 0.75), c(0.25, 0.75, 0.75, 0.25),
- width = 0.5, height = c(0.67, 0.5, 0.67, 0.5),
- gp = gpar(col = "grey20", fill = c('#804070', '#668040')))
- }),
- geom_violin = sd_icon({
- y <- seq(-.3, .3, length = 40)
- x1 <- dnorm(y, mean = -.15, sd = 0.05) +
- 1.5 * dnorm(y, mean = 0.1, sd = 0.1)
- x2 <- dnorm(y, mean = -.1, sd = 0.1) + dnorm(y, mean = 0.1, sd = 0.1)
+sd_section("Scales",
+ "Scales control the mapping between data and aesthetics.",
+ c(
+ "expand_limits",
+ "guides",
+ "guide_legend",
+ "guide_colourbar",
+ "scale_alpha",
+ "scale_area",
+ "scale_size_area",
+ "scale_colour_brewer",
+ "scale_colour_gradient",
+ "scale_colour_gradient2",
+ "scale_colour_gradientn",
+ "scale_colour_grey",
+ "scale_colour_hue",
+ "scale_identity",
+ "scale_manual",
+ "scale_linetype",
+ "scale_shape",
+ "scale_size",
+ "scale_x_continuous",
+ "scale_x_date",
+ "scale_x_datetime",
+ "scale_x_discrete",
+ "labs",
+ "update_labels",
+ "xlim"
+ )
+)
- y <- c(y, rev(y))
- x1 <- c(x1, -rev(x1)) / max(8 * x1)
- x2 <- c(x2, -rev(x2)) / max(8 * x2)
- gp <- gpar(fill = "black")
- gTree(children = gList(
- polygonGrob(x1 + .30, y + .35, default = "npc", gp = gp),
- polygonGrob(x2 + .70, y + .55, default = "npc", gp = gp))
- )
- }),
- geom_vline = sd_icon({
- linesGrob(c(0.5, 0.5), c(0, 1))
- }),
- position_dodge = sd_icon({
- y <- c(0.5, 0.3)
- rectGrob(c(0.25, 0.75), y, width = 0.4, height = y,
- gp = gpar(col = "grey60", fill = c('#804070', '#668040')), vjust = 1)
- }),
- position_fill = sd_icon({
- y <- c(0.5, 0.8)
- rectGrob(0.5, c(0.625, 1), width = 0.4, height = c(0.625, 0.375),
- gp = gpar(col = "grey60", fill = c('#804070', '#668040')), vjust = 1)
- }),
- position_identity = sd_icon({
- rectGrob(0.5, c(0.5, 0.3), width = 0.4, height = c(0.5, 0.3),
- gp = gpar(col = "grey60", fill = c('#804070', '#668040')), vjust = 1)
- }),
- position_jitter = sd_icon(inherit = "geom_jitter" ),
- position_stack = sd_icon({
- y <- c(0.5, 0.8)
- rectGrob(0.5, c(0.5, 0.8), width = 0.4, height = c(0.5, 0.3),
- gp = gpar(col = "grey60", fill = c('#804070', '#668040')), vjust = 1)
- }),
- scale_alpha = sd_icon({
- x <- c(0.1, 0.3, 0.5, 0.7, 0.9)
- rectGrob(x, width=0.25,
- gp=gpar(fill=alpha("black", x), col=NA)
- )
- }),
- scale_colour_brewer = sd_icon({
- rectGrob(c(0.1, 0.3, 0.5, 0.7, 0.9), width=0.21,
- gp=gpar(fill=RColorBrewer::brewer.pal(5, "PuOr"), col=NA)
- )
- }),
- scale_colour_gradient = sd_icon({
- g <- scale_fill_gradient()
- scale_train(g, 1:5)
- rectGrob(c(0.1, 0.3, 0.5, 0.7, 0.9), width=0.21,
- gp=gpar(fill=scale_map(g, 1:5), col=NA)
- )
- }),
- scale_colour_gradient2 = sd_icon({
- g <- scale_fill_gradient2()
- scale_train(g, 1:5 - 3)
- rectGrob(c(0.1, 0.3, 0.5, 0.7, 0.9), width=0.21,
- gp=gpar(fill=scale_map(g, 1:5 - 3), col=NA)
- )
- }),
- scale_colour_gradientn = sd_icon({
- g <- scale_fill_gradientn(colours = rainbow(7))
- scale_train(g, 1:5)
- rectGrob(c(0.1, 0.3, 0.5, 0.7, 0.9), width=0.21,
- gp=gpar(fill = scale_map(g, 1:5), col=NA)
- )
- }),
- scale_colour_grey = sd_icon({
- rectGrob(c(0.1, 0.3, 0.5, 0.7, 0.9), width=0.21,
- gp=gpar(fill=gray(seq(0, 1, length=5)), col=NA)
- )
- }),
- scale_colour_hue = sd_icon({
- rectGrob(c(0.1, 0.3, 0.5, 0.7, 0.9), width=0.21,
- gp=gpar(fill=hcl(seq(0, 360, length=6)[-6], c=100, l=65), col=NA)
- )
- }),
- scale_identity = sd_icon({
- textGrob("f(x) = x", gp=gpar(cex=1.2))
- }),
- scale_linetype = sd_icon({
- gTree(children=gList(
- segmentsGrob(0, 0.25, 1, 0.25, gp=gpar(lty=1)),
- segmentsGrob(0, 0.50, 1, 0.50, gp=gpar(lty=2)),
- segmentsGrob(0, 0.75, 1, 0.75, gp=gpar(lty=3))
- ))
- }),
- scale_manual = sd_icon({
- textGrob("DIY", gp=gpar(cex=1.2))
- }),
- scale_shape = sd_icon({
- gTree(children=gList(
- circleGrob(0.7, 0.7, r=0.1),
- segmentsGrob(0.2, 0.3, 0.4, 0.3),
- segmentsGrob(0.3, 0.2, 0.3, 0.4),
- polygonGrob(c(0.2, 0.2, 0.4, 0.4), c(0.8, 0.6, 0.6, 0.8)),
- polygonGrob(c(0.6, 0.7, 0.8), c(0.2, 0.4, 0.2))
- ))
- }),
- scale_size = sd_icon({
- pos <- c(0.15, 0.3, 0.5, 0.75)
- circleGrob(pos, pos, r=(c(0.1, 0.2, 0.3, 0.4)/2.5), gp=gpar(fill="grey50", col=NA))
- }),
- scale_x_date = sd_icon({
- textGrob("14/10/1979", gp=gpar(cex=1))
- }),
- scale_x_datetime = sd_icon({
- textGrob("14/10/1979\n10:14am", gp=gpar(cex=0.9))
- }),
- stat_bin = sd_icon(inherit = "geom_histogram" ),
- stat_bindot = sd_icon(inherit = "geom_dotplot" ),
- stat_boxplot = sd_icon(inherit = "geom_boxplot" ),
- stat_contour = sd_icon(inherit = "geom_contour" ),
- stat_density2d = sd_icon(inherit = "geom_density2d" ),
- stat_ecdf = sd_icon(inherit = "geom_step"),
- stat_density = sd_icon(inherit = "geom_density" ),
- stat_identity = sd_icon({
- textGrob('f(x) = x', gp = gpar(cex = 1.2))
- }),
- stat_quantile = sd_icon(inherit = "geom_quantile" ),
- stat_smooth = sd_icon(inherit = "geom_smooth" ),
- stat_sum = sd_icon({
- textGrob(expression(Sigma), gp = gpar(cex = 4))
- }),
- # The line stats will be removed in the future
- stat_abline = sd_icon(inherit = "geom_abline" ),
- stat_vline = sd_icon(inherit = "geom_vline" ),
- stat_hline = sd_icon(inherit = "geom_hline" ),
- stat_ydensity = sd_icon(inherit = "geom_violin" )
-))
\ No newline at end of file
+sd_section("Coordinate systems",
+ "Coordinate systems adjust the mapping from coordinates to the 2d plane of the computer screen.",
+ c(
+ "coord_cartesian",
+ "coord_fixed",
+ "coord_flip",
+ "coord_map",
+ "coord_polar",
+ "coord_trans"
+ )
+)
+
+sd_section("Faceting",
+ "Facets display subsets of the dataset in different panels.",
+ c(
+ "facet_grid",
+ "facet_null",
+ "facet_wrap",
+ "label_both",
+ "label_bquote",
+ "label_parsed",
+ "label_value"
+ )
+)
+
+sd_section("Position adjustments",
+ "Position adjustments can be used to fine tune positioning of objects to achieve effects like dodging, jittering and stacking.",
+ c(
+ "position_dodge",
+ "position_fill",
+ "position_identity",
+ "position_stack",
+ "position_jitter"
+ )
+)
+
+sd_section("Data",
+ "Data sets included in ggplot2 and used in examples",
+ c(
+ "diamonds",
+ "economics",
+ "midwest",
+ "movies",
+ "mpg",
+ "msleep",
+ "presidential",
+ "seals"
+ )
+)
+
+sd_section("Anotation",
+ "Specialised functions for adding annotations to a plot",
+ c(
+ "annotate",
+ "annotation_custom",
+ "annotation_logticks",
+ "annotation_map",
+ "annotation_raster",
+ "borders"
+ )
+)
+
+sd_section("Fortify",
+ "Fortify methods make it possible to use ggplot2 with objects of
+ various types, not just data frames.",
+ c(
+ "fortify",
+ "fortify-multcomp",
+ "fortify.lm",
+ "fortify.map",
+ "fortify.sp",
+ "map_data"
+ )
+)
+
+sd_section("Themes",
+ "Themes control non-data components of the plot",
+ c(
+ "add_theme",
+ "calc_element",
+ "element_blank",
+ "element_line",
+ "element_rect",
+ "element_text",
+ "is.rel",
+ "is.theme",
+ "opts",
+ "rel",
+ "theme",
+ "theme_blank",
+ "theme_bw",
+ "theme_classic",
+ "theme_grey",
+ "theme_minimal",
+ "theme_update",
+ "update_element"
+ )
+)
+
+sd_section("Plot creation", "",
+ c(
+ "ggplot",
+ "qplot",
+ "+.gg",
+ "autoplot",
+ "ggplot.data.frame",
+ "is.ggplot",
+ "print.ggplot"
+ )
+)
+
+sd_section("Aesthetics", "",
+ c(
+ "aes",
+ "aes_all",
+ "aes_auto",
+ "aes_string",
+ "aes_colour_fill_alpha",
+ "aes_group_order",
+ "aes_linetype_size_shape",
+ "aes_position"
+ )
+)
diff --git a/inst/test_ns/R/my-plot.r b/inst/test_ns/R/my-plot.r
index 4660379..a826e61 100644
--- a/inst/test_ns/R/my-plot.r
+++ b/inst/test_ns/R/my-plot.r
@@ -8,5 +8,5 @@ my_plot <- function() {
df <- data.frame(x = 1:10, y = sample(10), z = runif(1))
ggplot(df) + geom_point(aes_string(x = "x", y = "y", colour = "z"))
-
-}
\ No newline at end of file
+
+}
diff --git a/inst/tests/helper-plot-data.r b/inst/tests/helper-plot-data.r
index 07b9f49..1a242c6 100644
--- a/inst/tests/helper-plot-data.r
+++ b/inst/tests/helper-plot-data.r
@@ -3,7 +3,7 @@ pdata <- function(x) ggplot_build(x)$data
# Transform the data as the coordinate system does
cdata <- function(plot) {
pieces <- ggplot_build(plot)
-
+
lapply(pieces$data, function(d) {
ddply(d, "PANEL", function(panel_data) {
scales <- panel_scales(pieces$panel, panel_data$PANEL[1])
@@ -15,14 +15,14 @@ cdata <- function(plot) {
pranges <- function(plot) {
panels <- ggplot_build(plot)$panel
-
+
x_ranges <- lapply(panels$x_scales, scale_limits)
y_ranges <- lapply(panels$y_scales, scale_limits)
-
-
- npscales <- plot$scales$non_position_scales()
+
+
+ npscales <- plot$scales$non_position_scales()
npranges <- lapply(npscales$scales$scales, scale_limits)
-
-
+
+
c(list(x = x_ranges, y = y_ranges), npranges)
}
diff --git a/inst/tests/test-aes-grouping.r b/inst/tests/test-aes-grouping.r
index af9b269..bfa86de 100644
--- a/inst/tests/test-aes-grouping.r
+++ b/inst/tests/test-aes-grouping.r
@@ -13,7 +13,7 @@ groups <- function(x) length(unique(group(x)))
test_that("one group per combination of discrete vars", {
plot <- ggplot(df, aes(x, x)) + geom_point()
expect_that(group(plot), equals(c(1, 1, 1, 1)))
-
+
plot <- ggplot(df, aes(x, a)) + geom_point()
expect_that(group(plot), equals(c(1, 1, 2, 2)))
plot <- ggplot(df, aes(x, b)) + geom_point()
@@ -34,7 +34,7 @@ test_that("label is not used as a grouping var", {
test_that("group aesthetic overrides defaults", {
plot <- ggplot(df, aes(x, x, group = x)) + geom_point()
expect_that(groups(plot), equals(4))
-
+
plot <- ggplot(df, aes(a, b, group = 1)) + geom_point()
expect_that(groups(plot), equals(1))
})
@@ -46,7 +46,7 @@ test_that("group aesthetic overrides defaults", {
test_that("order affects plotting order of points", {
base <- ggplot(df, aes(a, x)) + geom_point()
-
+
ord1 <- ggplot_build(base)$data[[1]]
ord2 <- ggplot_build(base + aes(order = x))$data[[1]]
rev1 <- ggplot_build(base + aes(order = -x))$data[[1]]
@@ -60,7 +60,7 @@ test_that("order affects plotting order of points", {
test_that("order affects plotting order of bars", {
base <- ggplot(df, aes(a, fill = b)) + geom_bar()
-
+
ord1 <- ggplot_build(base)$data[[1]]
ord2 <- ggplot_build(base + aes(order = a))$data[[1]]
rev1 <- ggplot_build(base + aes(order = desc(b)))$data[[1]]
@@ -68,4 +68,4 @@ test_that("order affects plotting order of bars", {
expect_equal(ord1$group, 1:4)
expect_equal(ord2$group, 1:4)
expect_equal(rev1$group, c(2, 1, 4, 3))
-})
\ No newline at end of file
+})
diff --git a/inst/tests/test-aes-setting.r b/inst/tests/test-aes-setting.r
index c227474..be97da0 100644
--- a/inst/tests/test-aes-setting.r
+++ b/inst/tests/test-aes-setting.r
@@ -3,13 +3,13 @@ context("Aes - setting values")
test_that("Aesthetic parameters must match length of data", {
df <- data.frame(x = 1:5, y = 1:5)
p <- ggplot(df, aes(x, y))
-
+
set_colours <- function(colours) {
pdf(file=NULL)
print(p + geom_point(colour = colours))
dev.off()
}
-
+
set_colours("red")
expect_error(set_colours(rep("red", 2)), "Incompatible lengths")
dev.off() # Need to manually close device because of error
@@ -18,6 +18,6 @@ test_that("Aesthetic parameters must match length of data", {
expect_error(set_colours(rep("red", 4)), "Incompatible lengths")
dev.off()
set_colours(rep("red", 5))
-
-
-})
\ No newline at end of file
+
+
+})
diff --git a/inst/tests/test-aes.r b/inst/tests/test-aes.r
index c6b0797..07449aa 100644
--- a/inst/tests/test-aes.r
+++ b/inst/tests/test-aes.r
@@ -3,16 +3,16 @@ context("Creating aesthetic mappings")
test_that("function aes", {
expect_equal(aes(x = mpg, y = wt),
structure(list(x = bquote(mpg), y = bquote(wt)), class = "uneval"))
-
+
expect_equal(aes(x = mpg ^ 2, y = wt / cyl),
structure(list(x = bquote(mpg ^ 2), y = bquote(wt / cyl)), class = "uneval"))
-
+
})
test_that("function aes_string", {
expect_equal(aes_string(x = "mpg", y = "wt"),
structure(list(x = bquote(mpg), y = bquote(wt)), class = "uneval"))
-
+
expect_equal(aes_string(x = "mpg ^ 2", y = "wt / cyl"),
structure(list(x = bquote(mpg ^ 2), y = bquote(wt / cyl)), class = "uneval"))
})
@@ -33,7 +33,7 @@ test_that("function aes_all", {
gear = bquote(gear),
carb = bquote(carb)),
class = "uneval"))
-
+
expect_equal(aes_all(c("x", "y", "col", "pch")),
structure(list(x = bquote(x), y = bquote(y), colour = bquote(col), shape = bquote(pch)), class = "uneval"))
})
@@ -59,4 +59,4 @@ test_that("function aes_auto", {
structure(list(x = bquote(xp), y = bquote(yp)), class = "uneval"))
expect_equal(aes_auto(df), structure(setNames(list(), character(0)), class = "uneval"))
})
-
+
diff --git a/inst/tests/test-build.r b/inst/tests/test-build.r
index 3dc596b..7770eb1 100644
--- a/inst/tests/test-build.r
+++ b/inst/tests/test-build.r
@@ -3,9 +3,9 @@ context("Plot building")
df <- data.frame(x = 1:3, y = 3:1, z = letters[1:3])
-test_that("there is one data frame for each layer", {
- l1 <- ggplot(df, aes(x, y)) + geom_point()
- l2 <- ggplot(df, aes(x, y)) + geom_point() + geom_line()
+test_that("there is one data frame for each layer", {
+ l1 <- ggplot(df, aes(x, y)) + geom_point()
+ l2 <- ggplot(df, aes(x, y)) + geom_point() + geom_line()
l3 <- ggplot(df, aes(x, y)) + geom_point() + geom_line() + geom_point()
expect_that(length(pdata(l1)), equals(1))
@@ -16,7 +16,7 @@ test_that("there is one data frame for each layer", {
test_that("position aesthetics coerced to correct type", {
l1 <- ggplot(df, aes(x, y)) + geom_point()
d1 <- pdata(l1)[[1]]
-
+
expect_that(d1$x, is_a("numeric"))
expect_that(d1$y, is_a("numeric"))
@@ -24,19 +24,19 @@ test_that("position aesthetics coerced to correct type", {
d2 <- pdata(l2)[[1]]
expect_that(d2$x, is_a("integer"))
- expect_that(d2$y, is_a("integer"))
+ expect_that(d2$y, is_a("integer"))
})
test_that("non-position aesthetics are mapped", {
l1 <- ggplot(df, aes(x, y, fill = z, colour = z, shape = z, size = z)) +
- geom_point()
+ geom_point()
d1 <- pdata(l1)[[1]]
-
+
expect_that(sort(names(d1)), equals(sort(c("x", "y", "fill", "group",
"colour", "shape", "size", "PANEL"))))
l2 <- l1 + scale_colour_manual(values = c("blue", "red", "yellow"))
d2 <- pdata(l2)[[1]]
- expect_that(d2$colour, equals(c("blue", "red", "yellow")))
+ expect_that(d2$colour, equals(c("blue", "red", "yellow")))
})
diff --git a/inst/tests/test-data.r b/inst/tests/test-data.r
index 3503960..8226be2 100644
--- a/inst/tests/test-data.r
+++ b/inst/tests/test-data.r
@@ -23,4 +23,4 @@ test_that("stringsAsFactors doesn't affect results", {
expect_that(xlabels(char_false), equals(letters[1:5]))
expect_that(xlabels(factor_true), equals(letters[1:5]))
expect_that(xlabels(factor_false), equals(letters[1:5]))
-})
\ No newline at end of file
+})
diff --git a/inst/tests/test-facet-.r b/inst/tests/test-facet-.r
index 0a006cc..0054d01 100644
--- a/inst/tests/test-facet-.r
+++ b/inst/tests/test-facet-.r
@@ -5,15 +5,15 @@ df <- data.frame(x = 1:3, y = 3:1, z = letters[1:3])
test_that("facets split up the data", {
l1 <- ggplot(df, aes(x, y)) + geom_point() + facet_wrap(~ z)
d1 <- pdata(l1)[[1]]
-
+
expect_that(d1$PANEL, equals(factor(1:3)))
l2 <- ggplot(df, aes(x, y)) + geom_point() + facet_grid(. ~ z)
l3 <- ggplot(df, aes(x, y)) + geom_point() + facet_grid(z ~ .)
-
+
d2 <- pdata(l2)[[1]]
d3 <- pdata(l3)[[1]]
-
+
expect_that(d2, equals(d3))
expect_that(sort(names(d2)), equals(sort(c("x", "y", "group", "PANEL"))))
expect_that(d2$PANEL, equals(factor(1:3)))
@@ -21,19 +21,19 @@ test_that("facets split up the data", {
test_that("facets with free scales scale independently", {
- l1 <- ggplot(df, aes(x, y)) + geom_point() +
+ l1 <- ggplot(df, aes(x, y)) + geom_point() +
facet_wrap(~ z, scales = "free")
d1 <- cdata(l1)[[1]]
expect_that(length(unique(d1$x)), equals(1))
expect_that(length(unique(d1$y)), equals(1))
- l2 <- ggplot(df, aes(x, y)) + geom_point() +
+ l2 <- ggplot(df, aes(x, y)) + geom_point() +
facet_grid(. ~ z, scales = "free")
d2 <- cdata(l2)[[1]]
expect_that(length(unique(d2$x)), equals(1))
expect_that(length(unique(d2$y)), equals(3))
-
- l3 <- ggplot(df, aes(x, y)) + geom_point() +
+
+ l3 <- ggplot(df, aes(x, y)) + geom_point() +
facet_grid(z ~ ., scales = "free")
d3 <- cdata(l3)[[1]]
expect_that(length(unique(d3$x)), equals(3))
@@ -44,10 +44,10 @@ test_that("facets with free scales scale independently", {
test_that("shrink parameter affects scaling", {
l1 <- ggplot(df, aes(1, y)) + geom_point()
r1 <- pranges(l1)
-
+
expect_that(r1$x[[1]], equals(c(1, 1)))
expect_that(r1$y[[1]], equals(c(1, 3)))
-
+
l2 <- ggplot(df, aes(1, y)) + stat_summary(fun.y = "mean")
r2 <- pranges(l2)
expect_that(r2$y[[1]], equals(c(2, 2)))
diff --git a/inst/tests/test-facet-layout.r b/inst/tests/test-facet-layout.r
index 32faf34..7613099 100644
--- a/inst/tests/test-facet-layout.r
+++ b/inst/tests/test-facet-layout.r
@@ -13,7 +13,7 @@ test_that("all: no rows and cols gives null layout", {
test_that("grid: single row and single col equivalent", {
row <- layout_grid(list(a), row = "a")
col <- layout_grid(list(a), col = "a")
-
+
expect_that(row$ROW, equals(1:2))
expect_that(row$ROW, equals(col$COL))
expect_that(row[c("PANEL", "a")], equals(col[c("PANEL", "a")]))
@@ -29,7 +29,7 @@ test_that("grid: single row and single col equivalent", {
test_that("grid: includes all combinations", {
d <- data.frame(a = c(1, 2), b = c(2, 1))
all <- layout_grid(list(d), row = "a", col = "b")
-
+
expect_that(nrow(all), equals(4))
})
@@ -37,7 +37,7 @@ test_that("wrap and grid equivalent for 1d data", {
rowg <- layout_grid(list(a), row = "a")
roww <- layout_wrap(list(a), "a", ncol = 1)
expect_that(roww, equals(rowg))
-
+
colg <- layout_grid(list(a), col = "a")
colw <- layout_wrap(list(a), "a", nrow = 1)
expect_that(colw, equals(colg))
@@ -49,13 +49,13 @@ test_that("grid: crossed rows/cols create no more combinations than necessary",
one_a <- layout_grid(list(a, empty), "a", "b")
expect_that(nrow(one_a), equals(4))
-
+
two <- layout_grid(list(a, b), "a", "b")
expect_that(nrow(two), equals(4 + 2))
-
+
three <- layout_grid(list(a, b, c), "a", "b")
expect_that(nrow(three), equals(9))
-
+
four <- layout_grid(list(b, c), "a", "b")
expect_that(nrow(four), equals(1))
})
@@ -74,19 +74,19 @@ test_that("grid: margins add correct combinations", {
test_that("wrap: as.table reverses rows", {
one <- layout_wrap(list(a), "a", ncol = 1, as.table = FALSE)
expect_that(one$ROW, equals(c(2, 1)))
-
+
two <- layout_wrap(list(a), "a", nrow = 1, as.table = FALSE)
expect_that(two$ROW, equals(c(1, 1)))
-
+
})
test_that("grid: as.table reverses rows", {
one <- layout_grid(list(a), "a", as.table = FALSE)
expect_that(as.character(one$a), equals(c("2", "1")))
-
+
two <- layout_grid(list(a), "a", as.table = TRUE)
expect_that(as.character(two$a), equals(c("1", "2")))
-
+
})
# Drop behaviour -------------------------------------------------------------
@@ -100,18 +100,18 @@ test_that("layout_wrap: drop = FALSE preserves unused levels", {
wrap_a <- layout_wrap(list(a2), "a", drop = FALSE)
expect_equal(nrow(wrap_a), 4)
expect_equal(as.character(wrap_a$a), as.character(1:4))
-
+
wrap_b <- layout_wrap(list(a2), "b", drop = FALSE)
expect_equal(nrow(wrap_b), 4)
expect_equal(as.character(wrap_b$b), as.character(4:1))
-
+
})
test_that("layout_grid: drop = FALSE preserves unused levels", {
grid_a <- layout_grid(list(a2), "a", drop = FALSE)
expect_equal(nrow(grid_a), 4)
expect_equal(as.character(grid_a$a), as.character(1:4))
-
+
grid_b <- layout_grid(list(a2), "b", drop = FALSE)
expect_equal(nrow(grid_b), 4)
expect_equal(as.character(grid_b$b), as.character(4:1))
@@ -120,7 +120,7 @@ test_that("layout_grid: drop = FALSE preserves unused levels", {
expect_equal(nrow(grid_ab), 16)
expect_equal(as.character(grid_ab$a), as.character(rep(1:4, each = 4)))
expect_equal(as.character(grid_ab$b), as.character(rep(4:1, 4)))
-
+
})
# Missing behaviour ----------------------------------------------------------
@@ -138,11 +138,11 @@ test_that("missing values get a panel", {
grid_a <- layout_grid(list(a3), "a")
grid_b <- layout_grid(list(a3), "b")
grid_c <- layout_grid(list(a3), "c")
-
+
expect_equal(nrow(wrap_a), 4)
expect_equal(nrow(wrap_b), 4)
expect_equal(nrow(wrap_c), 4)
expect_equal(nrow(grid_a), 4)
expect_equal(nrow(grid_b), 4)
expect_equal(nrow(grid_c), 4)
-})
\ No newline at end of file
+})
diff --git a/inst/tests/test-facet-locate.r b/inst/tests/test-facet-locate.r
index 4b3b4d8..ecf8789 100644
--- a/inst/tests/test-facet-locate.r
+++ b/inst/tests/test-facet-locate.r
@@ -1,4 +1,4 @@
-context("Facetting (location)")
+context("Facetting (location)")
df <- expand.grid(a = 1:2, b = 1:2)
df_a <- unique(df["a"])
@@ -8,35 +8,35 @@ df_c <- unique(data.frame(c = 1))
test_that("two col cases with no missings adds single extra column", {
vscyl <- layout_grid(list(mtcars), "cyl", "vs")
- loc <- locate_grid(mtcars, vscyl, "cyl", "vs")
-
+ loc <- locate_grid(mtcars, vscyl, "cyl", "vs")
+
expect_that(nrow(loc), equals(nrow(mtcars)))
expect_that(ncol(loc), equals(ncol(mtcars) + 1))
-
+
match <- unique(loc[c("cyl", "vs", "PANEL")])
expect_that(nrow(match), equals(5))
-
+
})
test_that("margins add extra data", {
panel <- layout_grid(list(df), "a", "b", margins = "b")
loc <- locate_grid(df, panel, "a", "b", margins = "b")
-
- expect_that(nrow(loc), equals(nrow(df) * 2))
+
+ expect_that(nrow(loc), equals(nrow(df) * 2))
})
-test_that("grid: missing facet columns are duplicated", {
+test_that("grid: missing facet columns are duplicated", {
panel <- layout_grid(list(df), "a", "b")
loc_a <- locate_grid(df_a, panel, "a", "b")
expect_that(nrow(loc_a), equals(4))
expect_that(loc_a$PANEL, equals(factor(1:4)))
-
+
loc_b <- locate_grid(df_b, panel, "a", "b")
expect_that(nrow(loc_b), equals(4))
expect_that(loc_b$PANEL, equals(factor(1:4)))
-
+
loc_c <- locate_grid(df_c, panel, "a", "b")
expect_that(nrow(loc_c), equals(4))
expect_that(loc_c$PANEL, equals(factor(1:4)))
@@ -49,11 +49,11 @@ test_that("wrap: missing facet columns are duplicated", {
expect_that(nrow(loc_a), equals(4))
expect_that(loc_a$PANEL, equals(factor(1:4)))
expect_that(loc_a$a, equals(c(1, 1, 2, 2)))
-
+
loc_b <- locate_wrap(df_b, panel, c("a", "b"))
expect_that(nrow(loc_b), equals(4))
expect_that(loc_b$PANEL, equals(factor(1:4)))
-
+
loc_c <- locate_wrap(df_c, panel, c("a", "b"))
expect_that(nrow(loc_c), equals(4))
expect_that(loc_c$PANEL, equals(factor(1:4)))
@@ -76,7 +76,7 @@ test_that("wrap: missing values located correctly", {
panel_c <- layout_wrap(list(a3), "c", ncol = 1)
loc_c <- locate_wrap(data.frame(c = NA), panel_c, "c")
expect_equal(as.character(loc_c$PANEL), "4")
-
+
})
test_that("grid: missing values located correctly", {
diff --git a/inst/tests/test-fortify.r b/inst/tests/test-fortify.r
index 8521229..efc4735 100644
--- a/inst/tests/test-fortify.r
+++ b/inst/tests/test-fortify.r
@@ -5,8 +5,8 @@ test_that("Spatial polygons have correct ordering", {
make_square <- function(x = 0, y = 0, height = 1, width = 1){
delx <- width/2
dely <- height/2
- Polygon(matrix(c(x + delx, x - delx,x - delx,x + delx,x + delx ,
- y - dely,y - dely,y + dely,y + dely,y - dely), ncol = 2))
+ Polygon(matrix(c(x + delx, x - delx,x - delx,x + delx,x + delx ,
+ y - dely,y - dely,y + dely,y + dely,y - dely), ncol = 2))
}
make_hole <- function(x = 0, y = 0, height = .5, width = .5){
@@ -17,7 +17,7 @@ test_that("Spatial polygons have correct ordering", {
fake_data <- data.frame(ids = 1:5, region = c(1,1,2,3,4))
rownames(fake_data) <- 1:5
- polys <- list(Polygons(list(make_square(), make_hole()), 1),
+ polys <- list(Polygons(list(make_square(), make_hole()), 1),
Polygons(list(make_square(1,0), make_square(2, 0)), 2),
Polygons(list(make_square(1,1)), 3),
Polygons(list(make_square(0,1)), 4),
diff --git a/inst/tests/test-layer.r b/inst/tests/test-layer.r
new file mode 100644
index 0000000..9e24f49
--- /dev/null
+++ b/inst/tests/test-layer.r
@@ -0,0 +1,18 @@
+context("Layer")
+
+test_that("Bare name surround by .. is calculated", {
+ expect_true(is_calculated_aes(aes(..density..)))
+ expect_true(is_calculated_aes(aes(..DENSITY..)))
+ expect_false(is_calculated_aes(aes(a..x..b)))
+})
+
+test_that("Calling using variable surround by .. is calculated", {
+ expect_true(is_calculated_aes(aes(mean(..density..))))
+ expect_true(is_calculated_aes(aes(mean(..DENSITY..))))
+ expect_false(is_calculated_aes(aes(x=mean(a..x..b))))
+})
+
+test_that("strip_dots remove dots around calculated aesthetics", {
+ expect_equal(strip_dots(aes(x=..density..))$x, quote(density))
+ expect_equal(strip_dots(aes(mean(..density..)))$x, quote(mean(density)))
+})
diff --git a/inst/tests/test-qplot.r b/inst/tests/test-qplot.r
index daf0b9b..732e1b1 100644
--- a/inst/tests/test-qplot.r
+++ b/inst/tests/test-qplot.r
@@ -8,7 +8,7 @@ test_that("qplot works with variables in data frame and parent env", {
expect_is(qplot(x, y, data = df), "ggplot")
expect_is(qplot(x, y, data = df, colour = a), "ggplot")
expect_is(qplot(x, y, data = df, colour = b), "ggplot")
-
+
bin <- 1
expect_is(qplot(x, data = df, binwidth = bin), "ggplot")
})
@@ -20,8 +20,8 @@ test_that("qplot works in non-standard environments", {
x <- 1:10
qplot(x, breaks = 0:`-1-`)
})
-
+
expect_is(eval(expr, env), "ggplot")
-
+
})
diff --git a/inst/tests/test-scale-manual.r b/inst/tests/test-scale-manual.r
index 97d20f1..45fcbe6 100644
--- a/inst/tests/test-scale-manual.r
+++ b/inst/tests/test-scale-manual.r
@@ -4,7 +4,7 @@ context("scale_manual")
test_that("names of values used in manual scales", {
s <- scale_colour_manual(values = c("8" = "c","4" = "a","6" = "b"))
scale_train(s, c("4", "6", "8"))
- expect_equal(scale_map(s, c("4", "6", "8")), c("a", "b", "c"))
+ expect_equal(scale_map(s, c("4", "6", "8")), c("a", "b", "c"))
})
@@ -15,9 +15,9 @@ col <- c("A" = "red", "B" = "green", "C" = "blue")
cols <- function(x) ggplot_build(x)$data[[1]][, "fill"]
test_that("named values work regardless of order", {
- fill_scale <- function(order) scale_fill_manual(values = col[order],
+ fill_scale <- function(order) scale_fill_manual(values = col[order],
na.value = "black")
-
+
# Order of value vector shouldn't matter
expect_equal(cols(p + fill_scale(1:3)), c("red", "green"))
expect_equal(cols(p + fill_scale(1:2)), c("red", "green"))
@@ -31,20 +31,20 @@ test_that("missing values replaced with na.value", {
df <- data.frame(x = 1, y = 1:3, z = factor(c(1:2, NA), exclude = NULL))
pdata <- ggplot_build(qplot(x, y, data = df, colour = z) +
scale_colour_manual(values = c("black", "black"), na.value = "red"))
-
- expect_equal(pdata$data[[1]]$colour, c("black", "black", "red"))
+
+ expect_equal(pdata$data[[1]]$colour, c("black", "black", "red"))
})
test_that("insufficient values raise an error", {
df <- data.frame(x = 1, y = 1:3, z = factor(c(1:2, NA), exclude = NULL))
- p <- qplot(x, y, data = df, colour = z)
-
+ p <- qplot(x, y, data = df, colour = z)
+
expect_error(ggplot_build(p + scale_colour_manual(values = "black")),
"Insufficient values")
# Should be sufficient
ggplot_build(p + scale_colour_manual(values = c("black", "black")))
-
+
})
test_that("values are matched when scale contains more unique valuesthan are in the data", {
diff --git a/inst/tests/test-scales-breaks-labels.r b/inst/tests/test-scales-breaks-labels.r
index cf820ec..845a5d0 100644
--- a/inst/tests/test-scales-breaks-labels.r
+++ b/inst/tests/test-scales-breaks-labels.r
@@ -2,7 +2,7 @@ context("Scales: breaks and labels")
test_that("labels match breaks, even when outside limits", {
sc <- scale_y_continuous(breaks=1:4, labels=1:4, limits = c(1, 3))
-
+
expect_equal(scale_breaks(sc), c(1:3, NA))
expect_equal(scale_labels(sc), 1:4)
expect_equal(scale_breaks_minor(sc), c(1, 1.5, 2, 2.5, 3))
@@ -21,10 +21,10 @@ test_that("labels don't have extra spaces", {
sc1 <- scale_x_discrete(limits = labels)
sc2 <- scale_fill_discrete(limits = labels)
-
+
expect_equal(scale_labels(sc1), labels)
expect_equal(scale_labels(sc2), labels)
-
+
})
@@ -85,10 +85,10 @@ test_that("out-of-range breaks are dropped", {
test_that("no minor breaks when only one break", {
sc1 <- scale_x_discrete(limits = "a")
sc2 <- scale_x_continuous(limits = 1)
-
+
expect_equal(length(scale_breaks_minor(sc1)), 0)
expect_equal(length(scale_breaks_minor(sc2)), 0)
-
+
})
init_scale <- function(...) {
@@ -99,7 +99,7 @@ init_scale <- function(...) {
}
test_that("discrete labels match breaks", {
-
+
sc <- init_scale(breaks = 0:5 * 10)
expect_equal(length(scale_breaks(sc)), 5)
expect_equal(length(scale_labels(sc)), 5)
@@ -110,15 +110,15 @@ test_that("discrete labels match breaks", {
expect_equal(length(scale_labels(sc)), 5)
expect_equal(scale_labels(sc), letters[2:6])
- sc <- init_scale(breaks = 0:5 * 10, labels =
+ sc <- init_scale(breaks = 0:5 * 10, labels =
function(x) paste(x, "-", sep = ""))
expect_equal(scale_labels(sc), c("10-", "20-", "30-", "40-", "50-"))
-
+
pick_5 <- function(x) sample(x, 5)
sc <- init_scale(breaks = pick_5)
expect_equal(length(scale_breaks(sc)), 5)
expect_equal(length(scale_labels(sc)), 5)
-
+
})
@@ -130,16 +130,16 @@ test_that("scale breaks with numeric log transformation", {
test_that("continuous scales with no data have no breaks or labels", {
sc <- scale_x_continuous()
-
+
expect_equal(scale_breaks(sc), numeric())
expect_equal(scale_labels(sc), character())
expect_equal(scale_limits(sc), c(0, 1))
-
+
})
test_that("discrete scales with no data have no breaks or labels", {
sc <- scale_x_discrete()
-
+
expect_equal(scale_breaks(sc), numeric())
expect_equal(scale_labels(sc), character())
expect_equal(scale_limits(sc), c(0, 1))
@@ -156,87 +156,73 @@ test_that("suppressing breaks, minor_breask, and labels", {
# date, datetime
lims <- as.Date(c("2000/1/1", "2000/2/1"))
expect_equal(scale_breaks(scale_x_date(breaks = NULL, limits = lims)), NULL)
- # NA is deprecated, should throw warning
- expect_warning(s <- scale_breaks(scale_x_date(breaks = NA, limits = lims)))
- expect_equal(s, NULL)
+ # NA is defunct, should throw error
+ expect_error(scale_breaks(scale_x_date(breaks = NA, limits = lims)))
expect_equal(scale_labels(scale_x_date(labels = NULL, limits = lims)), NULL)
- expect_warning(s <- scale_labels(scale_x_date(labels = NA, limits = lims)))
- expect_equal(s, NULL)
+ expect_error(scale_labels(scale_x_date(labels = NA, limits = lims)))
expect_equal(scale_breaks_minor(scale_x_date(minor_breaks= NULL, limits = lims)), NULL)
- expect_warning(s <-scale_breaks_minor(scale_x_date(minor_breaks= NA, limits = lims)))
- expect_equal(s, NULL)
+ expect_error(scale_breaks_minor(scale_x_date(minor_breaks = NA, limits = lims)))
# date, datetime
lims <- as.POSIXct(c("2000/1/1 0:0:0", "2010/1/1 0:0:0"))
expect_equal(scale_breaks(scale_x_datetime(breaks = NULL, limits = lims)), NULL)
- expect_warning(s <- scale_breaks(scale_x_datetime(breaks = NA, limits = lims)))
- expect_equal(s, NULL)
+ expect_error(scale_breaks(scale_x_datetime(breaks = NA, limits = lims)))
expect_equal(scale_labels(scale_x_datetime(labels = NULL, limits = lims)), NULL)
- expect_warning(s <- scale_labels(scale_x_datetime(labels = NA, limits = lims)))
- expect_equal(s, NULL)
+ expect_error(scale_labels(scale_x_datetime(labels = NA, limits = lims)))
expect_equal(scale_breaks_minor(scale_x_datetime(minor_breaks= NULL, limits = lims)), NULL)
- expect_warning(s <- scale_breaks_minor(scale_x_datetime(minor_breaks= NA, limits = lims)))
- expect_equal(s, NULL)
+ expect_error(scale_breaks_minor(scale_x_datetime(minor_breaks= NA, limits = lims)))
})
test_that("scale_breaks with explicit NA options (deprecated)", {
- # NA is deprecated, should throw warning
-
+ # NA is defunct, should throw error
+
# X
sxc <- scale_x_continuous(breaks=NA)
scale_train(sxc, 1:3)
- expect_warning(s <- scale_breaks(sxc))
- expect_identical(s, NULL)
- expect_warning(s <- scale_breaks_minor(sxc))
- expect_identical(s, NULL)
-
+ expect_error(scale_breaks(sxc))
+ expect_error(scale_breaks_minor(sxc))
+
# Y
syc <- scale_y_continuous(breaks=NA)
scale_train(syc, 1:3)
- expect_warning(s <- scale_breaks(syc))
- expect_identical(s, NULL)
- expect_warning(s <- scale_breaks_minor(syc))
- expect_identical(s, NULL)
-
+ expect_error(scale_breaks(syc))
+ expect_error(scale_breaks_minor(syc))
+
# Alpha
sac <- scale_alpha_continuous(breaks=NA)
scale_train(sac,1:3)
- expect_warning(s <- scale_breaks(sac))
- expect_identical(s, NULL)
-
+ expect_error(scale_breaks(sac))
+
# Size
ssc <- scale_size_continuous(breaks=NA)
scale_train(ssc,1:3)
- expect_warning(s <- scale_breaks(ssc))
- expect_identical(s, NULL)
-
+ expect_error(scale_breaks(ssc))
+
# Fill
sfc <- scale_fill_continuous(breaks=NA)
scale_train(sfc,1:3)
- expect_warning(s <- scale_breaks(sfc))
- expect_identical(s, NULL)
-
+ expect_error(scale_breaks(sfc))
+
# Colour
scc <- scale_colour_continuous(breaks=NA)
scale_train(scc,1:3)
- expect_warning(s <- scale_breaks(scc))
- expect_identical(s, NULL)
-
+ expect_error(scale_breaks(scc))
+
})
test_that("breaks can be specified by names of labels", {
labels <- setNames(LETTERS[1:4], letters[1:4])
-
+
s <- scale_x_discrete(limits = letters[1:4], labels = labels)
expect_equal(as.vector(scale_breaks(s)), letters[1:4])
expect_equal(as.vector(scale_labels(s)), LETTERS[1:4])
-
+
s <- scale_x_discrete(limits = letters[1:4], labels = rev(labels))
expect_equal(as.vector(scale_breaks(s)), letters[1:4])
expect_equal(as.vector(scale_labels(s)), LETTERS[1:4])
-
+
s <- scale_x_discrete(limits = letters[1:4], labels = labels[1:2])
expect_equal(as.vector(scale_breaks(s)), letters[1:4])
expect_equal(as.vector(scale_labels(s)), c("A", "B", "c", "d"))
diff --git a/inst/tests/test-scales.r b/inst/tests/test-scales.r
index b048f0b..fece760 100644
--- a/inst/tests/test-scales.r
+++ b/inst/tests/test-scales.r
@@ -5,9 +5,9 @@ test_that("buidling a plot does not affect its scales", {
p <- ggplot(dat, aes(x, y)) + geom_point()
expect_equal(length(p$scales$scales), 0)
-
+
ggplot_build(p)
- expect_equal(length(p$scales$scales), 0)
+ expect_equal(length(p$scales$scales), 0)
})
test_that("ranges update only for variables listed in aesthetics", {
@@ -15,28 +15,28 @@ test_that("ranges update only for variables listed in aesthetics", {
scale_train_df(sc, data.frame(alpha = 1:10))
expect_equal(sc$range$range, c(1, 10))
-
+
scale_train_df(sc, data.frame(alpha = 50))
expect_equal(sc$range$range, c(1, 50))
-
+
scale_train_df(sc, data.frame(beta = 100))
expect_equal(sc$range$range, c(1, 50))
-
+
scale_train_df(sc, data.frame())
expect_equal(sc$range$range, c(1, 50))
-
+
})
test_that("mapping works", {
sc <- scale_alpha(range = c(0, 1), na.value = 0)
scale_train_df(sc, data.frame(alpha = 1:10))
-
+
expect_equal(
- scale_map_df(sc, data.frame(alpha = 1:10))[[1]],
+ scale_map_df(sc, data.frame(alpha = 1:10))[[1]],
round_any(seq(0, 1, length = 10), 1 / 500))
-
+
expect_equal(scale_map_df(sc, data.frame(alpha = NA))[[1]], 0)
-
+
expect_equal(
scale_map_df(sc, data.frame(alpha = c(-10, 11)))[[1]],
c(0, 0))
@@ -44,14 +44,14 @@ test_that("mapping works", {
test_that("identity scale preserves input values", {
df <- data.frame(x = 1:3, z = letters[1:3])
-
- p1 <- ggplot(df,
+
+ p1 <- ggplot(df,
aes(x, z, colour = z, fill = z, shape = z, size = x, alpha = x)) +
geom_point() +
scale_colour_identity() +
- scale_fill_identity() +
- scale_shape_identity() +
- scale_size_identity() +
+ scale_fill_identity() +
+ scale_shape_identity() +
+ scale_size_identity() +
scale_alpha_identity()
d1 <- pdata(p1)[[1]]
@@ -60,44 +60,44 @@ test_that("identity scale preserves input values", {
expect_that(d1$shape, equals(as.character(df$z)))
expect_that(d1$size, equals(as.numeric(df$z)))
expect_that(d1$alpha, equals(as.numeric(df$z)))
-
-
+
+
})
test_that("position scales updated by all position aesthetics", {
df <- data.frame(x = 1:3, y = 1:3)
-
+
aesthetics <- list(
aes(xend = x, yend = x),
aes(xmin = x, ymin = x),
aes(xmax = x, ymax = x),
aes(xintercept = x, yintercept = y)
)
-
+
base <- ggplot(df, aes(x = 1, y = 1)) + geom_point()
plots <- lapply(aesthetics, function(x) base %+% x)
ranges <- lapply(plots, pranges)
-
+
lapply(ranges, function(range) {
expect_that(range$x[[1]], equals(c(1, 3)))
expect_that(range$y[[1]], equals(c(1, 3)))
})
-
+
})
test_that("position scales generate after stats", {
df <- data.frame(x = factor(c(1, 1, 1)))
plot <- ggplot(df, aes(x)) + geom_bar()
ranges <- pranges(plot)
-
+
expect_that(ranges$x[[1]], equals(c("1")))
expect_that(ranges$y[[1]], equals(c(0, 3)))
-
+
})
test_that("oob affects position values", {
dat <- data.frame(x=c("a", "b", "c"), y=c(1, 5, 10))
- base <- ggplot(dat, aes(x=x, y=y)) +
+ base <- ggplot(dat, aes(x=x, y=y)) +
geom_bar(stat="identity") +
annotate("point", x = "a", y = c(-Inf, Inf))
@@ -113,20 +113,20 @@ test_that("oob affects position values", {
low_squish <- cdata(base + y_scale(c(0, 5), squish))
mid_squish <- cdata(base + y_scale(c(3, 7), squish))
-
+
# Points are always at the top and bottom
expect_equal(low_censor[[2]]$y, c(0, 1))
expect_equal(mid_censor[[2]]$y, c(0, 1))
expect_equal(low_squish[[2]]$y, c(0, 1))
expect_equal(mid_squish[[2]]$y, c(0, 1))
-
+
# Bars depend on limits and oob
expect_equal(low_censor[[1]]$y, c(0.2, 1))
expect_equal(mid_censor[[1]]$y, c(0.5))
expect_equal(low_squish[[1]]$y, c(0.2, 1, 1))
expect_equal(mid_squish[[1]]$y, c(0, 0.5, 1))
-
-
+
+
})
test_that("scales looked for in appropriate place", {
diff --git a/inst/tests/test-stats.r b/inst/tests/test-stats.r
index 7d9f8ef..faa0197 100644
--- a/inst/tests/test-stats.r
+++ b/inst/tests/test-stats.r
@@ -1,17 +1,17 @@
context("Stats")
test_that("plot succeeds even if some computation fails", {
- p1 <- ggplot(mtcars, aes(disp, mpg)) +
- geom_point() +
+ p1 <- ggplot(mtcars, aes(disp, mpg)) +
+ geom_point() +
facet_grid(gear ~ carb)
p2 <- p1 + geom_smooth()
-
+
b1 <- ggplot_build(p1)
expect_equal(length(b1$data), 1)
-
+
expect_warning(b2 <- ggplot_build(p2))
expect_equal(length(b2$data), 2)
-
+
})
@@ -28,20 +28,21 @@ context("stat-bin")
test_that("stat_sum", {
dat <- data.frame(x = c("a", "b", "c"), y = c(1, 5, 10))
- # Should get a message when mapping/setting y and also using stat_bin
- expect_message(p <- ggplot_build(ggplot(dat, aes(x=x, y=y)) + geom_bar()),
- "Mapping a variable to y and also using stat=\"bin\"")
- expect_message(p <- ggplot_build(ggplot(dat, aes(x=x, y=y)) + geom_bar(stat="bin")),
- "Mapping a variable to y and also using stat=\"bin\"")
-
- expect_message(p <- ggplot_build(ggplot(dat, aes(x=x)) + geom_bar(y=5)),
- "Mapping a variable to y and also using stat=\"bin\"")
-
- # This gives an error and a message (it would probably be OK if just one
+ # Should get an error when mapping/setting y and also using stat_bin
+ # But errors caught by internal tryCatch :()
+# expect_error(ggplot_build(ggplot(dat, aes(x=x, y=y)) + geom_bar()),
+# "Mapping a variable to y and also using stat=\"bin\"")
+# expect_error(p <- ggplot_build(ggplot(dat, aes(x=x, y=y)) + geom_bar(stat="bin")),
+# "Mapping a variable to y and also using stat=\"bin\"")
+#
+# expect_error(p <- ggplot_build(ggplot(dat, aes(x=x)) + geom_bar(y=5)),
+# "Mapping a variable to y and also using stat=\"bin\"")
+
+ # This gives an error (it would probably be OK if just one
# of these happened, but this test looks for both)
dat2 <- data.frame(x = c("a", "b", "c", "a", "b", "c"), y = c(1, 5, 10, 2, 3, 4))
- expect_message(expect_error(
- p <- ggplot_build(ggplot(dat2, aes(x=x, y=y)) + geom_bar())))
+# expect_error(
+# p <- ggplot_build(ggplot(dat2, aes(x=x, y=y)) + geom_bar()))
})
@@ -49,39 +50,40 @@ context("stat-sum")
test_that("stat_sum", {
d <- diamonds[1:1000, ]
+ all_ones <- function(x) all.equal(mean(x), 1)
ret <- test_stat(stat_sum(aes(x = cut, y = clarity), data = d))
expect_equal(dim(ret), c(38, 5))
expect_equal(sum(ret$n), nrow(d))
- expect_true(all(ret$prop == 1))
-
+ expect_true(all_ones(ret$prop))
+
ret <- test_stat(stat_sum(aes(x = cut, y = clarity, group = 1), data = d))
expect_equal(dim(ret), c(38, 5))
expect_equal(sum(ret$n), nrow(d))
expect_equal(sum(ret$prop), 1)
-
+
ret <- test_stat(stat_sum(aes(x = cut, y = clarity, group = cut), data = d))
expect_equal(dim(ret), c(38, 5))
expect_equal(sum(ret$n), nrow(d))
- expect_true(all(ddply(ret, .(x), summarise, prop = sum(prop))$prop == 1))
+ expect_true(all_ones(tapply(ret$prop, ret$x, FUN = sum)))
ret <- test_stat(stat_sum(aes(x = cut, y = clarity, group = cut, colour = cut), data = d))
expect_equal(dim(ret), c(38, 6))
expect_equal(ret$x, ret$colour)
expect_equal(sum(ret$n), nrow(d))
- expect_true(all(ddply(ret, .(x), summarise, prop = sum(prop))$prop == 1))
-
+ expect_true(all_ones(tapply(ret$prop, ret$x, FUN = sum)))
+
ret <- test_stat(stat_sum(aes(x = cut, y = clarity, group = clarity), data = d))
expect_equal(dim(ret), c(38, 5))
expect_equal(sum(ret$n), nrow(d))
- expect_true(all(ddply(ret, .(y), summarise, prop = sum(prop))$prop == 1))
+ expect_true(all_ones(tapply(ret$prop, ret$y, FUN = sum)))
ret <- test_stat(stat_sum(aes(x = cut, y = clarity, group = clarity, colour = cut), data = d))
expect_equal(dim(ret), c(38, 6))
expect_equal(ret$x, ret$colour)
expect_equal(sum(ret$n), nrow(d))
- expect_true(all(ddply(ret, .(y), summarise, prop = sum(prop))$prop == 1))
-
+ expect_true(all_ones(tapply(ret$prop, ret$y, FUN = sum)))
+
ret <- test_stat(stat_sum(aes(x = cut, y = clarity, group = 1, weight = price), data = d))
expect_equal(dim(ret), c(38, 5))
expect_equal(sum(ret$n), sum(d$price))
diff --git a/man/absoluteGrob.Rd b/man/absoluteGrob.Rd
index f081277..35db6a3 100644
--- a/man/absoluteGrob.Rd
+++ b/man/absoluteGrob.Rd
@@ -1,15 +1,16 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{absoluteGrob}
\alias{absoluteGrob}
\title{Absolute grob}
\usage{
- absoluteGrob(grob, width = NULL, height = NULL,
- xmin = NULL, ymin = NULL, vp = NULL)
+absoluteGrob(grob, width = NULL, height = NULL, xmin = NULL,
+ ymin = NULL, vp = NULL)
}
\description{
- This grob has fixed dimesions and position.
+This grob has fixed dimesions and position.
}
\details{
- It's still experimental
+It's still experimental
}
\keyword{internal}
diff --git a/man/add_theme.Rd b/man/add_theme.Rd
index 992f325..0f8e432 100644
--- a/man/add_theme.Rd
+++ b/man/add_theme.Rd
@@ -1,22 +1,22 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{add_theme}
\alias{add_theme}
\title{Modify properties of an element in a theme object}
\usage{
- add_theme(t1, t2, t2name)
+add_theme(t1, t2, t2name)
}
\arguments{
- \item{t1}{A theme object}
+\item{t1}{A theme object}
- \item{t2}{A theme object that is to be added to
- \code{t1}}
+\item{t2}{A theme object that is to be added to \code{t1}}
- \item{t2name}{A name of the t2 object. This is used for
- printing informative error messages.}
+\item{t2name}{A name of the t2 object. This is used for printing
+ informative error messages.}
}
\description{
- Modify properties of an element in a theme object
+Modify properties of an element in a theme object
}
\seealso{
- +.gg
++.gg
}
diff --git a/man/aes.Rd b/man/aes.Rd
index 4fd77a1..0f9c73d 100644
--- a/man/aes.Rd
+++ b/man/aes.Rd
@@ -1,34 +1,30 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{aes}
\alias{aes}
\title{Generate aesthetic mappings that describe how variables in the data are
mapped to visual properties (aesthetics) of geoms.}
\usage{
- aes(x, y, ...)
+aes(x, y, ...)
}
\arguments{
- \item{x}{x value}
-
- \item{y}{y value}
-
- \item{...}{List of name value pairs giving aesthetics to
- map.}
+\item{x,y,...}{List of name value pairs giving aesthetics to map.}
}
\description{
- \code{aes} creates a list of unevaluated expressions.
- This function also performs partial name matching,
- converts color to colour, and old style R names to ggplot
- names (eg. pch to shape, cex to size)
+\code{aes} creates a list of unevaluated expressions. This function also
+performs partial name matching, converts color to colour, and old style R
+names to ggplot names (eg. pch to shape, cex to size)
}
\examples{
aes(x = mpg, y = wt)
aes(x = mpg ^ 2, y = wt / cyl)
}
\seealso{
- \code{\link{aes_string}} for passing quoted variable
- names. \code{\link{aes_colour_fill_alpha}},
- \code{\link{aes_group_order}},
- \code{\link{aes_linetype_size_shape}} and
- \code{\link{aes_position}} for more specific examples
- with different aesthetics.
+See
+ \code{\link{aes_colour_fill_alpha}}, \code{\link{aes_group_order}},
+ \code{\link{aes_linetype_size_shape}} and \code{\link{aes_position}}
+ for more specific examples with different aesthetics.
+
+Other aesthetic generators: \code{\link{aes_q}},
+ \code{\link{aes_string}}
}
diff --git a/man/aes_all.Rd b/man/aes_all.Rd
index 59dc08b..08c04e0 100644
--- a/man/aes_all.Rd
+++ b/man/aes_all.Rd
@@ -1,15 +1,15 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{aes_all}
\alias{aes_all}
\title{Given a character vector, create a set of identity mappings}
\usage{
- aes_all(vars)
+aes_all(vars)
}
\arguments{
- \item{vars}{vector of variable names}
+\item{vars}{vector of variable names}
}
\description{
- Given a character vector, create a set of identity
- mappings
+Given a character vector, create a set of identity mappings
}
\examples{
aes_all(names(mtcars))
diff --git a/man/aes_auto.Rd b/man/aes_auto.Rd
index 902fc11..a97b470 100644
--- a/man/aes_auto.Rd
+++ b/man/aes_auto.Rd
@@ -1,16 +1,17 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{aes_auto}
\alias{aes_auto}
\title{Automatic aesthetic mapping}
\usage{
- aes_auto(data = NULL, ...)
+aes_auto(data = NULL, ...)
}
\arguments{
- \item{data}{data.frame or names of variables}
+\item{data}{data.frame or names of variables}
- \item{...}{aesthetics that need to be explicitly mapped.}
+\item{...}{aesthetics that need to be explicitly mapped.}
}
\description{
- Automatic aesthetic mapping
+Automatic aesthetic mapping
}
\examples{
df <- data.frame(x = 1, y = 1, colour = 1, label = 1, pch = 1)
diff --git a/man/aes_colour_fill_alpha.Rd b/man/aes_colour_fill_alpha.Rd
index 4b4a187..8aefa0e 100644
--- a/man/aes_colour_fill_alpha.Rd
+++ b/man/aes_colour_fill_alpha.Rd
@@ -1,3 +1,4 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{aes_colour_fill_alpha}
\alias{aes_colour_fill_alpha}
\alias{alpha}
@@ -6,8 +7,8 @@
\alias{fill}
\title{Colour related aesthetics: colour, fill and alpha}
\description{
- This page demonstrates the usage of a sub-group of
- aesthetics; colour, fill and alpha.
+This page demonstrates the usage of a sub-group
+of aesthetics; colour, fill and alpha.
}
\examples{
\donttest{
diff --git a/man/aes_group_order.Rd b/man/aes_group_order.Rd
index 38b38ae..ea32b0a 100644
--- a/man/aes_group_order.Rd
+++ b/man/aes_group_order.Rd
@@ -1,10 +1,11 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{aes_group_order}
\alias{aes_group_order}
\alias{group}
\alias{order}
\title{Aesthetics: group, order}
\description{
- Aesthetics: group, order
+Aesthetics: group, order
}
\examples{
\donttest{
diff --git a/man/aes_linetype_size_shape.Rd b/man/aes_linetype_size_shape.Rd
index f29af0f..0f8c8a8 100644
--- a/man/aes_linetype_size_shape.Rd
+++ b/man/aes_linetype_size_shape.Rd
@@ -1,3 +1,4 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{aes_linetype_size_shape}
\alias{aes_linetype_size_shape}
\alias{linetype}
@@ -5,8 +6,8 @@
\alias{size}
\title{Differentiation related aesthetics: linetype, size, shape}
\description{
- This page demonstrates the usage of a sub-group of
- aesthetics; linetype, size and shape.
+This page demonstrates the usage of a sub-group
+of aesthetics; linetype, size and shape.
}
\examples{
# Line types should be specified with either an integer, a name, or with a string of
diff --git a/man/aes_position.Rd b/man/aes_position.Rd
index 064d4d2..8823898 100644
--- a/man/aes_position.Rd
+++ b/man/aes_position.Rd
@@ -1,3 +1,4 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{aes_position}
\alias{aes_position}
\alias{x}
@@ -10,8 +11,8 @@
\alias{ymin}
\title{Position related aesthetics: x, y, xmin, xmax, ymin, ymax, xend, yend}
\description{
- This page demonstrates the usage of a sub-group of
- aesthetics; x, y, xmin, xmax, ymin, ymax, xend, and yend.
+This page demonstrates the usage of a sub-group
+of aesthetics; x, y, xmin, xmax, ymin, ymax, xend, and yend.
}
\examples{
# Generate data: means and standard errors of means for prices
@@ -27,24 +28,30 @@ se + geom_pointrange()
# generate sample data
library(plyr)
abc <- adply(matrix(rnorm(100), ncol = 5), 2, quantile, c(0, .25, .5, .75, 1))
-b <- ggplot(abc, aes(x = X1, ymin = "0\%", lower = "25\%", middle = "50\%", upper = "75\%", ymax = "100\%"))
+b <- ggplot(abc, aes(x = X1, ymin = "0\%", lower = "25\%",
+ middle = "50\%", upper = "75\%", ymax = "100\%"))
b + geom_boxplot(stat = "identity")
# Using annotate
p <- ggplot(mtcars, aes(wt, mpg)) + geom_point()
-p + annotate("rect", xmin = 2, xmax = 3.5, ymin = 2, ymax = 25, fill = "dark grey", alpha = .5)
+p + annotate("rect", xmin = 2, xmax = 3.5, ymin = 2, ymax = 25,
+ fill = "dark grey", alpha = .5)
# Geom_segment examples
library(grid)
-p + geom_segment(aes(x = 2, y = 15, xend = 2, yend = 25), arrow = arrow(length = unit(0.5, "cm")))
-p + geom_segment(aes(x = 2, y = 15, xend = 3, yend = 15), arrow = arrow(length = unit(0.5, "cm")))
-p + geom_segment(aes(x = 5, y = 30, xend = 3.5, yend = 25), arrow = arrow(length = unit(0.5, "cm")))
+p + geom_segment(aes(x = 2, y = 15, xend = 2, yend = 25),
+ arrow = arrow(length = unit(0.5, "cm")))
+p + geom_segment(aes(x = 2, y = 15, xend = 3, yend = 15),
+ arrow = arrow(length = unit(0.5, "cm")))
+p + geom_segment(aes(x = 5, y = 30, xend = 3.5, yend = 25),
+ arrow = arrow(length = unit(0.5, "cm")))
# You can also use geom_segment to recreate plot(type = "h") :
counts <- as.data.frame(table(x = rpois(100, 5)))
counts$x <- as.numeric(as.character(counts$x))
with(counts, plot(x, Freq, type = "h", lwd = 10))
-qplot(x, Freq, data = counts, geom = "segment", yend = 0, xend = x, size = I(10))
+qplot(x, Freq, data = counts, geom = "segment", yend = 0, xend = x,
+ size = I(10))
}
diff --git a/man/aes_string.Rd b/man/aes_string.Rd
index a2a3911..665dac7 100644
--- a/man/aes_string.Rd
+++ b/man/aes_string.Rd
@@ -1,29 +1,41 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{aes_string}
+\alias{aes_q}
\alias{aes_string}
-\title{Generate aesthetic mappings from a string}
+\title{Generate aesthetic mappings from a string/quoted objects}
\usage{
- aes_string(...)
+aes_string(x = NULL, y = NULL, ...)
+
+aes_q(x = NULL, y = NULL, ...)
}
\arguments{
- \item{...}{List of name value pairs}
+\item{x,y,...}{List of name value pairs}
}
\description{
- Aesthetic mappings describe how variables in the data are
- mapped to visual properties (aesthetics) of geoms.
- Compared to aes this function operates on strings rather
- than expressions.
+Aesthetic mappings describe how variables in the data are mapped to visual
+properties (aesthetics) of geoms. \code{\link{aes}} uses non-standard
+evaluation to capture the variable names. These two variants use
+regular evaluation, which is easier to use inside functions.
}
\details{
- \code{aes_string} is particularly useful when writing
- functions that create plots because you can use strings
- to define the aesthetic mappings, rather than having to
- mess around with expressions.
+\code{aes_string} and \code{aes_q} are particularly useful when writing
+functions that create plots because you can use strings or quoted
+names/calls to define the aesthetic mappings, rather than having to use
+\code{\link{substitute}} to generate a call to \code{aes()}.
}
\examples{
-aes_string(x = "mpg", y = "wt")
-aes(x = mpg, y = wt)
+# Threee ways of generating the same aesthetics
+aes(mpg, wt, col = cyl, fill = NULL)
+aes_string("mpg", "wt", col = "cyl", fill = NULL)
+aes_q(quote(mpg), quote(wt), col = quote(cyl), fill = NULL)
+
+aes(col = cyl, fill = NULL)
+aes_string(col = "cyl", fill = NULL)
+aes_q(col = quote(cyl), fill = NULL)
}
\seealso{
- \code{\link{aes}}
+\code{\link{aes}}
+
+Other aesthetic generators: \code{\link{aes}}
}
diff --git a/man/annotate.Rd b/man/annotate.Rd
index 23d858a..aa5db80 100644
--- a/man/annotate.Rd
+++ b/man/annotate.Rd
@@ -1,32 +1,32 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{annotate}
\alias{annotate}
\title{Create an annotation layer.}
\usage{
- annotate(geom, x = NULL, y = NULL, xmin = NULL,
- xmax = NULL, ymin = NULL, ymax = NULL, ...)
+annotate(geom, x = NULL, y = NULL, xmin = NULL, xmax = NULL,
+ ymin = NULL, ymax = NULL, ...)
}
\arguments{
- \item{geom}{name of geom to use for annotation}
+\item{geom}{name of geom to use for annotation}
- \item{x,y,xmin,ymin,xmax,ymax}{positionining aesthetics -
- you must specify at least one of these.}
+\item{x,y,xmin,ymin,xmax,ymax}{positionining aesthetics - you must
+specify at least one of these.}
- \item{...}{other aesthetics. These are not scaled so you
- can do (e.g.) \code{colour = "red"} to get a red point.}
+\item{...}{other aesthetics. These are not scaled so you can do (e.g.)
+\code{colour = "red"} to get a red point.}
}
\description{
- This function adds geoms to a plot. Unlike typical a geom
- function, the properties of the geoms are not mapped from
- variables of a data frame, but are instead in as vectors.
- This is useful for adding small annotations (such as text
- labels) or if you have your data in vectors, and for some
- reason don't want to put them in a data frame.
+This function adds geoms to a plot. Unlike typical a geom function,
+the properties of the geoms are not mapped from variables of a data frame,
+but are instead in as vectors. This is useful for adding small annotations
+(such as text labels) or if you have your data in vectors, and for some
+reason don't want to put them in a data frame.
}
\details{
- Note that all position aesthetics are scaled (i.e. they
- will expand the limits of the plot so they are visible),
- but all other aesthetics are set. This means that layers
- created with this function will never affect the legend.
+Note that all position aesthetics are scaled (i.e. they will expand the
+limits of the plot so they are visible), but all other aesthetics are
+set. This means that layers created with this function will never
+affect the legend.
}
\examples{
p <- ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point()
diff --git a/man/annotation_custom.Rd b/man/annotation_custom.Rd
index 302eb22..b346893 100644
--- a/man/annotation_custom.Rd
+++ b/man/annotation_custom.Rd
@@ -1,50 +1,46 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{annotation_custom}
\alias{annotation_custom}
\title{Annotation: Custom grob.}
\usage{
- annotation_custom(grob, xmin = -Inf, xmax = Inf,
- ymin = -Inf, ymax = Inf)
+annotation_custom(grob, xmin = -Inf, xmax = Inf, ymin = -Inf,
+ ymax = Inf)
}
\arguments{
- \item{grob}{grob to display}
+\item{grob}{grob to display}
- \item{xmin,xmax}{x location (in data coordinates) giving
- horizontal location of raster}
+\item{xmin,xmax}{x location (in data coordinates) giving horizontal
+location of raster}
- \item{ymin,ymax}{y location (in data coordinates) giving
- vertical location of raster}
+\item{ymin,ymax}{y location (in data coordinates) giving vertical
+location of raster}
}
\description{
- This is a special geom intended for use as static
- annnotations that are the same in every panel. These
- anotations will not affect scales (i.e. the x and y axes
- will not grow to cover the range of the grob, and the
- grob will not be modified by any ggplot settings or
- mappings).
+This is a special geom intended for use as static annnotations
+that are the same in every panel. These anotations will not
+affect scales (i.e. the x and y axes will not grow to cover the range
+of the grob, and the grob will not be modified by any ggplot settings or mappings).
}
\details{
- Most useful for adding tables, inset plots, and other
- grid-based decorations.
+Most useful for adding tables, inset plots, and other grid-based decorations.
}
\note{
- \code{annotation_custom} expects the grob to fill the
- entire viewport defined by xmin, xmax, ymin, ymax. Grobs
- with a different (absolute) size will be center-justified
- in that region. Inf values can be used to fill the full
- plot panel (see examples).
+\code{annotation_custom} expects the grob to fill the entire viewport
+defined by xmin, xmax, ymin, ymax. Grobs with a different (absolute) size
+will be center-justified in that region.
+Inf values can be used to fill the full plot panel (see examples).
}
\examples{
# Dummy plot
base <- qplot(1:10, 1:10, geom = "blank") + theme_bw()
# Adding a table
-\donttest{
-require(gridExtra)
+\donttest{if (require(gridExtra)) {
base + annotation_custom(grob = tableGrob(head(iris[ ,1:3])),
xmin = 3, xmax = 6, ymin = 2, ymax = 8)
# full panel
base + annotation_custom(grob = roundrectGrob(),
xmin = -Inf, xmax = Inf, ymin = -Inf, ymax = Inf)
-}
+}}
# Inset plot
g <- ggplotGrob(qplot(1, 1) +
theme(plot.background = element_rect(colour = "black")))
diff --git a/man/annotation_logticks.Rd b/man/annotation_logticks.Rd
index 9ccc4af..f120e5e 100644
--- a/man/annotation_logticks.Rd
+++ b/man/annotation_logticks.Rd
@@ -1,55 +1,48 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{annotation_logticks}
\alias{annotation_logticks}
\title{Annotation: log tick marks}
\usage{
- annotation_logticks(base = 10, sides = "bl",
- scaled = TRUE, short = unit(0.1, "cm"),
- mid = unit(0.2, "cm"), long = unit(0.3, "cm"),
- colour = "black", size = 0.5, linetype = 1, alpha = 1,
- color = NULL, ...)
+annotation_logticks(base = 10, sides = "bl", scaled = TRUE,
+ short = unit(0.1, "cm"), mid = unit(0.2, "cm"), long = unit(0.3, "cm"),
+ colour = "black", size = 0.5, linetype = 1, alpha = 1, color = NULL,
+ ...)
}
\arguments{
- \item{base}{the base of the log (default 10)}
+\item{base}{the base of the log (default 10)}
- \item{sides}{a string that controls which sides of the
- plot the log ticks appear on. It can be set to a string
- containing any of \code{"trbl"}, for top, right, bottom,
- and left.}
+\item{sides}{a string that controls which sides of the plot the log ticks appear on.
+It can be set to a string containing any of \code{"trbl"}, for top, right,
+bottom, and left.}
- \item{short}{a \code{unit} object specifying the length
- of the short tick marks}
+\item{short}{a \code{unit} object specifying the length of the short tick marks}
- \item{mid}{a \code{unit} object specifying the length of
- the middle tick marks. In base 10, these are the "5"
- ticks.}
+\item{mid}{a \code{unit} object specifying the length of the middle tick marks.
+In base 10, these are the "5" ticks.}
- \item{long}{a \code{unit} object specifying the length of
- the long tick marks. In base 10, these are the "1" (or
- "10") ticks.}
+\item{long}{a \code{unit} object specifying the length of the long tick marks.
+In base 10, these are the "1" (or "10") ticks.}
- \item{scaled}{is the data already log-scaled? This should
- be \code{TRUE} (default) when the data is already
- transformed with \code{log10()} or when using
- \code{scale_y_log10}. It should be \code{FALSE} when
- using \code{coord_trans(y = "log10")}.}
+\item{scaled}{is the data already log-scaled? This should be \code{TRUE}
+(default) when the data is already transformed with \code{log10()} or when
+using \code{scale_y_log10}. It should be \code{FALSE} when using
+\code{coord_trans(y = "log10")}.}
- \item{colour}{Colour of the tick marks.}
+\item{colour}{Colour of the tick marks.}
- \item{size}{Thickness of tick marks, in mm.}
+\item{size}{Thickness of tick marks, in mm.}
- \item{linetype}{Linetype of tick marks (\code{solid},
- \code{dashed}, etc.)}
+\item{linetype}{Linetype of tick marks (\code{solid}, \code{dashed}, etc.)}
- \item{alpha}{The transparency of the tick marks.}
+\item{alpha}{The transparency of the tick marks.}
- \item{color}{An alias for \code{colour}.}
+\item{color}{An alias for \code{colour}.}
- \item{...}{Other parameters passed on to the layer}
+\item{...}{Other parameters passed on to the layer}
}
\description{
- This annotation adds log tick marks with diminishing
- spacing. These tick marks probably make sense only for
- base 10.
+This annotation adds log tick marks with diminishing spacing.
+These tick marks probably make sense only for base 10.
}
\examples{
# Make a log-log plot (without log ticks)
@@ -98,11 +91,9 @@ library(grid)
a + annotation_logticks(short = unit(.5,"mm"), mid = unit(3,"mm"), long = unit(4,"mm"))
}
\seealso{
- \code{\link{scale_y_continuous}},
- \code{\link{scale_y_log10}} for log scale
+\code{\link{scale_y_continuous}}, \code{\link{scale_y_log10}} for log scale
transformations.
- \code{\link{coord_trans}} for log coordinate
- transformations.
+\code{\link{coord_trans}} for log coordinate transformations.
}
diff --git a/man/annotation_map.Rd b/man/annotation_map.Rd
index 228ca32..0802aea 100644
--- a/man/annotation_map.Rd
+++ b/man/annotation_map.Rd
@@ -1,18 +1,18 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{annotation_map}
\alias{annotation_map}
\title{Annotation: maps.}
\usage{
- annotation_map(map, ...)
+annotation_map(map, ...)
}
\arguments{
- \item{map}{data frame representing a map. Most map
- objects can be converted into the right format by using
- \code{\link{fortify}}}
+\item{map}{data frame representing a map. Most map objects can be
+converted into the right format by using \code{\link{fortify}}}
- \item{...}{other arguments used to modify aesthetics}
+\item{...}{other arguments used to modify aesthetics}
}
\description{
- Annotation: maps.
+Annotation: maps.
}
\examples{
library(maps)
diff --git a/man/annotation_raster.Rd b/man/annotation_raster.Rd
index af2b599..cd6eab9 100644
--- a/man/annotation_raster.Rd
+++ b/man/annotation_raster.Rd
@@ -1,32 +1,30 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{annotation_raster}
\alias{annotation_raster}
\title{Annotation: High-performance rectangular tiling.}
\usage{
- annotation_raster(raster, xmin, xmax, ymin, ymax,
- interpolate = FALSE)
+annotation_raster(raster, xmin, xmax, ymin, ymax, interpolate = FALSE)
}
\arguments{
- \item{raster}{raster object to display}
+\item{raster}{raster object to display}
- \item{xmin,xmax}{x location (in data coordinates) giving
- horizontal location of raster}
+\item{xmin,xmax}{x location (in data coordinates) giving horizontal
+location of raster}
- \item{ymin,ymax}{y location (in data coordinates) giving
- vertical location of raster}
+\item{ymin,ymax}{y location (in data coordinates) giving vertical
+location of raster}
- \item{interpolate}{If \code{TRUE} interpolate linearly,
- if \code{FALSE} (the default) don't interpolate.}
+\item{interpolate}{If \code{TRUE} interpolate linearly, if \code{FALSE}
+(the default) don't interpolate.}
}
\description{
- This is a special version of \code{\link{geom_raster}}
- optimised for static annotations that are the same in
- every panel. These annotations will not affect scales
- (i.e. the x and y axes will not grow to cover the range
- of the raster, and the raster must already have its own
- colours).
+This is a special version of \code{\link{geom_raster}} optimised for static
+annotations that are the same in every panel. These annotations will not
+affect scales (i.e. the x and y axes will not grow to cover the range
+of the raster, and the raster must already have its own colours).
}
\details{
- Most useful for adding bitmap images.
+Most useful for adding bitmap images.
}
\examples{
# Generate data
diff --git a/man/autoplot.Rd b/man/autoplot.Rd
index 4fb66f4..205d535 100644
--- a/man/autoplot.Rd
+++ b/man/autoplot.Rd
@@ -1,25 +1,24 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{autoplot}
\alias{autoplot}
\title{Create a complete ggplot appropriate to a particular data type}
\usage{
- autoplot(object, ...)
+autoplot(object, ...)
}
\arguments{
- \item{object}{an object, whose class will determine the
- behaviour of autoplot}
+\item{object}{an object, whose class will determine the behaviour of autoplot}
- \item{...}{other arguments passed to specific methods}
+\item{...}{other arguments passed to specific methods}
}
\value{
- a ggplot object
+a ggplot object
}
\description{
- \code{autoplot} uses ggplot2 to draw a particular plot
- for an object of a particular class in a single command.
- This defines the S3 generic that other classes and
- packages can extend.
+\code{autoplot} uses ggplot2 to draw a particular plot for an object of a
+particular class in a single command. This defines the S3 generic that
+other classes and packages can extend.
}
\seealso{
- \code{\link{ggplot}} and \code{\link{fortify}}
+\code{\link{ggplot}} and \code{\link{fortify}}
}
diff --git a/man/benchplot.Rd b/man/benchplot.Rd
index eb4fc14..1901bff 100644
--- a/man/benchplot.Rd
+++ b/man/benchplot.Rd
@@ -1,16 +1,17 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{benchplot}
\alias{benchplot}
\title{Benchmark plot creation time.
Broken down into construct, build, render and draw times.}
\usage{
- benchplot(x)
+benchplot(x)
}
\arguments{
- \item{x}{code to create ggplot2 plot}
+\item{x}{code to create ggplot2 plot}
}
\description{
- Benchmark plot creation time. Broken down into construct,
- build, render and draw times.
+Benchmark plot creation time.
+Broken down into construct, build, render and draw times.
}
\examples{
benchplot(qplot(mpg, wt, data = mtcars))
diff --git a/man/borders.Rd b/man/borders.Rd
index 5142ca8..fb80aa2 100644
--- a/man/borders.Rd
+++ b/man/borders.Rd
@@ -1,25 +1,24 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{borders}
\alias{borders}
\title{Create a layer of map borders.}
\usage{
- borders(database = "world", regions = ".", fill = NA,
- colour = "grey50", ...)
+borders(database = "world", regions = ".", fill = NA, colour = "grey50",
+ ...)
}
\arguments{
- \item{database}{map data, see \code{\link[maps]{map}} for
- details}
+\item{database}{map data, see \code{\link[maps]{map}} for details}
- \item{regions}{map region}
+\item{regions}{map region}
- \item{fill}{fill colour}
+\item{fill}{fill colour}
- \item{colour}{border colour}
+\item{colour}{border colour}
- \item{...}{other arguments passed onto
- \code{\link{geom_polygon}}}
+\item{...}{other arguments passed onto \code{\link{geom_polygon}}}
}
\description{
- Create a layer of map borders.
+Create a layer of map borders.
}
\examples{
if (require("maps")) {
@@ -37,7 +36,7 @@ capitals <- subset(us.cities, capital == 2)
ggplot(capitals, aes(long, lat)) +
borders("state") +
geom_point(aes(size = pop)) +
- scale_area()
+ scale_size_area()
}
}
diff --git a/man/calc_element.Rd b/man/calc_element.Rd
index f074fcd..ec1763d 100644
--- a/man/calc_element.Rd
+++ b/man/calc_element.Rd
@@ -1,21 +1,19 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{calc_element}
\alias{calc_element}
\title{Calculate the element properties, by inheriting properties from its parents}
\usage{
- calc_element(element, theme, verbose = FALSE)
+calc_element(element, theme, verbose = FALSE)
}
\arguments{
- \item{element}{The name of the theme element to
- calculate}
+\item{element}{The name of the theme element to calculate}
- \item{theme}{A theme object (like theme_grey())}
+\item{theme}{A theme object (like theme_grey())}
- \item{verbose}{If TRUE, print out which elements this one
- inherits from}
+\item{verbose}{If TRUE, print out which elements this one inherits from}
}
\description{
- Calculate the element properties, by inheriting
- properties from its parents
+Calculate the element properties, by inheriting properties from its parents
}
\examples{
t <- theme_grey()
diff --git a/man/continuous_scale.Rd b/man/continuous_scale.Rd
index e47c115..dac5a37 100644
--- a/man/continuous_scale.Rd
+++ b/man/continuous_scale.Rd
@@ -1,76 +1,70 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{continuous_scale}
\alias{continuous_scale}
\title{Continuous scale constructor.}
\usage{
- continuous_scale(aesthetics, scale_name, palette,
- name = NULL, breaks = waiver(),
- minor_breaks = waiver(), labels = waiver(),
- legend = NULL, limits = NULL, rescaler = rescale,
- oob = censor, expand = waiver(), na.value = NA_real_,
- trans = "identity", guide = "legend")
+continuous_scale(aesthetics, scale_name, palette, name = NULL,
+ breaks = waiver(), minor_breaks = waiver(), labels = waiver(),
+ legend = NULL, limits = NULL, rescaler = rescale, oob = censor,
+ expand = waiver(), na.value = NA_real_, trans = "identity",
+ guide = "legend")
}
\arguments{
- \item{minor_breaks}{Used with date or datetime scales.
- Either \code{NULL} for no minor breaks, \code{waiver()}
- for the default breaks (one minor break between each
- major break), a numeric vector of positions, or a
- function that given the limits returns a vector of minor
- breaks.}
+\item{minor_breaks}{Used with date or datetime scales. Either \code{NULL} for
+no minor breaks, \code{waiver()} for the default breaks (one minor break
+between each major break), a numeric vector of positions, or a function
+that given the limits returns a vector of minor breaks.}
- \item{limits}{A numeric vector of length two describing
- the scale limits.}
+\item{limits}{A numeric vector of length two describing the scale limits.}
- \item{rescaler}{Used by diverging and n colour gradients
- (i.e. \code{\link{scale_colour_gradient2}},
- \code{\link{scale_colour_gradientn}}).}
+\item{rescaler}{Used by diverging and n colour gradients
+(i.e. \code{\link{scale_colour_gradient2}}, \code{\link{scale_colour_gradientn}}).}
- \item{oob}{What to do with values outside scale limits
- (out of bounds)?}
+\item{oob}{What to do with values outside scale limits (out of bounds)?}
- \item{aesthetics}{the names of the aesthetics that this
- scale works with}
+\item{aesthetics}{the names of the aesthetics that this scale works with}
- \item{scale_name}{the name of the scale}
+\item{scale_name}{the name of the scale}
- \item{palette}{a palette function that when called with a
- single integer argument (the number of levels in the
- scale) returns the values that they should take}
+\item{palette}{a palette function that when called with a single integer
+argument (the number of levels in the scale) returns the values that
+they should take}
- \item{name}{the name of the scale - used as the axis
- label or the legend title}
+\item{name}{the name of the scale - used as the axis label or the legend
+title}
- \item{breaks}{control the breaks in the guide. There are
- four possible types of input: \itemize{ \item
- \code{NULL}: don't display any breaks \item a character
- vector giving the breaks as they should appear on the
- axis or in the legend. \item \code{waiver()} to use the
- default break computation. \item a function, that when
- called with a single argument, a character vector giving
- the limits of the scale, returns a character vector
- specifying which breaks to display. } This parameter
- does not affect in any way how the data is scaled - it
- only affects the appearance of the legend.}
+\item{breaks}{control the breaks in the guide. There are four possible
+types of input:
+\itemize{
+ \item \code{NULL}: don't display any breaks
+ \item a character vector giving the breaks as they should appear on the
+ axis or in the legend.
+ \item \code{waiver()} to use the default break computation.
+ \item a function, that when called with a single argument, a character
+ vector giving the limits of the scale, returns a character vector
+ specifying which breaks to display.
+}
+This parameter does not affect in any way how the data is scaled - it
+only affects the appearance of the legend.}
- \item{labels}{\code{NULL} for no labels, \code{waiver()}
- for default labels (labels the same as breaks), a
- character vector the same length as breaks, or a named
- character vector whose names are used to match
- replacement the labels for matching breaks.}
+\item{labels}{\code{NULL} for no labels, \code{waiver()} for default
+labels (labels the same as breaks), a character vector the same length
+as breaks, or a named character vector whose names are used to match
+replacement the labels for matching breaks.}
- \item{legend}{deprecated. Use \code{guide} instead.}
+\item{legend}{deprecated. Use \code{guide} instead.}
- \item{expand}{a numeric vector of length two, giving a
- multiplicative and additive constant used to expand the
- range of the scales so that there is a small gap between
- the data and the axes.}
+\item{expand}{a numeric vector of length two, giving a multiplicative and
+additive constant used to expand the range of the scales so that there
+is a small gap between the data and the axes.}
- \item{na.value}{how should missing values be displayed?}
+\item{na.value}{how should missing values be displayed?}
- \item{guide}{the name of, or actual function, used to
- create the guide.}
+\item{guide}{the name of, or actual function, used to create the
+guide.}
}
\description{
- Continuous scale constructor.
+Continuous scale constructor.
}
\keyword{internal}
diff --git a/man/coord.Rd b/man/coord.Rd
index 5e57c19..e51b2e7 100644
--- a/man/coord.Rd
+++ b/man/coord.Rd
@@ -1,14 +1,15 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{coord}
\alias{coord}
\title{New coordinate system.}
\usage{
- coord(..., subclass = c())
+coord(..., subclass = c())
}
\arguments{
- \item{...}{object fields}
+\item{...}{object fields}
}
\description{
- Internal use only.
+Internal use only.
}
\keyword{internal}
diff --git a/man/coord_cartesian.Rd b/man/coord_cartesian.Rd
index 9087418..2f550f0 100644
--- a/man/coord_cartesian.Rd
+++ b/man/coord_cartesian.Rd
@@ -1,22 +1,22 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{coord_cartesian}
\alias{coord_cartesian}
\title{Cartesian coordinates.}
\usage{
- coord_cartesian(xlim = NULL, ylim = NULL, wise = NULL)
+coord_cartesian(xlim = NULL, ylim = NULL, wise = NULL)
}
\arguments{
- \item{xlim}{limits for the x axis}
+\item{xlim}{limits for the x axis}
- \item{ylim}{limits for the y axis}
+\item{ylim}{limits for the y axis}
- \item{wise}{deprecated in 0.9.1}
+\item{wise}{deprecated in 0.9.1}
}
\description{
- The Cartesian coordinate system is the most familiar, and
- common, type of coordinate system. Setting limits on the
- coordinate system will zoom the plot (like you're looking
- at it with a magnifying glass), and will not change the
- underlying data like setting limits on a scale will.
+The Cartesian coordinate system is the most familiar, and common, type of
+coordinate system. Setting limits on the coordinate system will zoom the
+plot (like you're looking at it with a magnifying glass), and will not
+change the underlying data like setting limits on a scale will.
}
\examples{
# There are two ways of zooming the plot display: with scales or
diff --git a/man/coord_expand_defaults.Rd b/man/coord_expand_defaults.Rd
index 1a0a028..bc3afd5 100644
--- a/man/coord_expand_defaults.Rd
+++ b/man/coord_expand_defaults.Rd
@@ -1,11 +1,12 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{coord_expand_defaults}
\alias{coord_expand_defaults}
\title{Set the default expand values for the scale, if NA}
\usage{
- coord_expand_defaults(coord, scale, aesthetic = NULL)
+coord_expand_defaults(coord, scale, aesthetic = NULL)
}
\description{
- Set the default expand values for the scale, if NA
+Set the default expand values for the scale, if NA
}
\keyword{internal}
diff --git a/man/coord_fixed.Rd b/man/coord_fixed.Rd
index dd62bea..396f882 100644
--- a/man/coord_fixed.Rd
+++ b/man/coord_fixed.Rd
@@ -1,31 +1,28 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{coord_fixed}
\alias{coord_equal}
\alias{coord_fixed}
\title{Cartesian coordinates with fixed relationship between x and y scales.}
\usage{
- coord_fixed(ratio = 1, xlim = NULL, ylim = NULL,
- wise = NULL)
+coord_fixed(ratio = 1, xlim = NULL, ylim = NULL, wise = NULL)
}
\arguments{
- \item{ratio}{aspect ratio, expressed as \code{y / x}}
+\item{ratio}{aspect ratio, expressed as \code{y / x}}
- \item{xlim}{limits for the x axis}
+\item{xlim}{limits for the x axis}
- \item{ylim}{limits for the y axis}
+\item{ylim}{limits for the y axis}
- \item{wise}{deprecated in 0.9.1}
+\item{wise}{deprecated in 0.9.1}
}
\description{
- A fixed scale coordinate system forces a specified ratio
- between the physical representation of data units on the
- axes. The ratio represents the number of units on the
- y-axis equivalent to one unit on the x-axis. The default,
- \code{ratio = 1}, ensures that one unit on the x-axis is
- the same length as one unit on the y-axis. Ratios higher
- than one make units on the y axis longer than units on
- the x-axis, and vice versa. This is similar to
- \code{\link[MASS]{eqscplot}}, but it works for all types
- of graphics.
+A fixed scale coordinate system forces a specified ratio between the
+physical representation of data units on the axes. The ratio represents the
+number of units on the y-axis equivalent to one unit on the x-axis. The
+default, \code{ratio = 1}, ensures that one unit on the x-axis is the same
+length as one unit on the y-axis. Ratios higher than one make units on the
+y axis longer than units on the x-axis, and vice versa. This is similar to
+\code{\link[MASS]{eqscplot}}, but it works for all types of graphics.
}
\examples{
# ensures that the ranges of axes are equal to the specified ratio by
diff --git a/man/coord_flip.Rd b/man/coord_flip.Rd
index dfcd73f..bc48fdd 100644
--- a/man/coord_flip.Rd
+++ b/man/coord_flip.Rd
@@ -1,18 +1,17 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{coord_flip}
\alias{coord_flip}
\title{Flipped cartesian coordinates.}
\usage{
- coord_flip(...)
+coord_flip(...)
}
\arguments{
- \item{...}{Other arguments passed onto
- \code{\link{coord_cartesian}}}
+\item{...}{Other arguments passed onto \code{\link{coord_cartesian}}}
}
\description{
- Flipped cartesian coordinates so that horizontal becomes
- vertical, and vertical, horizontal. This is primarily
- useful for converting geoms and statistics which display
- y conditional on x, to x conditional on y.
+Flipped cartesian coordinates so that horizontal becomes vertical, and
+vertical, horizontal. This is primarily useful for converting geoms and
+statistics which display y conditional on x, to x conditional on y.
}
\examples{
\donttest{
diff --git a/man/coord_map.Rd b/man/coord_map.Rd
index a1d3e6c..ce40b8b 100644
--- a/man/coord_map.Rd
+++ b/man/coord_map.Rd
@@ -1,37 +1,34 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{coord_map}
\alias{coord_map}
\title{Map projections.}
\usage{
- coord_map(projection = "mercator", ...,
- orientation = NULL, xlim = NULL, ylim = NULL)
+coord_map(projection = "mercator", ..., orientation = NULL, xlim = NULL,
+ ylim = NULL)
}
\arguments{
- \item{projection}{projection to use, see
- \code{\link[mapproj]{mapproject}} for list}
+\item{projection}{projection to use, see
+\code{\link[mapproj]{mapproject}} for list}
- \item{...}{other arguments passed on to
- \code{\link[mapproj]{mapproject}}}
+\item{...}{other arguments passed on to
+\code{\link[mapproj]{mapproject}}}
- \item{orientation}{projection orientation, which defaults
- to \code{c(90, 0, mean(range(x)))}. This is not optimal
- for many projections, so you will have to supply your
- own. See \code{\link[mapproj]{mapproject}} for more
- information.}
+\item{orientation}{projection orientation, which defaults to
+\code{c(90, 0, mean(range(x)))}. This is not optimal for many
+projections, so you will have to supply your own. See
+\code{\link[mapproj]{mapproject}} for more information.}
- \item{xlim}{manually specific x limits (in degrees of
- lontitude)}
+\item{xlim}{manually specific x limits (in degrees of lontitude)}
- \item{ylim}{manually specific y limits (in degrees of
- latitude)}
+\item{ylim}{manually specific y limits (in degrees of latitude)}
}
\description{
- This coordinate system provides the full range of map
- projections available in the mapproj package.
+This coordinate system provides the full range of map projections available
+in the mapproj package.
}
\details{
- This is still experimental, and if you have any advice to
- offer regarding a better (or more correct) way to do
- this, please let me know
+This is still experimental, and if you have any advice to offer regarding
+a better (or more correct) way to do this, please let me know
}
\examples{
if (require("maps")) {
diff --git a/man/coord_polar.Rd b/man/coord_polar.Rd
index 059188b..bd1eb34 100644
--- a/man/coord_polar.Rd
+++ b/man/coord_polar.Rd
@@ -1,22 +1,20 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{coord_polar}
\alias{coord_polar}
\title{Polar coordinates.}
\usage{
- coord_polar(theta = "x", start = 0, direction = 1)
+coord_polar(theta = "x", start = 0, direction = 1)
}
\arguments{
- \item{theta}{variable to map angle to (\code{x} or
- \code{y})}
+\item{theta}{variable to map angle to (\code{x} or \code{y})}
- \item{start}{offset of starting point from 12 o'clock in
- radians}
+\item{start}{offset of starting point from 12 o'clock in radians}
- \item{direction}{1, clockwise; -1, anticlockwise}
+\item{direction}{1, clockwise; -1, anticlockwise}
}
\description{
- The polar coordinate system is most commonly used for pie
- charts, which are a stacked bar chart in polar
- coordinates.
+The polar coordinate system is most commonly used for pie charts, which
+are a stacked bar chart in polar coordinates.
}
\examples{
\donttest{
diff --git a/man/coord_quickmap.Rd b/man/coord_quickmap.Rd
new file mode 100644
index 0000000..37dbb8e
--- /dev/null
+++ b/man/coord_quickmap.Rd
@@ -0,0 +1,51 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
+\name{coord_quickmap}
+\alias{coord_quickmap}
+\title{Cartesian coordinates with an aspect ratio approximating Mercator projection.}
+\usage{
+coord_quickmap(xlim = NULL, ylim = NULL)
+}
+\arguments{
+\item{xlim}{limits for the x axis}
+
+\item{ylim}{limits for the y axis}
+}
+\description{
+The represenation of a portion of the earth, wich is approximately spherical,
+onto a flat 2D plane requires a projection. This is what
+\code{\link{coord_map}} does. These projections account for the fact that the
+actual length (in km) of one degree of longitude varies between the equator
+and the pole. Near the equator, the ratio between the lengths of one degree
+of latitude and one degree of longitude is approximately 1. Near the pole, it
+is tends towards infinity because the length of one degree of longitude tends
+towards 0. For regions that span only a few degrees and are not too close to
+the poles, setting the aspect ratio of the plot to the appropriate lat/lon
+ratio approximates the usual mercator projection. This is what
+\code{coord_quickmap} does. With \code{\link{coord_map}} all elements of the
+graphic have to be projected which is not the case here. So
+\code{\link{coord_quickmap}} has the advantage of being much faster, in
+particular for complex plots such as those using with
+\code{\link{geom_tile}}, at the expense of correctedness in the projection.
+}
+\examples{
+# ensures that the ranges of axes are equal to the specified ratio by
+# adjusting the plot aspect ratio
+
+if (require("maps")) {
+# Create a lat-long dataframe from the maps package
+nz <- map_data("nz")
+# Prepare a plot of the map
+nzmap <- ggplot(nz, aes(x = long, y = lat, group = group)) +
+ geom_polygon(fill = "white", colour = "black")
+
+# Plot it in cartesian coordinates
+nzmap
+# With correct mercator projection
+nzmap + coord_map()
+# With the aspect ratio approximation
+nzmap + coord_quickmap()
+}
+
+# Resize the plot to see that the specified aspect ratio is maintained
+}
+
diff --git a/man/coord_trans.Rd b/man/coord_trans.Rd
index 343b868..d9ab9df 100644
--- a/man/coord_trans.Rd
+++ b/man/coord_trans.Rd
@@ -1,28 +1,26 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{coord_trans}
\alias{coord_trans}
\title{Transformed cartesian coordinate system.}
\usage{
- coord_trans(xtrans = "identity", ytrans = "identity",
- limx = NULL, limy = NULL)
+coord_trans(xtrans = "identity", ytrans = "identity", limx = NULL,
+ limy = NULL)
}
\arguments{
- \item{xtrans,ytrans}{transformers for x and y axes}
+\item{xtrans,ytrans}{transformers for x and y axes}
- \item{limx,limy}{limits for x and y axes. (Named so for
- backward compatability)}
+\item{limx,limy}{limits for x and y axes. (Named so for backward
+compatability)}
}
\description{
- \code{coord_trans} is different to scale transformations
- in that it occurs after statistical transformation and
- will affect the visual appearance of geoms - there is no
- guarantee that straight lines will continue to be
- straight.
+\code{coord_trans} is different to scale transformations in that it occurs after
+statistical transformation and will affect the visual appearance of geoms - there is
+no guarantee that straight lines will continue to be straight.
}
\details{
- All current transformations only work with continuous
- values - see \code{\link[scales]{trans_new}} for list of
- transformations, and instructions on how to create your
- own.
+All current transformations only work with continuous values - see
+\code{\link[scales]{trans_new}} for list of transformations, and instructions on
+how to create your own.
}
\examples{
\donttest{
diff --git a/man/cut_interval.Rd b/man/cut_interval.Rd
index 99c3e4a..4bbc231 100644
--- a/man/cut_interval.Rd
+++ b/man/cut_interval.Rd
@@ -1,21 +1,21 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{cut_interval}
\alias{cut_interval}
\title{Cut numeric vector into intervals of equal length.}
\usage{
- cut_interval(x, n = NULL, length = NULL, ...)
+cut_interval(x, n = NULL, length = NULL, ...)
}
\arguments{
- \item{x}{numeric vector}
+\item{x}{numeric vector}
- \item{n}{number of intervals to create, OR}
+\item{n}{number of intervals to create, OR}
- \item{length}{length of each interval}
+\item{length}{length of each interval}
- \item{...}{other arguments passed on to
- \code{\link{cut}}}
+\item{...}{other arguments passed on to \code{\link{cut}}}
}
\description{
- Cut numeric vector into intervals of equal length.
+Cut numeric vector into intervals of equal length.
}
\examples{
table(cut_interval(1:100, n = 10))
@@ -23,6 +23,6 @@ table(cut_interval(1:100, n = 11))
table(cut_interval(1:100, length = 10))
}
\seealso{
- \code{\link{cut_number}}
+\code{\link{cut_number}}
}
diff --git a/man/cut_number.Rd b/man/cut_number.Rd
index 6aa0f0f..b6dad14 100644
--- a/man/cut_number.Rd
+++ b/man/cut_number.Rd
@@ -1,25 +1,24 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{cut_number}
\alias{cut_number}
\title{Cut numeric vector into intervals containing equal number of points.}
\usage{
- cut_number(x, n = NULL, ...)
+cut_number(x, n = NULL, ...)
}
\arguments{
- \item{x}{numeric vector}
+\item{x}{numeric vector}
- \item{n}{number of intervals to create}
+\item{n}{number of intervals to create}
- \item{...}{other arguments passed on to
- \code{\link{cut}}}
+\item{...}{other arguments passed on to \code{\link{cut}}}
}
\description{
- Cut numeric vector into intervals containing equal number
- of points.
+Cut numeric vector into intervals containing equal number of points.
}
\examples{
table(cut_number(runif(1000), n = 10))
}
\seealso{
- \code{\link{cut_interval}}
+\code{\link{cut_interval}}
}
diff --git a/man/cweave.Rd b/man/cweave.Rd
index 9244b4d..1166c7f 100644
--- a/man/cweave.Rd
+++ b/man/cweave.Rd
@@ -1,17 +1,18 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{cweave}
\alias{cweave}
\title{Col weave}
\usage{
- cweave(...)
+cweave(...)
}
\arguments{
- \item{...}{matrices to weave together}
+\item{...}{matrices to weave together}
}
\description{
- Weave together two (or more) matrices by column
+Weave together two (or more) matrices by column
}
\details{
- Matrices must have same dimensions
+Matrices must have same dimensions
}
\keyword{internal}
diff --git a/man/diamonds.Rd b/man/diamonds.Rd
index fefaf71..63eeef4 100644
--- a/man/diamonds.Rd
+++ b/man/diamonds.Rd
@@ -1,24 +1,29 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\docType{data}
\name{diamonds}
\alias{diamonds}
\title{Prices of 50,000 round cut diamonds}
\format{A data frame with 53940 rows and 10 variables}
+\usage{
+data(diamonds)
+}
\description{
- A dataset containing the prices and other attributes of
- almost 54,000 diamonds. The variables are as follows:
+A dataset containing the prices and other attributes of almost 54,000
+ diamonds. The variables are as follows:
}
\details{
- \itemize{ \item price. price in US dollars
- (\$326--\$18,823) \item carat. weight of the diamond
- (0.2--5.01) \item cut. quality of the cut (Fair, Good,
- Very Good, Premium, Ideal) \item colour. diamond colour,
- from J (worst) to D (best) \item clarity. a measurement
- of how clear the diamond is (I1 (worst), SI1, SI2, VS1,
- VS2, VVS1, VVS2, IF (best)) \item x. length in mm
- (0--10.74) \item y. width in mm (0--58.9) \item z. depth
- in mm (0--31.8) \item depth. total depth percentage = z /
- mean(x, y) = 2 * z / (x + y) (43--79) \item table. width
- of top of diamond relative to widest point (43--95) }
+\itemize{
+ \item price. price in US dollars (\$326--\$18,823)
+ \item carat. weight of the diamond (0.2--5.01)
+ \item cut. quality of the cut (Fair, Good, Very Good, Premium, Ideal)
+ \item colour. diamond colour, from J (worst) to D (best)
+ \item clarity. a measurement of how clear the diamond is (I1 (worst), SI1, SI2, VS1, VS2, VVS1, VVS2, IF (best))
+ \item x. length in mm (0--10.74)
+ \item y. width in mm (0--58.9)
+ \item z. depth in mm (0--31.8)
+ \item depth. total depth percentage = z / mean(x, y) = 2 * z / (x + y) (43--79)
+ \item table. width of top of diamond relative to widest point (43--95)
+}
}
\keyword{datasets}
diff --git a/man/discrete_scale.Rd b/man/discrete_scale.Rd
index 62bf634..8e8c41a 100644
--- a/man/discrete_scale.Rd
+++ b/man/discrete_scale.Rd
@@ -1,63 +1,62 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{discrete_scale}
\alias{discrete_scale}
\title{Discrete scale constructor.}
\usage{
- discrete_scale(aesthetics, scale_name, palette,
- name = NULL, breaks = waiver(), labels = waiver(),
- legend = NULL, limits = NULL, expand = waiver(),
- na.value = NA, drop = TRUE, guide = "legend")
+discrete_scale(aesthetics, scale_name, palette, name = NULL,
+ breaks = waiver(), labels = waiver(), legend = NULL, limits = NULL,
+ expand = waiver(), na.value = NA, drop = TRUE, guide = "legend")
}
\arguments{
- \item{aesthetics}{the names of the aesthetics that this
- scale works with}
-
- \item{scale_name}{the name of the scale}
-
- \item{palette}{a palette function that when called with a
- single integer argument (the number of levels in the
- scale) returns the values that they should take}
-
- \item{name}{the name of the scale - used as the axis
- label or the legend title}
-
- \item{drop}{drop unused factor levels from the scale
- (\code{TRUE} or \code{FALSE})}
-
- \item{breaks}{control the breaks in the guide. There are
- four possible types of input: \itemize{ \item
- \code{NULL}: don't display any breaks \item a character
- vector giving the breaks as they should appear on the
- axis or in the legend. \item \code{waiver()} to use the
- default break computation. \item a function, that when
- called with a single argument, a character vector giving
- the limits of the scale, returns a character vector
- specifying which breaks to display. } This parameter
- does not affect in any way how the data is scaled - it
- only affects the appearance of the legend.}
-
- \item{limits}{A character vector specifying the data
- range for the scale. and the default order of their
- display in guides.}
-
- \item{labels}{\code{NULL} for no labels, \code{waiver()}
- for default labels (labels the same as breaks), a
- character vector the same length as breaks, or a named
- character vector whose names are used to match
- replacement the labels for matching breaks.}
-
- \item{legend}{deprecated. Use \code{guide} instead.}
-
- \item{expand}{a numeric vector of length two, giving a
- multiplicative and additive constant used to expand the
- range of the scales so that there is a small gap between
- the data and the axes.}
-
- \item{na.value}{how should missing values be displayed?}
-
- \item{guide}{the name of, or actual function, used to
- create the guide.}
+\item{aesthetics}{the names of the aesthetics that this scale works with}
+
+\item{scale_name}{the name of the scale}
+
+\item{palette}{a palette function that when called with a single integer
+argument (the number of levels in the scale) returns the values that
+they should take}
+
+\item{name}{the name of the scale - used as the axis label or the legend
+title}
+
+\item{drop}{drop unused factor levels from the scale (\code{TRUE} or
+\code{FALSE})}
+
+\item{breaks}{control the breaks in the guide. There are four possible
+types of input:
+\itemize{
+ \item \code{NULL}: don't display any breaks
+ \item a character vector giving the breaks as they should appear on the
+ axis or in the legend.
+ \item \code{waiver()} to use the default break computation.
+ \item a function, that when called with a single argument, a character
+ vector giving the limits of the scale, returns a character vector
+ specifying which breaks to display.
+}
+This parameter does not affect in any way how the data is scaled - it
+only affects the appearance of the legend.}
+
+\item{limits}{A character vector specifying the data range for the scale.
+and the default order of their display in guides.}
+
+\item{labels}{\code{NULL} for no labels, \code{waiver()} for default
+labels (labels the same as breaks), a character vector the same length
+as breaks, or a named character vector whose names are used to match
+replacement the labels for matching breaks.}
+
+\item{legend}{deprecated. Use \code{guide} instead.}
+
+\item{expand}{a numeric vector of length two, giving a multiplicative and
+additive constant used to expand the range of the scales so that there
+is a small gap between the data and the axes.}
+
+\item{na.value}{how should missing values be displayed?}
+
+\item{guide}{the name of, or actual function, used to create the
+guide.}
}
\description{
- Discrete scale constructor.
+Discrete scale constructor.
}
+\keyword{internal}
diff --git a/man/economics.Rd b/man/economics.Rd
index f0fdb2b..16c08c9 100644
--- a/man/economics.Rd
+++ b/man/economics.Rd
@@ -1,29 +1,26 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\docType{data}
\name{economics}
\alias{economics}
\title{US economic time series.}
\format{A data frame with 478 rows and 6 variables}
+\usage{
+data(economics)
+}
\description{
- This dataset was produced from US economic time series
- data available from
- \url{http://research.stlouisfed.org/fred2}.
+This dataset was produced from US economic time series data available from \url{http://research.stlouisfed.org/fred2}.
}
\details{
- \itemize{ \item date. Month of data collection
+\itemize{
+ \item date. Month of data collection
- \item psavert, personal savings rate,
- \url{http://research.stlouisfed.org/fred2/series/PSAVERT/}
- \item pce, personal consumption expenditures, in billions
- of dollars,
- \url{http://research.stlouisfed.org/fred2/series/PCE}
- \item unemploy, number of unemployed in thousands,
- \url{http://research.stlouisfed.org/fred2/series/UNEMPLOY}
- \item uempmed, median duration of unemployment, in week,
- \url{http://research.stlouisfed.org/fred2/series/UEMPMED}
- \item pop, total population, in thousands,
- \url{http://research.stlouisfed.org/fred2/series/POP}
+\item psavert, personal savings rate, \url{http://research.stlouisfed.org/fred2/series/PSAVERT/}
+ \item pce, personal consumption expenditures, in billions of dollars, \url{http://research.stlouisfed.org/fred2/series/PCE}
+ \item unemploy, number of unemployed in thousands, \url{http://research.stlouisfed.org/fred2/series/UNEMPLOY}
+ \item uempmed, median duration of unemployment, in week, \url{http://research.stlouisfed.org/fred2/series/UEMPMED}
+ \item pop, total population, in thousands, \url{http://research.stlouisfed.org/fred2/series/POP}
- }
+}
}
\keyword{datasets}
diff --git a/man/element_blank.Rd b/man/element_blank.Rd
index c470e97..2760409 100644
--- a/man/element_blank.Rd
+++ b/man/element_blank.Rd
@@ -1,12 +1,13 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{element_blank}
\alias{element_blank}
\title{Theme element: blank.
This theme element draws nothing, and assigns no space}
\usage{
- element_blank()
+element_blank()
}
\description{
- Theme element: blank. This theme element draws nothing,
- and assigns no space
+Theme element: blank.
+This theme element draws nothing, and assigns no space
}
diff --git a/man/element_line.Rd b/man/element_line.Rd
index 2b4ee0b..eb064d8 100644
--- a/man/element_line.Rd
+++ b/man/element_line.Rd
@@ -1,22 +1,23 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{element_line}
\alias{element_line}
\title{Theme element: line.}
\usage{
- element_line(colour = NULL, size = NULL, linetype = NULL,
- lineend = NULL, color = NULL)
+element_line(colour = NULL, size = NULL, linetype = NULL,
+ lineend = NULL, color = NULL)
}
\arguments{
- \item{colour}{line colour}
+\item{colour}{line colour}
- \item{size}{line size}
+\item{size}{line size}
- \item{linetype}{line type}
+\item{linetype}{line type}
- \item{lineend}{line end}
+\item{lineend}{line end}
- \item{color}{an alias for \code{colour}}
+\item{color}{an alias for \code{colour}}
}
\description{
- Theme element: line.
+Theme element: line.
}
diff --git a/man/element_rect.Rd b/man/element_rect.Rd
index 1ac6791..8be599e 100644
--- a/man/element_rect.Rd
+++ b/man/element_rect.Rd
@@ -1,22 +1,23 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{element_rect}
\alias{element_rect}
\title{Theme element: rectangle.}
\usage{
- element_rect(fill = NULL, colour = NULL, size = NULL,
- linetype = NULL, color = NULL)
+element_rect(fill = NULL, colour = NULL, size = NULL, linetype = NULL,
+ color = NULL)
}
\arguments{
- \item{fill}{fill colour}
+\item{fill}{fill colour}
- \item{colour}{border colour}
+\item{colour}{border colour}
- \item{size}{border size}
+\item{size}{border size}
- \item{linetype}{border linetype}
+\item{linetype}{border linetype}
- \item{color}{an alias for \code{colour}}
+\item{color}{an alias for \code{colour}}
}
\description{
- Most often used for backgrounds and borders.
+Most often used for backgrounds and borders.
}
diff --git a/man/element_text.Rd b/man/element_text.Rd
index e4f4446..0a4a1fb 100644
--- a/man/element_text.Rd
+++ b/man/element_text.Rd
@@ -1,32 +1,32 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{element_text}
\alias{element_text}
\title{Theme element: text.}
\usage{
- element_text(family = NULL, face = NULL, colour = NULL,
- size = NULL, hjust = NULL, vjust = NULL, angle = NULL,
- lineheight = NULL, color = NULL)
+element_text(family = NULL, face = NULL, colour = NULL, size = NULL,
+ hjust = NULL, vjust = NULL, angle = NULL, lineheight = NULL,
+ color = NULL)
}
\arguments{
- \item{family}{font family}
+\item{family}{font family}
- \item{face}{font face ("plain", "italic", "bold",
- "bold.italic")}
+\item{face}{font face ("plain", "italic", "bold", "bold.italic")}
- \item{colour}{text colour}
+\item{colour}{text colour}
- \item{size}{text size (in pts)}
+\item{size}{text size (in pts)}
- \item{hjust}{horizontal justification (in [0, 1])}
+\item{hjust}{horizontal justification (in [0, 1])}
- \item{vjust}{vertical justification (in [0, 1])}
+\item{vjust}{vertical justification (in [0, 1])}
- \item{angle}{angle (in [0, 360])}
+\item{angle}{angle (in [0, 360])}
- \item{lineheight}{line height}
+\item{lineheight}{line height}
- \item{color}{an alias for \code{colour}}
+\item{color}{an alias for \code{colour}}
}
\description{
- Theme element: text.
+Theme element: text.
}
diff --git a/man/expand_limits.Rd b/man/expand_limits.Rd
index 679632e..22758da 100644
--- a/man/expand_limits.Rd
+++ b/man/expand_limits.Rd
@@ -1,17 +1,17 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{expand_limits}
\alias{expand_limits}
\title{Expand the plot limits with data.}
\usage{
- expand_limits(...)
+expand_limits(...)
}
\arguments{
- \item{...}{named list of aesthetics specifying the value
- (or values) that should be included in each scale.}
+\item{...}{named list of aesthetics specifying the value (or values) that
+should be included in each scale.}
}
\description{
- panels or all plots. This function is a thin wrapper
- around \code{\link{geom_blank}} that makes it easy to add
- such values.
+panels or all plots. This function is a thin wrapper around
+\code{\link{geom_blank}} that makes it easy to add such values.
}
\examples{
p <- qplot(mpg, wt, data = mtcars)
diff --git a/man/facet.Rd b/man/facet.Rd
index e9c2f60..96696c7 100644
--- a/man/facet.Rd
+++ b/man/facet.Rd
@@ -1,18 +1,17 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{facet}
\alias{facet}
\title{Facet specification.}
\usage{
- facet(..., shrink = TRUE, subclass = c())
+facet(..., shrink = TRUE, subclass = c())
}
\arguments{
- \item{...}{object fields}
+\item{...}{object fields}
- \item{shrink}{shrink scales to fit output of statistics,
- not raw data}
+\item{shrink}{shrink scales to fit output of statistics, not raw data}
}
\description{
- Create new facetting specification. For internal use
- only.
+Create new facetting specification. For internal use only.
}
\keyword{internal}
diff --git a/man/facet_grid.Rd b/man/facet_grid.Rd
index 02fac35..9a9e12d 100644
--- a/man/facet_grid.Rd
+++ b/man/facet_grid.Rd
@@ -1,64 +1,55 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{facet_grid}
\alias{facet_grid}
\title{Lay out panels in a grid.}
\usage{
- facet_grid(facets, margins = FALSE, scales = "fixed",
- space = "fixed", shrink = TRUE,
- labeller = "label_value", as.table = TRUE, drop = TRUE)
+facet_grid(facets, margins = FALSE, scales = "fixed", space = "fixed",
+ shrink = TRUE, labeller = "label_value", as.table = TRUE, drop = TRUE)
}
\arguments{
- \item{facets}{a formula with the rows (of the tabular
- display) on the LHS and the columns (of the tabular
- display) on the RHS; the dot in the formula is used to
- indicate there should be no faceting on this dimension
- (either row or column). The formula can also be provided
- as a string instead of a classical formula object}
-
- \item{margins}{either a logical value or a character
- vector. Margins are additional facets which contain all
- the data for each of the possible values of the faceting
- variables. If \code{FALSE}, no additional facets are
- included (the default). If \code{TRUE}, margins are
- included for all faceting variables. If specified as a
- character vector, it is the names of variables for which
- margins are to be created.}
-
- \item{scales}{Are scales shared across all facets (the
- default, \code{"fixed"}), or do they vary across rows
- (\code{"free_x"}), columns (\code{"free_y"}), or both
- rows and columns (\code{"free"})}
-
- \item{space}{If \code{"fixed"}, the default, all panels
- have the same size. If \code{"free_y"} their height will
- be proportional to the length of the y scale; if
- \code{"free_x"} their width will be proportional to the
- length of the x scale; or if \code{"free"} both height
- and width will vary. This setting has no effect unless
- the appropriate scales also vary.}
-
- \item{labeller}{A function that takes two arguments
- (\code{variable} and \code{value}) and returns a string
- suitable for display in the facet strip. See
- \code{\link{label_value}} for more details and pointers
- to other options.}
-
- \item{as.table}{If \code{TRUE}, the default, the facets
- are laid out like a table with highest values at the
- bottom-right. If \code{FALSE}, the facets are laid out
- like a plot with the highest value at the top-right.}
-
- \item{shrink}{If \code{TRUE}, will shrink scales to fit
- output of statistics, not raw data. If \code{FALSE}, will
- be range of raw data before statistical summary.}
-
- \item{drop}{If \code{TRUE}, the default, all factor
- levels not used in the data will automatically be
- dropped. If \code{FALSE}, all factor levels will be
- shown, regardless of whether or not they appear in the
- data.}
+\item{facets}{a formula with the rows (of the tabular display) on the LHS
+and the columns (of the tabular display) on the RHS; the dot in the
+formula is used to indicate there should be no faceting on this dimension
+(either row or column). The formula can also be provided as a string
+instead of a classical formula object}
+
+\item{margins}{either a logical value or a character
+vector. Margins are additional facets which contain all the data
+for each of the possible values of the faceting variables. If
+\code{FALSE}, no additional facets are included (the
+default). If \code{TRUE}, margins are included for all faceting
+variables. If specified as a character vector, it is the names of
+variables for which margins are to be created.}
+
+\item{scales}{Are scales shared across all facets (the default,
+\code{"fixed"}), or do they vary across rows (\code{"free_x"}),
+columns (\code{"free_y"}), or both rows and columns (\code{"free"})}
+
+\item{space}{If \code{"fixed"}, the default, all panels have the same size.
+ If \code{"free_y"} their height will be proportional to the length of the
+ y scale; if \code{"free_x"} their width will be proportional to the
+length of the x scale; or if \code{"free"} both height and width will
+vary. This setting has no effect unless the appropriate scales also vary.}
+
+\item{labeller}{A function that takes two arguments (\code{variable} and
+\code{value}) and returns a string suitable for display in the facet
+strip. See \code{\link{label_value}} for more details and pointers
+to other options.}
+
+\item{as.table}{If \code{TRUE}, the default, the facets are laid out like
+a table with highest values at the bottom-right. If \code{FALSE}, the
+facets are laid out like a plot with the highest value at the top-right.}
+
+\item{shrink}{If \code{TRUE}, will shrink scales to fit output of
+statistics, not raw data. If \code{FALSE}, will be range of raw data
+before statistical summary.}
+
+\item{drop}{If \code{TRUE}, the default, all factor levels not used in the
+data will automatically be dropped. If \code{FALSE}, all factor levels
+will be shown, regardless of whether or not they appear in the data.}
}
\description{
- Lay out panels in a grid.
+Lay out panels in a grid.
}
\examples{
\donttest{
diff --git a/man/facet_null.Rd b/man/facet_null.Rd
index cb53efa..a545bc6 100644
--- a/man/facet_null.Rd
+++ b/man/facet_null.Rd
@@ -1,16 +1,17 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{facet_null}
\alias{facet_null}
\title{Facet specification: a single panel.}
\usage{
- facet_null(shrink = TRUE)
+facet_null(shrink = TRUE)
}
\arguments{
- \item{shrink}{If \code{TRUE}, will shrink scales to fit
- output of statistics, not raw data. If \code{FALSE}, will
- be range of raw data before statistical summary.}
+\item{shrink}{If \code{TRUE}, will shrink scales to fit output of
+statistics, not raw data. If \code{FALSE}, will be range of raw data
+before statistical summary.}
}
\description{
- Facet specification: a single panel.
+Facet specification: a single panel.
}
\examples{
# facet_null is the default facetting specification if you
diff --git a/man/facet_wrap.Rd b/man/facet_wrap.Rd
index a688365..79c1e77 100644
--- a/man/facet_wrap.Rd
+++ b/man/facet_wrap.Rd
@@ -1,39 +1,36 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{facet_wrap}
\alias{facet_wrap}
\title{Wrap a 1d ribbon of panels into 2d.}
\usage{
- facet_wrap(facets, nrow = NULL, ncol = NULL,
- scales = "fixed", shrink = TRUE, as.table = TRUE,
- drop = TRUE)
+facet_wrap(facets, nrow = NULL, ncol = NULL, scales = "fixed",
+ shrink = TRUE, as.table = TRUE, drop = TRUE)
}
\arguments{
- \item{nrow}{number of rows}
+\item{nrow}{number of rows}
- \item{ncol}{number of columns}
+\item{ncol}{number of columns}
- \item{facets}{formula specifying variables to facet by}
+\item{facets}{formula specifying variables to facet by}
- \item{scales}{should scales be fixed (\code{"fixed"}, the
- default), free (\code{"free"}), or free in one dimension
- (\code{"free_x"}, \code{"free_y"})}
+\item{scales}{should scales be fixed (\code{"fixed"}, the default),
+free (\code{"free"}), or free in one dimension (\code{"free_x"},
+\code{"free_y"})}
- \item{shrink}{If \code{TRUE}, will shrink scales to fit
- output of statistics, not raw data. If \code{FALSE}, will
- be range of raw data before statistical summary.}
+\item{shrink}{If \code{TRUE}, will shrink scales to fit output of
+statistics, not raw data. If \code{FALSE}, will be range of raw data
+before statistical summary.}
- \item{as.table}{If \code{TRUE}, the default, the facets
- are laid out like a table with highest values at the
- bottom-right. If \code{FALSE}, the facets are laid out
- like a plot with the highest value at the top-right.}
+\item{as.table}{If \code{TRUE}, the default, the facets are laid out like
+a table with highest values at the bottom-right. If \code{FALSE}, the
+facets are laid out like a plot with the highest value at the top-right.}
- \item{drop}{If \code{TRUE}, the default, all factor
- levels not used in the data will automatically be
- dropped. If \code{FALSE}, all factor levels will be
- shown, regardless of whether or not they appear in the
- data.}
+\item{drop}{If \code{TRUE}, the default, all factor levels not used in the
+data will automatically be dropped. If \code{FALSE}, all factor levels
+will be shown, regardless of whether or not they appear in the data.}
}
\description{
- Wrap a 1d ribbon of panels into 2d.
+Wrap a 1d ribbon of panels into 2d.
}
\examples{
\donttest{
diff --git a/man/fortify-multcomp.Rd b/man/fortify-multcomp.Rd
index c811f71..d80386f 100644
--- a/man/fortify-multcomp.Rd
+++ b/man/fortify-multcomp.Rd
@@ -1,3 +1,4 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{fortify-multcomp}
\alias{fortify-multcomp}
\alias{fortify.cld}
@@ -6,24 +7,22 @@
\alias{fortify.summary.glht}
\title{Fortify methods for objects produced by \pkg{multcomp}}
\usage{
- \method{fortify}{glht} (model, data, ...)
+\method{fortify}{glht}(model, data, ...)
- \method{fortify}{confint.glht} (model, data, ...)
+\method{fortify}{confint.glht}(model, data, ...)
- \method{fortify}{summary.glht} (model, data, ...)
+\method{fortify}{summary.glht}(model, data, ...)
- \method{fortify}{cld} (model, data, ...)
+\method{fortify}{cld}(model, data, ...)
}
\arguments{
- \item{model}{an object of class \code{glht},
- \code{confint.glht}, \code{summary.glht} or
- \code{\link[multcomp]{cld}}}
+\item{model}{an object of class \code{glht}, \code{confint.glht},
+\code{summary.glht} or \code{\link[multcomp]{cld}}}
- \item{data,...}{other arguments to the generic ignored in
- this method.}
+\item{data,...}{other arguments to the generic ignored in this method.}
}
\description{
- Fortify methods for objects produced by \pkg{multcomp}
+Fortify methods for objects produced by \pkg{multcomp}
}
\examples{
if (require("multcomp")) {
diff --git a/man/fortify.Rd b/man/fortify.Rd
index e29325b..25c501b 100644
--- a/man/fortify.Rd
+++ b/man/fortify.Rd
@@ -1,24 +1,23 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{fortify}
\alias{fortify}
\title{Fortify a model with data.}
\usage{
- fortify(model, data, ...)
+fortify(model, data, ...)
}
\arguments{
- \item{model}{model or other R object to convert to data
- frame}
+\item{model}{model or other R object to convert to data frame}
- \item{data}{original dataset, if needed}
+\item{data}{original dataset, if needed}
- \item{...}{other arguments passed to methods}
+\item{...}{other arguments passed to methods}
}
\description{
- Method to convert a generic R object into a data frame
- useful for plotting. Takes its name from the idea of
- fortifying the original data with model fit statistics,
- and vice versa.
+Method to convert a generic R object into a data frame useful for plotting.
+Takes its name from the idea of fortifying the original data with model fit
+statistics, and vice versa.
}
\seealso{
- \code{\link{fortify.lm}}
+\code{\link{fortify.lm}}
}
diff --git a/man/fortify.lm.Rd b/man/fortify.lm.Rd
index e720e82..bfc0135 100644
--- a/man/fortify.lm.Rd
+++ b/man/fortify.lm.Rd
@@ -1,30 +1,30 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{fortify.lm}
\alias{fortify.lm}
\title{Supplement the data fitted to a linear model with model fit statistics.}
\usage{
- \method{fortify}{lm} (model, data = model$model, ...)
+\method{fortify}{lm}(model, data = model$model, ...)
}
\arguments{
- \item{model}{linear model}
+\item{model}{linear model}
- \item{data}{data set, defaults to data used to fit model}
+\item{data}{data set, defaults to data used to fit model}
- \item{...}{not used by this method}
+\item{...}{not used by this method}
}
\value{
- The original data with extra columns:
+The original data with extra columns:
\item{.hat}{Diagonal of the hat matrix}
- \item{.sigma}{Estimate of residual standard deviation
- when corresponding observation is dropped from model}
- \item{.cooksd}{Cooks distance,
- \code{\link{cooks.distance}}} \item{.fitted}{Fitted
- values of model} \item{.resid}{Residuals}
+ \item{.sigma}{Estimate of residual standard deviation when
+ corresponding observation is dropped from model}
+ \item{.cooksd}{Cooks distance, \code{\link{cooks.distance}}}
+ \item{.fitted}{Fitted values of model}
+ \item{.resid}{Residuals}
\item{.stdresid}{Standardised residuals}
}
\description{
- If you have missing values in your model data, you may
- need to refit the model with \code{na.action =
- na.exclude}.
+If you have missing values in your model data, you may need to refit
+the model with \code{na.action = na.exclude}.
}
\examples{
mod <- lm(mpg ~ wt, data = mtcars)
@@ -68,6 +68,6 @@ ggplot(mod, aes(.hat, .cooksd)) +
geom_abline(slope = seq(0, 3, by = 0.5), colour = "white") +
geom_smooth(se = FALSE) +
geom_point()
-qplot(.hat, .cooksd, size = .cooksd / .hat, data = mod) + scale_area()
+qplot(.hat, .cooksd, size = .cooksd / .hat, data = mod) + scale_size_area()
}
diff --git a/man/fortify.map.Rd b/man/fortify.map.Rd
index a7279b6..fcbf6cd 100644
--- a/man/fortify.map.Rd
+++ b/man/fortify.map.Rd
@@ -1,19 +1,20 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{fortify.map}
\alias{fortify.map}
\title{Fortify method for map objects.}
\usage{
- \method{fortify}{map} (model, data, ...)
+\method{fortify}{map}(model, data, ...)
}
\arguments{
- \item{model}{map object}
+\item{model}{map object}
- \item{data}{not used by this method}
+\item{data}{not used by this method}
- \item{...}{not used by this method}
+\item{...}{not used by this method}
}
\description{
- This function turns a map into a data frame that can more
- easily be plotted with ggplot2.
+This function turns a map into a data frame that can more easily be
+plotted with ggplot2.
}
\examples{
if (require("maps")) {
@@ -28,6 +29,6 @@ qplot(long, lat, data = tx, geom = "polygon", group = group,
}
}
\seealso{
- \code{\link{map_data}} and \code{\link{borders}}
+\code{\link{map_data}} and \code{\link{borders}}
}
diff --git a/man/fortify.sp.Rd b/man/fortify.sp.Rd
index 7f77a76..1b52b98 100644
--- a/man/fortify.sp.Rd
+++ b/man/fortify.sp.Rd
@@ -1,3 +1,4 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{fortify.sp}
\alias{fortify.Line}
\alias{fortify.Lines}
@@ -9,35 +10,32 @@
\alias{fortify.sp}
\title{Fortify method for classes from the sp package.}
\usage{
- \method{fortify}{SpatialPolygonsDataFrame} (model, data,
- region = NULL, ...)
+\method{fortify}{SpatialPolygonsDataFrame}(model, data, region = NULL, ...)
- \method{fortify}{SpatialPolygons} (model, data, ...)
+\method{fortify}{SpatialPolygons}(model, data, ...)
- \method{fortify}{Polygons} (model, data, ...)
+\method{fortify}{Polygons}(model, data, ...)
- \method{fortify}{Polygon} (model, data, ...)
+\method{fortify}{Polygon}(model, data, ...)
- \method{fortify}{SpatialLinesDataFrame} (model, data,
- ...)
+\method{fortify}{SpatialLinesDataFrame}(model, data, ...)
- \method{fortify}{Lines} (model, data, ...)
+\method{fortify}{Lines}(model, data, ...)
- \method{fortify}{Line} (model, data, ...)
+\method{fortify}{Line}(model, data, ...)
}
\arguments{
- \item{model}{\code{SpatialPolygonsDataFrame} to convert
- into a dataframe.}
+\item{model}{\code{SpatialPolygonsDataFrame} to convert into a dataframe.}
- \item{data}{not used by this method}
+\item{data}{not used by this method}
- \item{region}{name of variable used to split up regions}
+\item{region}{name of variable used to split up regions}
- \item{...}{not used by this method}
+\item{...}{not used by this method}
}
\description{
- To figure out the correct variable name for region,
- inspect \code{as.data.frame(model)}.
+To figure out the correct variable name for region, inspect
+\code{as.data.frame(model)}.
}
\examples{
if (require("maptools")) {
diff --git a/man/geom_abline.Rd b/man/geom_abline.Rd
index 197aaee..3f55b6a 100644
--- a/man/geom_abline.Rd
+++ b/man/geom_abline.Rd
@@ -1,51 +1,47 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{geom_abline}
\alias{geom_abline}
\title{Line specified by slope and intercept.}
\usage{
- geom_abline(mapping = NULL, data = NULL, stat = "abline",
- position = "identity", show_guide = FALSE, ...)
+geom_abline(mapping = NULL, data = NULL, stat = "abline",
+ position = "identity", show_guide = FALSE, ...)
}
\arguments{
- \item{show_guide}{should a legend be drawn? (defaults to
- \code{FALSE})}
+\item{show_guide}{should a legend be drawn? (defaults to \code{FALSE})}
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{stat}{The statistical transformation to use on the
- data for this layer.}
+\item{stat}{The statistical transformation to use on the data for this
+layer.}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlapping points
+on this layer}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\description{
- The abline geom adds a line with specified slope and
- intercept to the plot.
+The abline geom adds a line with specified slope and intercept to the
+plot.
}
\details{
- With its siblings \code{geom_hline} and
- \code{geom_vline}, it's useful for annotating plots. You
- can supply the parameters for geom_abline, intercept and
- slope, in two ways: either explicitly as fixed values, or
- in a data frame. If you specify the fixed values
- (\code{geom_abline(intercept=0, slope=1)}) then the line
- will be the same in all panels. If the intercept and
- slope are stored in the data, then they can vary from
- panel to panel. See the examples for more ideas.
+With its siblings \code{geom_hline} and \code{geom_vline}, it's useful for
+annotating plots. You can supply the parameters for geom_abline,
+intercept and slope, in two ways: either explicitly as fixed values, or
+in a data frame. If you specify the fixed values
+(\code{geom_abline(intercept=0, slope=1)}) then the line will be the same
+in all panels. If the intercept and slope are stored in the data, then
+they can vary from panel to panel. See the examples for more ideas.
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom",
- "abline")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "abline")}
}
\examples{
p <- qplot(wt, mpg, data = mtcars)
@@ -85,9 +81,9 @@ p + geom_abline(intercept = 37, slope = -5) + coord_flip()
p + geom_abline(intercept = 37, slope = -5) + coord_polar()
}
\seealso{
- \code{\link{stat_smooth}} to add lines derived from the
- data, \code{\link{geom_hline}} for horizontal lines,
- \code{\link{geom_vline}} for vertical lines
- \code{\link{geom_segment}}
+\code{\link{stat_smooth}} to add lines derived from the data,
+ \code{\link{geom_hline}} for horizontal lines,
+ \code{\link{geom_vline}} for vertical lines
+ \code{\link{geom_segment}}
}
diff --git a/man/geom_area.Rd b/man/geom_area.Rd
index 55d2dd6..3696588 100644
--- a/man/geom_area.Rd
+++ b/man/geom_area.Rd
@@ -1,48 +1,43 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{geom_area}
\alias{geom_area}
\title{Area plot.}
\usage{
- geom_area(mapping = NULL, data = NULL, stat = "identity",
- position = "stack", na.rm = FALSE, ...)
+geom_area(mapping = NULL, data = NULL, stat = "identity",
+ position = "stack", na.rm = FALSE, ...)
}
\arguments{
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{stat}{The statistical transformation to use on the
- data for this layer.}
+\item{stat}{The statistical transformation to use on the data for this
+layer.}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlapping points
+on this layer}
- \item{na.rm}{If \code{FALSE} (the default), removes
- missing values with a warning. If \code{TRUE} silently
- removes missing values.}
+\item{na.rm}{If \code{FALSE} (the default), removes missing values with
+a warning. If \code{TRUE} silently removes missing values.}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\description{
- An area plot is the continuous analog of a stacked bar
- chart (see \code{\link{geom_bar}}), and can be used to
- show how composition of the whole varies over the range
- of x. Choosing the order in which different components
- is stacked is very important, as it becomes increasing
- hard to see the individual pattern as you move up the
- stack.
+An area plot is the continuous analog of a stacked bar chart (see
+\code{\link{geom_bar}}), and can be used to show how composition of the
+whole varies over the range of x. Choosing the order in which different
+components is stacked is very important, as it becomes increasing hard to
+see the individual pattern as you move up the stack.
}
\details{
- An area plot is a special case of
- \code{\link{geom_ribbon}}, where the minimum of the range
- is fixed to 0, and the position adjustment defaults to
- position_stacked.
+An area plot is a special case of \code{\link{geom_ribbon}}, where the
+minimum of the range is fixed to 0, and the position adjustment defaults
+to position_stacked.
}
\examples{
# see geom_ribbon
diff --git a/man/geom_bar.Rd b/man/geom_bar.Rd
index 20591f2..fda3dc1 100644
--- a/man/geom_bar.Rd
+++ b/man/geom_bar.Rd
@@ -1,77 +1,68 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{geom_bar}
\alias{geom_bar}
\title{Bars, rectangles with bases on x-axis}
\usage{
- geom_bar(mapping = NULL, data = NULL, stat = "bin",
- position = "stack", ...)
+geom_bar(mapping = NULL, data = NULL, stat = "bin", position = "stack",
+ ...)
}
\arguments{
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{stat}{The statistical transformation to use on the
- data for this layer.}
+\item{stat}{The statistical transformation to use on the data for this
+layer.}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlapping points
+on this layer}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\description{
- The bar geom is used to produce 1d area plots: bar charts
- for categorical x, and histograms for continuous y.
- stat_bin explains the details of these summaries in more
- detail. In particular, you can use the \code{weight}
- aesthetic to create weighted histograms and barcharts
- where the height of the bar no longer represent a count
- of observations, but a sum over some other variable. See
- the examples for a practical example.
+The bar geom is used to produce 1d area plots: bar charts for categorical
+x, and histograms for continuous y. stat_bin explains the details of
+these summaries in more detail. In particular, you can use the
+\code{weight} aesthetic to create weighted histograms and barcharts where
+the height of the bar no longer represent a count of observations, but a
+sum over some other variable. See the examples for a practical
+example.
}
\details{
- The heights of the bars commonly represent one of two
- things: either a count of cases in each group, or the
- values in a column of the data frame. By default,
- \code{geom_bar} uses \code{stat="bin"}. This makes the
- height of each bar equal to the number of cases in each
- group, and it is incompatible with mapping values to the
- \code{y} aesthetic. If you want the heights of the bars
- to represent values in the data, use
- \code{stat="identity"} and map a value to the \code{y}
- aesthetic.
-
- By default, multiple x's occuring in the same place will
- be stacked a top one another by position_stack. If you
- want them to be dodged from side-to-side, see
- \code{\link{position_dodge}}. Finally,
- \code{\link{position_fill}} shows relative propotions at
- each x by stacking the bars and then stretching or
- squashing to the same height.
-
- Sometimes, bar charts are used not as a distributional
- summary, but instead of a dotplot. Generally, it's
- preferable to use a dotplot (see \code{geom_point}) as it
- has a better data-ink ratio. However, if you do want to
- create this type of plot, you can set y to the value you
- have calculated, and use \code{stat='identity'}
-
- A bar chart maps the height of the bar to a variable, and
- so the base of the bar must always been shown to produce
- a valid visual comparison. Naomi Robbins has a nice
- \href{http://www.b-eye-network.com/view/index.php?cid=2468}{article
- on this topic}. This is the reason it doesn't make sense
- to use a log-scaled y axis with a bar chart
+The heights of the bars commonly represent one of two things: either a
+count of cases in each group, or the values in a column of the data frame.
+By default, \code{geom_bar} uses \code{stat="bin"}. This makes the height
+of each bar equal to the number of cases in each group, and it is
+incompatible with mapping values to the \code{y} aesthetic. If you want
+the heights of the bars to represent values in the data, use
+\code{stat="identity"} and map a value to the \code{y} aesthetic.
+
+By default, multiple x's occuring in the same place will be stacked a top
+one another by position_stack. If you want them to be dodged from
+side-to-side, see \code{\link{position_dodge}}. Finally,
+\code{\link{position_fill}} shows relative propotions at each x by stacking
+the bars and then stretching or squashing to the same height.
+
+Sometimes, bar charts are used not as a distributional summary, but
+instead of a dotplot. Generally, it's preferable to use a dotplot (see
+\code{geom_point}) as it has a better data-ink ratio. However, if you do
+want to create this type of plot, you can set y to the value you have
+calculated, and use \code{stat='identity'}
+
+A bar chart maps the height of the bar to a variable, and so the base of
+the bar must always been shown to produce a valid visual comparison.
+Naomi Robbins has a nice
+\href{http://www.b-eye-network.com/view/index.php?cid=2468}{article on this topic}.
+This is the reason it doesn't make sense to use a log-scaled y axis with a bar chart
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom",
- "bar")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "bar")}
}
\examples{
\donttest{
@@ -153,9 +144,8 @@ m + geom_bar()
}
}
\seealso{
- \code{\link{stat_bin}} for more details of the binning
- alogirithm, \code{\link{position_dodge}} for creating
- side-by-side barcharts, \code{\link{position_stack}} for
- more info on stacking,
+\code{\link{stat_bin}} for more details of the binning alogirithm,
+ \code{\link{position_dodge}} for creating side-by-side barcharts,
+ \code{\link{position_stack}} for more info on stacking,
}
diff --git a/man/geom_bin2d.Rd b/man/geom_bin2d.Rd
index 65a71e0..3851efd 100644
--- a/man/geom_bin2d.Rd
+++ b/man/geom_bin2d.Rd
@@ -1,36 +1,35 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{geom_bin2d}
\alias{geom_bin2d}
\title{Add heatmap of 2d bin counts.}
\usage{
- geom_bin2d(mapping = NULL, data = NULL, stat = "bin2d",
- position = "identity", ...)
+geom_bin2d(mapping = NULL, data = NULL, stat = "bin2d",
+ position = "identity", ...)
}
\arguments{
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{stat}{The statistical transformation to use on the
- data for this layer.}
+\item{stat}{The statistical transformation to use on the data for this
+layer.}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlapping points
+on this layer}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\description{
- Add heatmap of 2d bin counts.
+Add heatmap of 2d bin counts.
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom",
- "bin2d")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "bin2d")}
}
\examples{
d <- ggplot(diamonds, aes(x = x, y = y)) + xlim(4,10) + ylim(4,10)
diff --git a/man/geom_blank.Rd b/man/geom_blank.Rd
index 373daa8..c919f9d 100644
--- a/man/geom_blank.Rd
+++ b/man/geom_blank.Rd
@@ -1,33 +1,32 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{geom_blank}
\alias{geom_blank}
\title{Blank, draws nothing.}
\usage{
- geom_blank(mapping = NULL, data = NULL,
- stat = "identity", position = "identity", ...)
+geom_blank(mapping = NULL, data = NULL, stat = "identity",
+ position = "identity", ...)
}
\arguments{
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{stat}{The statistical transformation to use on the
- data for this layer.}
+\item{stat}{The statistical transformation to use on the data for this
+layer.}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlapping points
+on this layer}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\description{
- The blank geom draws nothing, but can be a useful way of
- ensuring common scales between different plots.
+The blank geom draws nothing, but can be a useful way of ensuring common
+scales between different plots.
}
\examples{
qplot(length, rating, data = movies, geom = "blank")
diff --git a/man/geom_boxplot.Rd b/man/geom_boxplot.Rd
index 815dda9..a6238b5 100644
--- a/man/geom_boxplot.Rd
+++ b/man/geom_boxplot.Rd
@@ -1,73 +1,71 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{geom_boxplot}
\alias{geom_boxplot}
\title{Box and whiskers plot.}
\usage{
- geom_boxplot(mapping = NULL, data = NULL,
- stat = "boxplot", position = "dodge",
- outlier.colour = "black", outlier.shape = 16,
- outlier.size = 2, notch = FALSE, notchwidth = 0.5, ...)
+geom_boxplot(mapping = NULL, data = NULL, stat = "boxplot",
+ position = "dodge", outlier.colour = NULL, outlier.shape = NULL,
+ outlier.size = NULL, notch = FALSE, notchwidth = 0.5,
+ varwidth = FALSE, ...)
}
\arguments{
- \item{outlier.colour}{colour for outlying points}
+\item{outlier.colour}{colour for outlying points. Uses the default from geom_point().}
- \item{outlier.shape}{shape of outlying points}
+\item{outlier.shape}{shape of outlying points. Uses the default from geom_point().}
- \item{outlier.size}{size of outlying points}
+\item{outlier.size}{size of outlying points. Uses the default from geom_point().}
- \item{notch}{if \code{FALSE} (default) make a standard
- box plot. If \code{TRUE}, make a notched box plot.
- Notches are used to compare groups; if the notches of two
- boxes do not overlap, this is strong evidence that the
- medians differ.}
+\item{notch}{if \code{FALSE} (default) make a standard box plot. If
+\code{TRUE}, make a notched box plot. Notches are used to compare groups;
+if the notches of two boxes do not overlap, this is strong evidence that
+the medians differ.}
- \item{notchwidth}{for a notched box plot, width of the
- notch relative to the body (default 0.5)}
+\item{notchwidth}{for a notched box plot, width of the notch relative to
+the body (default 0.5)}
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{varwidth}{if \code{FALSE} (default) make a standard box plot. If
+\code{TRUE}, boxes are drawn with widths proportional to the
+square-roots of the number of observations in the groups (possibly
+weighted, using the \code{weight} aesthetic).}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{stat}{The statistical transformation to use on the
- data for this layer.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{stat}{The statistical transformation to use on the data for this
+layer.}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{position}{The position adjustment to use for overlapping points
+on this layer}
+
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\description{
- The upper and lower "hinges" correspond to the first and
- third quartiles (the 25th and 75th percentiles). This
- differs slightly from the method used by the
- \code{boxplot} function, and may be apparent with small
- samples. See \code{\link{boxplot.stats}} for for more
- information on how hinge positions are calculated for
- \code{boxplot}.
+The upper and lower "hinges" correspond to the first and third quartiles
+(the 25th and 75th percentiles). This differs slightly from the method used
+by the \code{boxplot} function, and may be apparent with small samples.
+See \code{\link{boxplot.stats}} for for more information on how hinge
+positions are calculated for \code{boxplot}.
}
\details{
- The upper whisker extends from the hinge to the highest
- value that is within 1.5 * IQR of the hinge, where IQR is
- the inter-quartile range, or distance between the first
- and third quartiles. The lower whisker extends from the
- hinge to the lowest value within 1.5 * IQR of the hinge.
- Data beyond the end of the whiskers are outliers and
- plotted as points (as specified by Tukey).
-
- In a notched box plot, the notches extend \code{1.58 *
- IQR / sqrt(n)}. This gives a roughly 95% confidence
- interval for comparing medians. See McGill et al. (1978)
- for more details.
+The upper whisker extends from the hinge to the highest value that is within
+1.5 * IQR of the hinge, where IQR is the inter-quartile range, or distance
+between the first and third quartiles. The lower whisker extends from the
+hinge to the lowest value within 1.5 * IQR of the hinge. Data beyond the
+end of the whiskers are outliers and plotted as points (as specified by Tukey).
+
+In a notched box plot, the notches extend \code{1.58 * IQR / sqrt(n)}.
+This gives a roughly 95% confidence interval for comparing medians.
+See McGill et al. (1978) for more details.
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom",
- "boxplot")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "boxplot")}
}
\examples{
\donttest{
@@ -120,20 +118,32 @@ qplot(year, budget, data = movies, geom = "boxplot",
# Using precomputed statistics
# generate sample data
abc <- adply(matrix(rnorm(100), ncol = 5), 2, quantile, c(0, .25, .5, .75, 1))
-b <- ggplot(abc, aes(x = X1, ymin = `0\%`, lower = `25\%`, middle = `50\%`, upper = `75\%`, ymax = `100\%`))
+b <- ggplot(abc, aes(x = X1, ymin = `0\%`, lower = `25\%`,
+ middle = `50\%`, upper = `75\%`, ymax = `100\%`))
b + geom_boxplot(stat = "identity")
b + geom_boxplot(stat = "identity") + coord_flip()
b + geom_boxplot(aes(fill = X1), stat = "identity")
+
+# Using varwidth
+p + geom_boxplot(varwidth = TRUE)
+qplot(factor(cyl), mpg, data = mtcars, geom = "boxplot", varwidth = TRUE)
+
+# Update the defaults for the outliers by changing the defaults for geom_point
+
+p <- ggplot(mtcars, aes(factor(cyl), mpg))
+p + geom_boxplot()
+
+update_geom_defaults("point", list(shape = 1, colour = "red", size = 5))
+p + geom_boxplot()
}
}
\references{
- McGill, R., Tukey, J. W. and Larsen, W. A. (1978)
- Variations of box plots. The American Statistician 32,
- 12-16.
+McGill, R., Tukey, J. W. and Larsen, W. A. (1978) Variations of
+ box plots. The American Statistician 32, 12-16.
}
\seealso{
- \code{\link{stat_quantile}} to view quantiles conditioned
- on a continuous variable, \code{\link{geom_jitter}} for
- another way to look at conditional distributions"
+\code{\link{stat_quantile}} to view quantiles conditioned on a
+ continuous variable, \code{\link{geom_jitter}} for another way to look
+ at conditional distributions"
}
diff --git a/man/geom_contour.Rd b/man/geom_contour.Rd
index 5bb3fae..29ac6cf 100644
--- a/man/geom_contour.Rd
+++ b/man/geom_contour.Rd
@@ -1,54 +1,50 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{geom_contour}
\alias{geom_contour}
\title{Display contours of a 3d surface in 2d.}
\usage{
- geom_contour(mapping = NULL, data = NULL,
- stat = "contour", position = "identity",
- lineend = "butt", linejoin = "round", linemitre = 1,
- na.rm = FALSE, ...)
+geom_contour(mapping = NULL, data = NULL, stat = "contour",
+ position = "identity", lineend = "butt", linejoin = "round",
+ linemitre = 1, na.rm = FALSE, ...)
}
\arguments{
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{stat}{The statistical transformation to use on the
- data for this layer.}
+\item{stat}{The statistical transformation to use on the data for this
+layer.}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlapping points
+on this layer}
- \item{na.rm}{If \code{FALSE} (the default), removes
- missing values with a warning. If \code{TRUE} silently
- removes missing values.}
+\item{na.rm}{If \code{FALSE} (the default), removes missing values with
+a warning. If \code{TRUE} silently removes missing values.}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
- \item{lineend}{Line end style (round, butt, square)}
+\item{lineend}{Line end style (round, butt, square)}
- \item{linejoin}{Line join style (round, mitre, bevel)}
+\item{linejoin}{Line join style (round, mitre, bevel)}
- \item{linemitre}{Line mitre limit (number greater than
- 1)}
+\item{linemitre}{Line mitre limit (number greater than 1)}
}
\description{
- Display contours of a 3d surface in 2d.
+Display contours of a 3d surface in 2d.
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom",
- "contour")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "contour")}
}
\examples{
# See stat_contour for examples
}
\seealso{
- \code{\link{geom_density2d}}: 2d density contours
+\code{\link{geom_density2d}}: 2d density contours
}
diff --git a/man/geom_crossbar.Rd b/man/geom_crossbar.Rd
index 6df8207..bad7c97 100644
--- a/man/geom_crossbar.Rd
+++ b/man/geom_crossbar.Rd
@@ -1,50 +1,45 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{geom_crossbar}
\alias{geom_crossbar}
\title{Hollow bar with middle indicated by horizontal line.}
\usage{
- geom_crossbar(mapping = NULL, data = NULL,
- stat = "identity", position = "identity", fatten = 2,
- ...)
+geom_crossbar(mapping = NULL, data = NULL, stat = "identity",
+ position = "identity", fatten = 2, ...)
}
\arguments{
- \item{fatten}{a multiplicate factor to fatten middle bar
- by}
+\item{fatten}{a multiplicate factor to fatten middle bar by}
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{stat}{The statistical transformation to use on the
- data for this layer.}
+\item{stat}{The statistical transformation to use on the data for this
+layer.}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlapping points
+on this layer}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\description{
- Hollow bar with middle indicated by horizontal line.
+Hollow bar with middle indicated by horizontal line.
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom",
- "crossbar")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "crossbar")}
}
\examples{
# See geom_linerange for examples
}
\seealso{
- \code{\link{geom_errorbar}} for error bars,
- \code{\link{geom_pointrange}} and
- \code{\link{geom_linerange}} for other ways of showing
- mean + error, \code{\link{stat_summary}} to compute
- errors from the data, \code{\link{geom_smooth}} for the
- continuous analog.
+\code{\link{geom_errorbar}} for error bars,
+\code{\link{geom_pointrange}} and \code{\link{geom_linerange}} for other
+ways of showing mean + error, \code{\link{stat_summary}} to compute
+errors from the data, \code{\link{geom_smooth}} for the continuous analog.
}
diff --git a/man/geom_density.Rd b/man/geom_density.Rd
index 873937e..a503501 100644
--- a/man/geom_density.Rd
+++ b/man/geom_density.Rd
@@ -1,48 +1,44 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{geom_density}
\alias{geom_density}
\title{Display a smooth density estimate.}
\usage{
- geom_density(mapping = NULL, data = NULL,
- stat = "density", position = "identity", na.rm = FALSE,
- ...)
+geom_density(mapping = NULL, data = NULL, stat = "density",
+ position = "identity", na.rm = FALSE, ...)
}
\arguments{
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{stat}{The statistical transformation to use on the
- data for this layer.}
+\item{stat}{The statistical transformation to use on the data for this
+layer.}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlapping points
+on this layer}
- \item{na.rm}{If \code{FALSE} (the default), removes
- missing values with a warning. If \code{TRUE} silently
- removes missing values.}
+\item{na.rm}{If \code{FALSE} (the default), removes missing values with
+a warning. If \code{TRUE} silently removes missing values.}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\description{
- A smooth density estimate calculated by
- \code{\link{stat_density}}.
+A smooth density estimate calculated by \code{\link{stat_density}}.
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom",
- "density")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "density")}
}
\examples{
# See stat_density for examples
}
\seealso{
- \code{\link{geom_histogram}} for the histogram and
+\code{\link{geom_histogram}} for the histogram and
\code{\link{stat_density}} for examples.
}
diff --git a/man/geom_density2d.Rd b/man/geom_density2d.Rd
index c4d6244..dd34b26 100644
--- a/man/geom_density2d.Rd
+++ b/man/geom_density2d.Rd
@@ -1,60 +1,55 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{geom_density2d}
\alias{geom_density2d}
\title{Contours from a 2d density estimate.}
\usage{
- geom_density2d(mapping = NULL, data = NULL,
- stat = "density2d", position = "identity",
- lineend = "butt", linejoin = "round", linemitre = 1,
- na.rm = FALSE, ...)
+geom_density2d(mapping = NULL, data = NULL, stat = "density2d",
+ position = "identity", lineend = "butt", linejoin = "round",
+ linemitre = 1, na.rm = FALSE, ...)
}
\arguments{
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{stat}{The statistical transformation to use on the
- data for this layer.}
+\item{stat}{The statistical transformation to use on the data for this
+layer.}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlapping points
+on this layer}
- \item{na.rm}{If \code{FALSE} (the default), removes
- missing values with a warning. If \code{TRUE} silently
- removes missing values.}
+\item{na.rm}{If \code{FALSE} (the default), removes missing values with
+a warning. If \code{TRUE} silently removes missing values.}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
- \item{lineend}{Line end style (round, butt, square)}
+\item{lineend}{Line end style (round, butt, square)}
- \item{linejoin}{Line join style (round, mitre, bevel)}
+\item{linejoin}{Line join style (round, mitre, bevel)}
- \item{linemitre}{Line mitre limit (number greater than
- 1)}
+\item{linemitre}{Line mitre limit (number greater than 1)}
}
\description{
- Perform a 2D kernel density estimatation using kde2d and
- display the results with contours.
+Perform a 2D kernel density estimatation using kde2d and display the
+results with contours.
}
\details{
- This can be useful for dealing with overplotting.
+This can be useful for dealing with overplotting.
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom",
- "density2d")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "density2d")}
}
\examples{
# See stat_density2d for examples
}
\seealso{
- \code{\link{geom_contour}} for contour drawing geom,
- \code{\link{stat_sum}} for another way of dealing with
- overplotting
+\code{\link{geom_contour}} for contour drawing geom,
+ \code{\link{stat_sum}} for another way of dealing with overplotting
}
diff --git a/man/geom_dotplot.Rd b/man/geom_dotplot.Rd
index fa95299..2ee299b 100644
--- a/man/geom_dotplot.Rd
+++ b/man/geom_dotplot.Rd
@@ -1,95 +1,81 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{geom_dotplot}
\alias{geom_dotplot}
\title{Dot plot}
\usage{
- geom_dotplot(mapping = NULL, data = NULL,
- stat = "bindot", position = "identity", na.rm = FALSE,
- binwidth = NULL, binaxis = "x", method = "dotdensity",
- binpositions = "bygroup", stackdir = "up",
- stackratio = 1, dotsize = 1, stackgroups = FALSE, ...)
+geom_dotplot(mapping = NULL, data = NULL, stat = "bindot",
+ position = "identity", na.rm = FALSE, binwidth = NULL, binaxis = "x",
+ method = "dotdensity", binpositions = "bygroup", stackdir = "up",
+ stackratio = 1, dotsize = 1, stackgroups = FALSE, ...)
}
\arguments{
- \item{binaxis}{which axis to bin along "x" (default) or
- "y"}
-
- \item{method}{"dotdensity" (default) for dot-density
- binning, or "histodot" for fixed bin widths (like
- stat_bin)}
-
- \item{binwidth}{When \code{method} is "dotdensity", this
- specifies maximum bin width. When method is "histodot",
- this specifies bin width. Defaults to 1/30 of the range
- of the data}
-
- \item{binpositions}{When \code{method} is "dotdensity",
- "bygroup" (default) determines positions of the bins for
- each group separately. "all" determines positions of the
- bins with all the data taken together; this is used for
- aligning dot stacks across multiple groups.}
-
- \item{stackdir}{which direction to stack the dots. "up"
- (default), "down", "center", "centerwhole" (centered, but
- with dots aligned)}
-
- \item{stackratio}{how close to stack the dots. Default is
- 1, where dots just just touch. Use smaller values for
- closer, overlapping dots.}
-
- \item{dotsize}{The diameter of the dots relative to
- \code{binwidth}, default 1.}
-
- \item{stackgroups}{should dots be stacked across groups?
- This has the effect that \code{position = "stack"} should
- have, but can't (because this geom has some odd
- properties).}
-
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
-
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
-
- \item{stat}{The statistical transformation to use on the
- data for this layer.}
-
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
-
- \item{na.rm}{If \code{FALSE} (the default), removes
- missing values with a warning. If \code{TRUE} silently
- removes missing values.}
-
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{binaxis}{which axis to bin along "x" (default) or "y"}
+
+\item{method}{"dotdensity" (default) for dot-density binning, or
+"histodot" for fixed bin widths (like stat_bin)}
+
+\item{binwidth}{When \code{method} is "dotdensity", this specifies maximum bin width.
+ When method is "histodot", this specifies bin width.
+Defaults to 1/30 of the range of the data}
+
+\item{binpositions}{When \code{method} is "dotdensity", "bygroup" (default)
+determines positions of the bins for each group separately. "all" determines
+positions of the bins with all the data taken together; this is used for
+aligning dot stacks across multiple groups.}
+
+\item{stackdir}{which direction to stack the dots. "up" (default),
+"down", "center", "centerwhole" (centered, but with dots aligned)}
+
+\item{stackratio}{how close to stack the dots. Default is 1, where dots just
+just touch. Use smaller values for closer, overlapping dots.}
+
+\item{dotsize}{The diameter of the dots relative to \code{binwidth}, default 1.}
+
+\item{stackgroups}{should dots be stacked across groups? This has the effect
+that \code{position = "stack"} should have, but can't (because this geom has
+some odd properties).}
+
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
+
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
+
+\item{stat}{The statistical transformation to use on the data for this
+layer.}
+
+\item{position}{The position adjustment to use for overlapping points
+on this layer}
+
+\item{na.rm}{If \code{FALSE} (the default), removes missing values with
+a warning. If \code{TRUE} silently removes missing values.}
+
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\description{
- In a dot plot, the width of a dot corresponds to the bin
- width (or maximum width, depending on the binning
- algorithm), and dots are stacked, with each dot
- representing one observation.
+In a dot plot, the width of a dot corresponds to the bin width
+(or maximum width, depending on the binning algorithm), and dots are
+stacked, with each dot representing one observation.
}
\details{
- With dot-density binning, the bin positions are
- determined by the data and \code{binwidth}, which is the
- maximum width of each bin. See Wilkinson (1999) for
- details on the dot-density binning algorithm.
-
- With histodot binning, the bins have fixed positions and
- fixed widths, much like a histogram.
-
- When binning along the x axis and stacking along the y
- axis, the numbers on y axis are not meaningful, due to
- technical limitations of ggplot2. You can hide the y
- axis, as in one of the examples, or manually scale it to
- match the number of dots.
+With dot-density binning, the bin positions are determined by the data and
+\code{binwidth}, which is the maximum width of each bin. See Wilkinson
+(1999) for details on the dot-density binning algorithm.
+
+With histodot binning, the bins have fixed positions and fixed widths, much
+like a histogram.
+
+When binning along the x axis and stacking along the y axis, the numbers on
+y axis are not meaningful, due to technical limitations of ggplot2. You can
+hide the y axis, as in one of the examples, or manually scale it
+to match the number of dots.
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom",
- "dotplot")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "dotplot")}
}
\examples{
ggplot(mtcars, aes(x = mpg)) + geom_dotplot()
@@ -107,7 +93,7 @@ ggplot(mtcars, aes(x = mpg)) +
# y axis isn't really meaningful, so hide it
ggplot(mtcars, aes(x = mpg)) + geom_dotplot(binwidth = 1.5) +
- scale_y_continuous(name = "", breaks = NA)
+ scale_y_continuous(name = "", breaks = NULL)
# Overlap dots vertically
ggplot(mtcars, aes(x = mpg)) + geom_dotplot(binwidth = 1.5, stackratio = .7)
@@ -142,9 +128,12 @@ ggplot(mtcars, aes(x = mpg, fill = factor(cyl))) +
ggplot(mtcars, aes(x = 1, y = mpg, fill = factor(cyl))) +
geom_dotplot(binaxis = "y", stackgroups = TRUE, binwidth = 1, method = "histodot")
+
+# Use qplot instead
+qplot(mpg, data = mtcars, geom = "dotplot")
}
\references{
- Wilkinson, L. (1999) Dot plots. The American
- Statistician, 53(3), 276-281.
+Wilkinson, L. (1999) Dot plots. The American Statistician,
+ 53(3), 276-281.
}
diff --git a/man/geom_errorbar.Rd b/man/geom_errorbar.Rd
index 97c5893..3dc352c 100644
--- a/man/geom_errorbar.Rd
+++ b/man/geom_errorbar.Rd
@@ -1,36 +1,35 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{geom_errorbar}
\alias{geom_errorbar}
\title{Error bars.}
\usage{
- geom_errorbar(mapping = NULL, data = NULL,
- stat = "identity", position = "identity", ...)
+geom_errorbar(mapping = NULL, data = NULL, stat = "identity",
+ position = "identity", ...)
}
\arguments{
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{stat}{The statistical transformation to use on the
- data for this layer.}
+\item{stat}{The statistical transformation to use on the data for this
+layer.}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlapping points
+on this layer}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\description{
- Error bars.
+Error bars.
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom",
- "errorbar")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "errorbar")}
}
\examples{
# Create a simple example dataset
@@ -68,12 +67,10 @@ p + geom_crossbar(limits, width=0.2)
p + geom_line(aes(group=group)) + geom_errorbar(limits, width=0.2)
}
\seealso{
- \code{\link{geom_pointrange}}: range indicated by
- straight line, with point in the middle;
- \code{\link{geom_linerange}}: range indicated by straight
- line; \code{\link{geom_crossbar}}: hollow bar with middle
- indicated by horizontal line; \code{\link{stat_summary}}:
- examples of these guys in use, \code{\link{geom_smooth}}
- for continuous analog
+\code{\link{geom_pointrange}}: range indicated by straight line,
+ with point in the middle; \code{\link{geom_linerange}}: range indicated
+ by straight line; \code{\link{geom_crossbar}}: hollow bar with middle
+ indicated by horizontal line; \code{\link{stat_summary}}: examples of
+ these guys in use, \code{\link{geom_smooth}} for continuous analog
}
diff --git a/man/geom_errorbarh.Rd b/man/geom_errorbarh.Rd
index 1f59c2e..8e5272a 100644
--- a/man/geom_errorbarh.Rd
+++ b/man/geom_errorbarh.Rd
@@ -1,36 +1,35 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{geom_errorbarh}
\alias{geom_errorbarh}
\title{Horizontal error bars}
\usage{
- geom_errorbarh(mapping = NULL, data = NULL,
- stat = "identity", position = "identity", ...)
+geom_errorbarh(mapping = NULL, data = NULL, stat = "identity",
+ position = "identity", ...)
}
\arguments{
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{stat}{The statistical transformation to use on the
- data for this layer.}
+\item{stat}{The statistical transformation to use on the data for this
+layer.}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlapping points
+on this layer}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\description{
- Horizontal error bars
+Horizontal error bars
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom",
- "errorbarh")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "errorbarh")}
}
\examples{
df <- data.frame(
@@ -49,6 +48,6 @@ p + geom_point() +
geom_errorbarh(aes(xmax = resp + se, xmin = resp - se, height = .2))
}
\seealso{
- \code{\link{geom_errorbar}}: vertical error bars
+\code{\link{geom_errorbar}}: vertical error bars
}
diff --git a/man/geom_freqpoly.Rd b/man/geom_freqpoly.Rd
index 9abf3a0..ac59961 100644
--- a/man/geom_freqpoly.Rd
+++ b/man/geom_freqpoly.Rd
@@ -1,36 +1,35 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{geom_freqpoly}
\alias{geom_freqpoly}
\title{Frequency polygon.}
\usage{
- geom_freqpoly(mapping = NULL, data = NULL, stat = "bin",
- position = "identity", ...)
+geom_freqpoly(mapping = NULL, data = NULL, stat = "bin",
+ position = "identity", ...)
}
\arguments{
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{stat}{The statistical transformation to use on the
- data for this layer.}
+\item{stat}{The statistical transformation to use on the data for this
+layer.}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlapping points
+on this layer}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\description{
- Frequency polygon.
+Frequency polygon.
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom",
- "freqpoly")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "freqpoly")}
}
\examples{
qplot(carat, data = diamonds, geom = "freqpoly")
@@ -44,6 +43,6 @@ qplot(price, ..density.., data = diamonds, geom = "freqpoly",
binwidth = 1000, colour = color)
}
\seealso{
- \code{\link{geom_histogram}}: histograms
+\code{\link{geom_histogram}}: histograms
}
diff --git a/man/geom_hex.Rd b/man/geom_hex.Rd
index bd847f2..3c0ca41 100644
--- a/man/geom_hex.Rd
+++ b/man/geom_hex.Rd
@@ -1,36 +1,35 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{geom_hex}
\alias{geom_hex}
\title{Hexagon bining.}
\usage{
- geom_hex(mapping = NULL, data = NULL, stat = "binhex",
- position = "identity", ...)
+geom_hex(mapping = NULL, data = NULL, stat = "binhex",
+ position = "identity", ...)
}
\arguments{
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{stat}{The statistical transformation to use on the
- data for this layer.}
+\item{stat}{The statistical transformation to use on the data for this
+layer.}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlapping points
+on this layer}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\description{
- Hexagon bining.
+Hexagon bining.
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom",
- "hex")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "hex")}
}
\examples{
# See ?stat_binhex for examples
diff --git a/man/geom_histogram.Rd b/man/geom_histogram.Rd
index 8410a1d..e134a5c 100644
--- a/man/geom_histogram.Rd
+++ b/man/geom_histogram.Rd
@@ -1,45 +1,42 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{geom_histogram}
\alias{geom_histogram}
\title{Histogram}
\usage{
- geom_histogram(mapping = NULL, data = NULL, stat = "bin",
- position = "stack", ...)
+geom_histogram(mapping = NULL, data = NULL, stat = "bin",
+ position = "stack", ...)
}
\arguments{
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{stat}{The statistical transformation to use on the
- data for this layer.}
+\item{stat}{The statistical transformation to use on the data for this
+layer.}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlapping points
+on this layer}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\description{
- \code{geom_histogram} is an alias for
- \code{\link{geom_bar}} plus \code{\link{stat_bin}} so you
- will need to look at the documentation for those objects
- to get more information about the parameters.
+\code{geom_histogram} is an alias for \code{\link{geom_bar}} plus
+\code{\link{stat_bin}} so you will need to look at the documentation for
+those objects to get more information about the parameters.
}
\details{
- By default, \code{stat_bin} uses 30 bins - this is not a
- good default, but the idea is to get you experimenting
- with different binwidths. You may need to look at a few
- to uncover the full story behind your data.
+By default, \code{stat_bin} uses 30 bins - this is not a good default,
+but the idea is to get you experimenting with different binwidths. You
+may need to look at a few to uncover the full story behind your data.
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom",
- "histogram")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "histogram")}
}
\examples{
\donttest{
@@ -141,5 +138,6 @@ ggplot(diamonds_small, aes(price, fill = cut)) +
ggplot(diamonds_small, aes(depth, fill = cut)) +
geom_density(alpha = 0.2) + xlim(55, 70)
}
+rm(movies)
}
diff --git a/man/geom_hline.Rd b/man/geom_hline.Rd
index f4ca7f0..4503419 100644
--- a/man/geom_hline.Rd
+++ b/man/geom_hline.Rd
@@ -1,49 +1,46 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{geom_hline}
\alias{geom_hline}
\title{Horizontal line.}
\usage{
- geom_hline(mapping = NULL, data = NULL, stat = "hline",
- position = "identity", show_guide = FALSE, ...)
+geom_hline(mapping = NULL, data = NULL, stat = "hline",
+ position = "identity", show_guide = FALSE, ...)
}
\arguments{
- \item{show_guide}{should a legend be drawn? (defaults to
- \code{FALSE})}
+\item{show_guide}{should a legend be drawn? (defaults to \code{FALSE})}
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{stat}{The statistical transformation to use on the
- data for this layer.}
+\item{stat}{The statistical transformation to use on the data for this
+layer.}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlapping points
+on this layer}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\description{
- This geom allows you to annotate the plot with horizontal
- lines (see \code{\link{geom_vline}} and
- \code{\link{geom_abline}} for other types of lines).
+This geom allows you to annotate the plot with horizontal lines (see
+\code{\link{geom_vline}} and \code{\link{geom_abline}} for other types of
+lines).
}
\details{
- There are two ways to use it. You can either specify the
- intercept of the line in the call to the geom, in which
- case the line will be in the same position in every
- panel. Alternatively, you can supply a different
- intercept for each panel using a data.frame. See the
- examples for the differences
+There are two ways to use it. You can either specify the intercept of
+the line in the call to the geom, in which case the line will be in the
+same position in every panel. Alternatively, you can supply a different
+intercept for each panel using a data.frame. See the examples for the
+differences
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom",
- "hline")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "hline")}
}
\examples{
p <- ggplot(mtcars, aes(x = wt, y=mpg)) + geom_point()
@@ -65,9 +62,8 @@ hline.data <- data.frame(z = 1:4, vs = c(0,0,1,1), am = c(0,1,0,1))
p + geom_hline(aes(yintercept = z), hline.data)
}
\seealso{
- \code{\link{geom_vline}} for vertical lines,
- \code{\link{geom_abline}} for lines defined by a slope
- and intercept, \code{\link{geom_segment}} for a more
- general approach
+\code{\link{geom_vline}} for vertical lines,
+ \code{\link{geom_abline}} for lines defined by a slope and intercept,
+ \code{\link{geom_segment}} for a more general approach
}
diff --git a/man/geom_jitter.Rd b/man/geom_jitter.Rd
index e80f19c..ca58428 100644
--- a/man/geom_jitter.Rd
+++ b/man/geom_jitter.Rd
@@ -1,44 +1,40 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{geom_jitter}
\alias{geom_jitter}
\title{Points, jittered to reduce overplotting.}
\usage{
- geom_jitter(mapping = NULL, data = NULL,
- stat = "identity", position = "jitter", na.rm = FALSE,
- ...)
+geom_jitter(mapping = NULL, data = NULL, stat = "identity",
+ position = "jitter", na.rm = FALSE, ...)
}
\arguments{
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{stat}{The statistical transformation to use on the
- data for this layer.}
+\item{stat}{The statistical transformation to use on the data for this
+layer.}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlapping points
+on this layer}
- \item{na.rm}{If \code{FALSE} (the default), removes
- missing values with a warning. If \code{TRUE} silently
- removes missing values.}
+\item{na.rm}{If \code{FALSE} (the default), removes missing values with
+a warning. If \code{TRUE} silently removes missing values.}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\description{
- The jitter geom is a convenient default for geom_point
- with position = 'jitter'. See
- \code{\link{position_jitter}} to see how to adjust amount
- of jittering.
+The jitter geom is a convenient default for geom_point with position =
+'jitter'. See \code{\link{position_jitter}} to see how to adjust amount
+of jittering.
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom",
- "jitter")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "jitter")}
}
\examples{
p <- ggplot(mpg, aes(displ, hwy))
@@ -59,10 +55,10 @@ qplot(class, hwy, data = mpg, geom = c("boxplot", "jitter"))
qplot(class, hwy, data = mpg, geom = c("jitter", "boxplot"))
}
\seealso{
- \code{\link{geom_point}} for regular, unjittered points,
- \code{\link{geom_boxplot}} for another way of looking at
- the conditional distribution of a variable,
- \code{\link{position_jitter}} for examples of using
- jittering with other geoms
+\code{\link{geom_point}} for regular, unjittered points,
+ \code{\link{geom_boxplot}} for another way of looking at the conditional
+ distribution of a variable,
+ \code{\link{position_jitter}} for examples of using jittering with other
+ geoms
}
diff --git a/man/geom_line.Rd b/man/geom_line.Rd
index 36d8b6e..a3a3e66 100644
--- a/man/geom_line.Rd
+++ b/man/geom_line.Rd
@@ -1,36 +1,35 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{geom_line}
\alias{geom_line}
\title{Connect observations, ordered by x value.}
\usage{
- geom_line(mapping = NULL, data = NULL, stat = "identity",
- position = "identity", ...)
+geom_line(mapping = NULL, data = NULL, stat = "identity",
+ position = "identity", ...)
}
\arguments{
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{stat}{The statistical transformation to use on the
- data for this layer.}
+\item{stat}{The statistical transformation to use on the data for this
+layer.}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlapping points
+on this layer}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\description{
- Connect observations, ordered by x value.
+Connect observations, ordered by x value.
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom",
- "line")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "line")}
}
\examples{
# Summarise number of movie ratings by year of movie
@@ -86,8 +85,8 @@ ggplot(dfm, aes(variable, value, group = id, colour = group)) +
geom_path(alpha = 0.5)
}
\seealso{
- \code{\link{geom_path}}: connect observations in data
- order, \code{\link{geom_segment}}: draw line segments,
- \code{\link{geom_ribbon}}: fill between line and x-axis
+\code{\link{geom_path}}: connect observations in data order,
+ \code{\link{geom_segment}}: draw line segments,
+ \code{\link{geom_ribbon}}: fill between line and x-axis
}
diff --git a/man/geom_linerange.Rd b/man/geom_linerange.Rd
index 1185b5e..8bab061 100644
--- a/man/geom_linerange.Rd
+++ b/man/geom_linerange.Rd
@@ -1,42 +1,42 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{geom_linerange}
\alias{geom_linerange}
\title{An interval represented by a vertical line.}
\usage{
- geom_linerange(mapping = NULL, data = NULL,
- stat = "identity", position = "identity", ...)
+geom_linerange(mapping = NULL, data = NULL, stat = "identity",
+ position = "identity", ...)
}
\arguments{
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{stat}{The statistical transformation to use on the
- data for this layer.}
+\item{stat}{The statistical transformation to use on the data for this
+layer.}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlapping points
+on this layer}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\description{
- An interval represented by a vertical line.
+An interval represented by a vertical line.
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom",
- "linerange")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "linerange")}
}
\examples{
# Generate data: means and standard errors of means for prices
# for each type of cut
dmod <- lm(price ~ cut, data=diamonds)
-cuts <- data.frame(cut=unique(diamonds$cut), predict(dmod, data.frame(cut = unique(diamonds$cut)), se=TRUE)[c("fit","se.fit")])
+cuts <- data.frame(cut = unique(diamonds$cut),
+ predict(dmod, data.frame(cut = unique(diamonds$cut)), se=TRUE)[c("fit","se.fit")])
qplot(cut, fit, data=cuts)
# With a bar chart, we are comparing lengths, so the y-axis is
@@ -55,12 +55,10 @@ se + geom_crossbar(width = 0.5)
se + geom_linerange() + coord_flip()
}
\seealso{
- \code{\link{geom_errorbar}}: error bars;
- \code{\link{geom_pointrange}}: range indicated by
- straight line, with point in the middle;
- \code{\link{geom_crossbar}}: hollow bar with middle
- indicated by horizontal line; \code{\link{stat_summary}}:
- examples of these guys in use; \code{\link{geom_smooth}}:
- for continuous analog
+\code{\link{geom_errorbar}}: error bars;
+ \code{\link{geom_pointrange}}: range indicated by straight line, with
+ point in the middle; \code{\link{geom_crossbar}}: hollow bar with middle
+ indicated by horizontal line; \code{\link{stat_summary}}: examples of
+ these guys in use; \code{\link{geom_smooth}}: for continuous analog
}
diff --git a/man/geom_map.Rd b/man/geom_map.Rd
index a8f9142..c0857ce 100644
--- a/man/geom_map.Rd
+++ b/man/geom_map.Rd
@@ -1,39 +1,36 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{geom_map}
\alias{geom_map}
\title{Polygons from a reference map.}
\usage{
- geom_map(mapping = NULL, data = NULL, map,
- stat = "identity", ...)
+geom_map(mapping = NULL, data = NULL, map, stat = "identity", ...)
}
\arguments{
- \item{map}{Data frame that contains the map coordinates.
- This will typically be created using
- \code{\link{fortify}} on a spatial object. It must
- contain columns \code{x} or \code{long}, \code{y} or
- \code{lat}, and \code{region} or \code{id}.}
+\item{map}{Data frame that contains the map coordinates. This will
+typically be created using \code{\link{fortify}} on a spatial object.
+It must contain columns \code{x} or \code{long}, \code{y} or
+\code{lat}, and \code{region} or \code{id}.}
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{stat}{The statistical transformation to use on the
- data for this layer.}
+\item{stat}{The statistical transformation to use on the data for this
+layer.}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\description{
- Does not affect position scales.
+Does not affect position scales.
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom",
- "map")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "map")}
}
\examples{
# When using geom_polygon, you will typically need two data frames:
@@ -71,9 +68,15 @@ library(reshape2) # for melt
crimesm <- melt(crimes, id = 1)
if (require(maps)) {
states_map <- map_data("state")
- ggplot(crimes, aes(map_id = state)) + geom_map(aes(fill = Murder), map = states_map) + expand_limits(x = states_map$long, y = states_map$lat)
+ ggplot(crimes, aes(map_id = state)) +
+ geom_map(aes(fill = Murder), map = states_map) +
+ expand_limits(x = states_map$long, y = states_map$lat)
+
last_plot() + coord_map()
- ggplot(crimesm, aes(map_id = state)) + geom_map(aes(fill = value), map = states_map) + expand_limits(x = states_map$long, y = states_map$lat) + facet_wrap( ~ variable)
+ ggplot(crimesm, aes(map_id = state)) +
+ geom_map(aes(fill = value), map = states_map) +
+ expand_limits(x = states_map$long, y = states_map$lat) +
+ facet_wrap( ~ variable)
}
}
diff --git a/man/geom_path.Rd b/man/geom_path.Rd
index 056f988..71135cc 100644
--- a/man/geom_path.Rd
+++ b/man/geom_path.Rd
@@ -1,52 +1,47 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{geom_path}
\alias{geom_path}
\title{Connect observations in original order}
\usage{
- geom_path(mapping = NULL, data = NULL, stat = "identity",
- position = "identity", lineend = "butt",
- linejoin = "round", linemitre = 1, na.rm = FALSE,
- arrow = NULL, ...)
+geom_path(mapping = NULL, data = NULL, stat = "identity",
+ position = "identity", lineend = "butt", linejoin = "round",
+ linemitre = 1, na.rm = FALSE, arrow = NULL, ...)
}
\arguments{
- \item{lineend}{Line end style (round, butt, square)}
+\item{lineend}{Line end style (round, butt, square)}
- \item{linejoin}{Line join style (round, mitre, bevel)}
+\item{linejoin}{Line join style (round, mitre, bevel)}
- \item{linemitre}{Line mitre limit (number greater than
- 1)}
+\item{linemitre}{Line mitre limit (number greater than 1)}
- \item{arrow}{Arrow specification, as created by
- ?grid::arrow}
+\item{arrow}{Arrow specification, as created by ?grid::arrow}
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{stat}{The statistical transformation to use on the
- data for this layer.}
+\item{stat}{The statistical transformation to use on the data for this
+layer.}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlapping points
+on this layer}
- \item{na.rm}{If \code{FALSE} (the default), removes
- missing values with a warning. If \code{TRUE} silently
- removes missing values.}
+\item{na.rm}{If \code{FALSE} (the default), removes missing values with
+a warning. If \code{TRUE} silently removes missing values.}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\description{
- Connect observations in original order
+Connect observations in original order
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom",
- "path")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "path")}
}
\examples{
\donttest{
@@ -131,8 +126,8 @@ c + geom_path(arrow = arrow(angle = 15, ends = "both", length = unit(0.6, "inche
}
}
\seealso{
- \code{\link{geom_line}}: Functional (ordered) lines;
- \code{\link{geom_polygon}}: Filled paths (polygons);
- \code{\link{geom_segment}}: Line segments
+\code{\link{geom_line}}: Functional (ordered) lines;
+ \code{\link{geom_polygon}}: Filled paths (polygons);
+ \code{\link{geom_segment}}: Line segments
}
diff --git a/man/geom_point.Rd b/man/geom_point.Rd
index 697e895..3418ce0 100644
--- a/man/geom_point.Rd
+++ b/man/geom_point.Rd
@@ -1,68 +1,60 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{geom_point}
\alias{geom_point}
\title{Points, as for a scatterplot}
\usage{
- geom_point(mapping = NULL, data = NULL,
- stat = "identity", position = "identity",
- na.rm = FALSE, ...)
+geom_point(mapping = NULL, data = NULL, stat = "identity",
+ position = "identity", na.rm = FALSE, ...)
}
\arguments{
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{stat}{The statistical transformation to use on the
- data for this layer.}
+\item{stat}{The statistical transformation to use on the data for this
+layer.}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlapping points
+on this layer}
- \item{na.rm}{If \code{FALSE} (the default), removes
- missing values with a warning. If \code{TRUE} silently
- removes missing values.}
+\item{na.rm}{If \code{FALSE} (the default), removes missing values with
+a warning. If \code{TRUE} silently removes missing values.}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\description{
- The point geom is used to create scatterplots.
+The point geom is used to create scatterplots.
}
\details{
- The scatterplot is useful for displaying the relationship
- between two continuous variables, although it can also be
- used with one continuous and one categorical variable, or
- two categorical variables. See \code{\link{geom_jitter}}
- for possibilities.
-
- The \emph{bubblechart} is a scatterplot with a third
- variable mapped to the size of points. There are no
- special names for scatterplots where another variable is
- mapped to point shape or colour, however.
-
- The biggest potential problem with a scatterplot is
- overplotting: whenever you have more than a few points,
- points may be plotted on top of one another. This can
- severely distort the visual appearance of the plot. There
- is no one solution to this problem, but there are some
- techniques that can help. You can add additional
- information with \code{\link{stat_smooth}},
- \code{\link{stat_quantile}} or
- \code{\link{stat_density2d}}. If you have few unique x
- values, \code{\link{geom_boxplot}} may also be useful.
- Alternatively, you can summarise the number of points at
- each location and display that in some way, using
- \code{\link{stat_sum}}. Another technique is to use
- transparent points, \code{geom_point(alpha = 0.05)}.
+The scatterplot is useful for displaying the relationship between two
+continuous variables, although it can also be used with one continuous
+and one categorical variable, or two categorical variables. See
+\code{\link{geom_jitter}} for possibilities.
+
+The \emph{bubblechart} is a scatterplot with a third variable mapped to
+the size of points. There are no special names for scatterplots where
+another variable is mapped to point shape or colour, however.
+
+The biggest potential problem with a scatterplot is overplotting: whenever
+you have more than a few points, points may be plotted on top of one
+another. This can severely distort the visual appearance of the plot.
+There is no one solution to this problem, but there are some techniques
+that can help. You can add additional information with
+\code{\link{stat_smooth}}, \code{\link{stat_quantile}} or
+\code{\link{stat_density2d}}. If you have few unique x values,
+\code{\link{geom_boxplot}} may also be useful. Alternatively, you can
+summarise the number of points at each location and display that in some
+way, using \code{\link{stat_sum}}. Another technique is to use transparent
+points, \code{geom_point(alpha = 0.05)}.
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom",
- "point")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "point")}
}
\examples{
\donttest{
@@ -78,7 +70,7 @@ p + geom_point(aes(size = qsec))
# Change scales
p + geom_point(aes(colour = cyl)) + scale_colour_gradient(low = "blue")
-p + geom_point(aes(size = qsec)) + scale_area()
+p + geom_point(aes(size = qsec)) + scale_size_area()
p + geom_point(aes(shape = factor(cyl))) + scale_shape(solid = FALSE)
# Set aesthetics to fixed value
@@ -124,8 +116,8 @@ qplot(wt, mpg, data = mtcars, colour = I("red"))
}
}
\seealso{
- \code{\link{scale_size}} to see scale area of points,
- instead of radius, \code{\link{geom_jitter}} to jitter
- points to reduce (mild) overplotting
+\code{\link{scale_size}} to see scale area of points, instead of
+ radius, \code{\link{geom_jitter}} to jitter points to reduce (mild)
+ overplotting
}
diff --git a/man/geom_pointrange.Rd b/man/geom_pointrange.Rd
index 48fc5f0..e9f2be6 100644
--- a/man/geom_pointrange.Rd
+++ b/man/geom_pointrange.Rd
@@ -1,47 +1,44 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{geom_pointrange}
\alias{geom_pointrange}
\title{An interval represented by a vertical line, with a point in the middle.}
\usage{
- geom_pointrange(mapping = NULL, data = NULL,
- stat = "identity", position = "identity", ...)
+geom_pointrange(mapping = NULL, data = NULL, stat = "identity",
+ position = "identity", ...)
}
\arguments{
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{stat}{The statistical transformation to use on the
- data for this layer.}
+\item{stat}{The statistical transformation to use on the data for this
+layer.}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlapping points
+on this layer}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\description{
- An interval represented by a vertical line, with a point
- in the middle.
+An interval represented by a vertical line, with a point in the middle.
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom",
- "pointrange")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "pointrange")}
}
\examples{
# See geom_linerange for examples
}
\seealso{
- \code{\link{geom_errorbar}} for error bars,
- \code{\link{geom_linerange}} for range indicated by
- straight line, + examples, \code{\link{geom_crossbar}}
- for hollow bar with middle indicated by horizontal line,
- \code{\link{stat_summary}} for examples of these guys in
- use, \code{\link{geom_smooth}} for continuous analog"
+\code{\link{geom_errorbar}} for error bars,
+ \code{\link{geom_linerange}} for range indicated by straight line, + examples,
+ \code{\link{geom_crossbar}} for hollow bar with middle indicated by horizontal line,
+ \code{\link{stat_summary}} for examples of these guys in use,
+ \code{\link{geom_smooth}} for continuous analog"
}
diff --git a/man/geom_polygon.Rd b/man/geom_polygon.Rd
index e10ee81..d319c35 100644
--- a/man/geom_polygon.Rd
+++ b/man/geom_polygon.Rd
@@ -1,36 +1,35 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{geom_polygon}
\alias{geom_polygon}
\title{Polygon, a filled path.}
\usage{
- geom_polygon(mapping = NULL, data = NULL,
- stat = "identity", position = "identity", ...)
+geom_polygon(mapping = NULL, data = NULL, stat = "identity",
+ position = "identity", ...)
}
\arguments{
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{stat}{The statistical transformation to use on the
- data for this layer.}
+\item{stat}{The statistical transformation to use on the data for this
+layer.}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlapping points
+on this layer}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\description{
- Polygon, a filled path.
+Polygon, a filled path.
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom",
- "polygon")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "polygon")}
}
\examples{
# When using geom_polygon, you will typically need two data frames:
@@ -72,8 +71,7 @@ p + geom_line(data = stream, colour="grey30", size = 5)
# coord_map to produce different map projections.
}
\seealso{
- \code{\link{geom_path}} for an unfilled polygon,
- \code{\link{geom_ribbon}} for a polygon anchored on the
- x-axis
+\code{\link{geom_path}} for an unfilled polygon,
+ \code{\link{geom_ribbon}} for a polygon anchored on the x-axis
}
diff --git a/man/geom_quantile.Rd b/man/geom_quantile.Rd
index 99274ac..08f2144 100644
--- a/man/geom_quantile.Rd
+++ b/man/geom_quantile.Rd
@@ -1,55 +1,50 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{geom_quantile}
\alias{geom_quantile}
\title{Add quantile lines from a quantile regression.}
\usage{
- geom_quantile(mapping = NULL, data = NULL,
- stat = "quantile", position = "identity",
- lineend = "butt", linejoin = "round", linemitre = 1,
- na.rm = FALSE, ...)
+geom_quantile(mapping = NULL, data = NULL, stat = "quantile",
+ position = "identity", lineend = "butt", linejoin = "round",
+ linemitre = 1, na.rm = FALSE, ...)
}
\arguments{
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{stat}{The statistical transformation to use on the
- data for this layer.}
+\item{stat}{The statistical transformation to use on the data for this
+layer.}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlapping points
+on this layer}
- \item{na.rm}{If \code{FALSE} (the default), removes
- missing values with a warning. If \code{TRUE} silently
- removes missing values.}
+\item{na.rm}{If \code{FALSE} (the default), removes missing values with
+a warning. If \code{TRUE} silently removes missing values.}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
- \item{lineend}{Line end style (round, butt, square)}
+\item{lineend}{Line end style (round, butt, square)}
- \item{linejoin}{Line join style (round, mitre, bevel)}
+\item{linejoin}{Line join style (round, mitre, bevel)}
- \item{linemitre}{Line mitre limit (number greater than
- 1)}
+\item{linemitre}{Line mitre limit (number greater than 1)}
}
\description{
- This can be used as a continuous analogue of a
- geom_boxplot.
+This can be used as a continuous analogue of a geom_boxplot.
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom",
- "quantile")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "quantile")}
}
\examples{
# See stat_quantile for examples
}
\seealso{
- See \code{\link{stat_quantile}} for examples.
+See \code{\link{stat_quantile}} for examples.
}
diff --git a/man/geom_raster.Rd b/man/geom_raster.Rd
index c0463dd..7c58471 100644
--- a/man/geom_raster.Rd
+++ b/man/geom_raster.Rd
@@ -1,55 +1,51 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{geom_raster}
\alias{geom_raster}
\title{High-performance rectangular tiling.}
\usage{
- geom_raster(mapping = NULL, data = NULL,
- stat = "identity", position = "identity", hjust = 0.5,
- vjust = 0.5, interpolate = FALSE, ...)
+geom_raster(mapping = NULL, data = NULL, stat = "identity",
+ position = "identity", hjust = 0.5, vjust = 0.5, interpolate = FALSE,
+ ...)
}
\arguments{
- \item{hjust,vjust}{horizontal and vertical justification
- of the grob. Each justification value should be a number
- between 0 and 1. Defaults to 0.5 for both, centering
- each pixel over its data location.}
+\item{hjust,vjust}{horizontal and vertical justification of the grob. Each
+justification value should be a number between 0 and 1. Defaults to 0.5
+for both, centering each pixel over its data location.}
- \item{interpolate}{If \code{TRUE} interpolate linearly,
- if \code{FALSE} (the default) don't interpolate.}
+\item{interpolate}{If \code{TRUE} interpolate linearly, if \code{FALSE}
+(the default) don't interpolate.}
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{stat}{The statistical transformation to use on the
- data for this layer.}
+\item{stat}{The statistical transformation to use on the data for this
+layer.}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlapping points
+on this layer}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\description{
- This is a special case of \code{\link{geom_tile}} where
- all tiles are the same size. It is implemented highly
- efficiently using the internal \code{rasterGrob}
- function.
+This is a special case of \code{\link{geom_tile}} where all tiles are
+the same size. It is implemented highly efficiently using the internal
+\code{rasterGrob} function.
}
\details{
- By default, \code{geom_raster} add a vertical and
- horizontal padding. The size of padding depends on the
- resolution of data. If you want to manually set the
- padding (e.g. want zero-padding), you can change the
- behavior by setting \code{hpad} and \code{vpad}.
+By default, \code{geom_raster} add a vertical and horizontal padding.
+The size of padding depends on the resolution of data.
+If you want to manually set the padding (e.g. want zero-padding),
+you can change the behavior by setting \code{hpad} and \code{vpad}.
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom",
- "raster")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "raster")}
}
\examples{
\donttest{
diff --git a/man/geom_rect.Rd b/man/geom_rect.Rd
index 57a8f17..d37b2a7 100644
--- a/man/geom_rect.Rd
+++ b/man/geom_rect.Rd
@@ -1,36 +1,35 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{geom_rect}
\alias{geom_rect}
\title{2d rectangles.}
\usage{
- geom_rect(mapping = NULL, data = NULL, stat = "identity",
- position = "identity", ...)
+geom_rect(mapping = NULL, data = NULL, stat = "identity",
+ position = "identity", ...)
}
\arguments{
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{stat}{The statistical transformation to use on the
- data for this layer.}
+\item{stat}{The statistical transformation to use on the data for this
+layer.}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlapping points
+on this layer}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\description{
- 2d rectangles.
+2d rectangles.
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom",
- "rect")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "rect")}
}
\examples{
df <- data.frame(
diff --git a/man/geom_ribbon.Rd b/man/geom_ribbon.Rd
index 3e5dd0e..26ce95e 100644
--- a/man/geom_ribbon.Rd
+++ b/man/geom_ribbon.Rd
@@ -1,41 +1,38 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{geom_ribbon}
\alias{geom_ribbon}
\title{Ribbons, y range with continuous x values.}
\usage{
- geom_ribbon(mapping = NULL, data = NULL,
- stat = "identity", position = "identity",
- na.rm = FALSE, ...)
+geom_ribbon(mapping = NULL, data = NULL, stat = "identity",
+ position = "identity", na.rm = FALSE, ...)
}
\arguments{
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{stat}{The statistical transformation to use on the
- data for this layer.}
+\item{stat}{The statistical transformation to use on the data for this
+layer.}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlapping points
+on this layer}
- \item{na.rm}{If \code{FALSE} (the default), removes
- missing values with a warning. If \code{TRUE} silently
- removes missing values.}
+\item{na.rm}{If \code{FALSE} (the default), removes missing values with
+a warning. If \code{TRUE} silently removes missing values.}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\description{
- Ribbons, y range with continuous x values.
+Ribbons, y range with continuous x values.
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom",
- "ribbon")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "ribbon")}
}
\examples{
\donttest{
@@ -71,8 +68,8 @@ qplot(year, level, data=huron, geom=c("area", "line"))
}
}
\seealso{
- \code{\link{geom_bar}} for discrete intervals (bars),
- \code{\link{geom_linerange}} for discrete intervals
- (lines), \code{\link{geom_polygon}} for general polygons"
+\code{\link{geom_bar}} for discrete intervals (bars),
+ \code{\link{geom_linerange}} for discrete intervals (lines),
+ \code{\link{geom_polygon}} for general polygons"
}
diff --git a/man/geom_rug.Rd b/man/geom_rug.Rd
index 3ad8e15..7772628 100644
--- a/man/geom_rug.Rd
+++ b/man/geom_rug.Rd
@@ -1,41 +1,39 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{geom_rug}
\alias{geom_rug}
\title{Marginal rug plots.}
\usage{
- geom_rug(mapping = NULL, data = NULL, stat = "identity",
- position = "identity", sides = "bl", ...)
+geom_rug(mapping = NULL, data = NULL, stat = "identity",
+ position = "identity", sides = "bl", ...)
}
\arguments{
- \item{sides}{A string that controls which sides of the
- plot the rugs appear on. It can be set to a string
- containing any of \code{"trbl"}, for top, right, bottom,
- and left.}
+\item{sides}{A string that controls which sides of the plot the rugs appear on.
+It can be set to a string containing any of \code{"trbl"}, for top, right,
+bottom, and left.}
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{stat}{The statistical transformation to use on the
- data for this layer.}
+\item{stat}{The statistical transformation to use on the data for this
+layer.}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlapping points
+on this layer}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\description{
- Marginal rug plots.
+Marginal rug plots.
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom",
- "rug")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "rug")}
}
\examples{
p <- ggplot(mtcars, aes(x=wt, y=mpg))
diff --git a/man/geom_segment.Rd b/man/geom_segment.Rd
index 6f6452e..7533bea 100644
--- a/man/geom_segment.Rd
+++ b/man/geom_segment.Rd
@@ -1,51 +1,49 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{geom_segment}
\alias{geom_segment}
\title{Single line segments.}
\usage{
- geom_segment(mapping = NULL, data = NULL,
- stat = "identity", position = "identity", arrow = NULL,
- lineend = "butt", na.rm = FALSE, ...)
+geom_segment(mapping = NULL, data = NULL, stat = "identity",
+ position = "identity", arrow = NULL, lineend = "butt", na.rm = FALSE,
+ ...)
}
\arguments{
- \item{arrow}{specification for arrow heads, as created by
- arrow()}
+\item{arrow}{specification for arrow heads, as created by arrow()}
- \item{lineend}{Line end style (round, butt, square)}
+\item{lineend}{Line end style (round, butt, square)}
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{stat}{The statistical transformation to use on the
- data for this layer.}
+\item{stat}{The statistical transformation to use on the data for this
+layer.}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlapping points
+on this layer}
- \item{na.rm}{If \code{FALSE} (the default), removes
- missing values with a warning. If \code{TRUE} silently
- removes missing values.}
+\item{na.rm}{If \code{FALSE} (the default), removes missing values with
+a warning. If \code{TRUE} silently removes missing values.}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\description{
- Single line segments.
+Single line segments.
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom",
- "segment")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "segment")}
}
\examples{
library(grid) # needed for arrow function
p <- ggplot(seals, aes(x = long, y = lat))
-(p <- p + geom_segment(aes(xend = long + delta_long, yend = lat + delta_lat), arrow = arrow(length = unit(0.1,"cm"))))
+(p <- p + geom_segment(aes(xend = long + delta_long, yend = lat + delta_lat),
+ arrow = arrow(length = unit(0.1,"cm"))))
if (require("maps")) {
@@ -73,10 +71,11 @@ library(grid) # needed for arrow function
b <- ggplot(mtcars, aes(wt, mpg)) + geom_point()
b + geom_segment(aes(x = 2, y = 15, xend = 2, yend = 25))
b + geom_segment(aes(x = 2, y = 15, xend = 3, yend = 15))
-b + geom_segment(aes(x = 5, y = 30, xend = 3.5, yend = 25), arrow = arrow(length = unit(0.5, "cm")))
+b + geom_segment(aes(x = 5, y = 30, xend = 3.5, yend = 25),
+ arrow = arrow(length = unit(0.5, "cm")))
}
\seealso{
- \code{\link{geom_path}} and \code{\link{geom_line}} for
- multi- segment lines and paths.
+\code{\link{geom_path}} and \code{\link{geom_line}} for multi-
+ segment lines and paths.
}
diff --git a/man/geom_smooth.Rd b/man/geom_smooth.Rd
index 5e7a502..6f0d655 100644
--- a/man/geom_smooth.Rd
+++ b/man/geom_smooth.Rd
@@ -1,36 +1,35 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{geom_smooth}
\alias{geom_smooth}
\title{Add a smoothed conditional mean.}
\usage{
- geom_smooth(mapping = NULL, data = NULL, stat = "smooth",
- position = "identity", ...)
+geom_smooth(mapping = NULL, data = NULL, stat = "smooth",
+ position = "identity", ...)
}
\arguments{
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{stat}{The statistical transformation to use on the
- data for this layer.}
+\item{stat}{The statistical transformation to use on the data for this
+layer.}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlapping points
+on this layer}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\description{
- Add a smoothed conditional mean.
+Add a smoothed conditional mean.
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom",
- "smooth")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "smooth")}
}
\examples{
# See stat_smooth for examples of using built in model fitting
@@ -58,9 +57,7 @@ qplot(wt, mpg, data=mtcars, colour=factor(cyl)) +
geom_smooth(aes(ymin = lcl, ymax = ucl), data=grid, stat="identity")
}
\seealso{
- The default stat for this geom is
- \code{\link{stat_smooth}} see that documentation for more
- options to control the underlying statistical
- transformation.
+The default stat for this geom is \code{\link{stat_smooth}} see
+ that documentation for more options to control the underlying statistical transformation.
}
diff --git a/man/geom_step.Rd b/man/geom_step.Rd
index 92a8bf2..31848b4 100644
--- a/man/geom_step.Rd
+++ b/man/geom_step.Rd
@@ -1,39 +1,38 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{geom_step}
\alias{geom_step}
\title{Connect observations by stairs.}
\usage{
- geom_step(mapping = NULL, data = NULL, stat = "identity",
- position = "identity", direction = "hv", ...)
+geom_step(mapping = NULL, data = NULL, stat = "identity",
+ position = "identity", direction = "hv", ...)
}
\arguments{
- \item{direction}{direction of stairs: 'vh' for vertical
- then horizontal, or 'hv' for horizontal then vertical}
+\item{direction}{direction of stairs: 'vh' for vertical then horizontal, or
+'hv' for horizontal then vertical}
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{stat}{The statistical transformation to use on the
- data for this layer.}
+\item{stat}{The statistical transformation to use on the data for this
+layer.}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlapping points
+on this layer}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\description{
- Connect observations by stairs.
+Connect observations by stairs.
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom",
- "step")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "step")}
}
\examples{
# Simple quantiles/ECDF from examples(plot)
diff --git a/man/geom_text.Rd b/man/geom_text.Rd
index 55bc31f..2c8a2d1 100644
--- a/man/geom_text.Rd
+++ b/man/geom_text.Rd
@@ -1,39 +1,38 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{geom_text}
\alias{geom_text}
\title{Textual annotations.}
\usage{
- geom_text(mapping = NULL, data = NULL, stat = "identity",
- position = "identity", parse = FALSE, ...)
+geom_text(mapping = NULL, data = NULL, stat = "identity",
+ position = "identity", parse = FALSE, ...)
}
\arguments{
- \item{parse}{If TRUE, the labels will be parsed into
- expressions and displayed as described in ?plotmath}
+\item{parse}{If TRUE, the labels will be parsed into expressions and
+displayed as described in ?plotmath}
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{stat}{The statistical transformation to use on the
- data for this layer.}
+\item{stat}{The statistical transformation to use on the data for this
+layer.}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlapping points
+on this layer}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\description{
- Textual annotations.
+Textual annotations.
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom",
- "text")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "text")}
}
\examples{
\donttest{
diff --git a/man/geom_tile.Rd b/man/geom_tile.Rd
index dcc7f05..f137c15 100644
--- a/man/geom_tile.Rd
+++ b/man/geom_tile.Rd
@@ -1,37 +1,35 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{geom_tile}
\alias{geom_tile}
\title{Tile plane with rectangles.}
\usage{
- geom_tile(mapping = NULL, data = NULL, stat = "identity",
- position = "identity", ...)
+geom_tile(mapping = NULL, data = NULL, stat = "identity",
+ position = "identity", ...)
}
\arguments{
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{stat}{The statistical transformation to use on the
- data for this layer.}
+\item{stat}{The statistical transformation to use on the data for this
+layer.}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlapping points
+on this layer}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\description{
- Similar to \code{\link{levelplot}} and
- \code{\link{image}}.
+Similar to \code{\link{levelplot}} and \code{\link{image}}.
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom",
- "tile")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "tile")}
}
\examples{
\donttest{
@@ -91,7 +89,8 @@ qplot(x, y, fill=factor(z), data=example, geom="tile", width=w)
# You can manually set the colour of the tiles using
# scale_manual
col <- c("darkblue", "blue", "green", "orange", "red")
-qplot(x, y, fill=col[z], data=example, geom="tile", width=w, group=1) + scale_fill_identity(labels=letters[1:5], breaks=col)
+qplot(x, y, fill=col[z], data=example, geom="tile", width=w, group=1) +
+ scale_fill_identity(labels=letters[1:5], breaks=col)
}
}
diff --git a/man/geom_violin.Rd b/man/geom_violin.Rd
index 9f8ac8f..340e327 100644
--- a/man/geom_violin.Rd
+++ b/man/geom_violin.Rd
@@ -1,46 +1,42 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{geom_violin}
\alias{geom_violin}
\title{Violin plot.}
\usage{
- geom_violin(mapping = NULL, data = NULL,
- stat = "ydensity", position = "dodge", trim = TRUE,
- scale = "area", ...)
+geom_violin(mapping = NULL, data = NULL, stat = "ydensity",
+ position = "dodge", trim = TRUE, scale = "area", ...)
}
\arguments{
- \item{trim}{If \code{TRUE} (default), trim the tails of
- the violins to the range of the data. If \code{FALSE},
- don't trim the tails.}
+\item{trim}{If \code{TRUE} (default), trim the tails of the violins
+to the range of the data. If \code{FALSE}, don't trim the tails.}
- \item{scale}{if "area" (default), all violins have the
- same area (before trimming the tails). If "count", areas
- are scaled proportionally to the number of observations.
- If "width", all violins have the same maximum width.}
+\item{scale}{if "area" (default), all violins have the same area (before trimming
+the tails). If "count", areas are scaled proportionally to the number of
+observations. If "width", all violins have the same maximum width.}
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{stat}{The statistical transformation to use on the
- data for this layer.}
+\item{stat}{The statistical transformation to use on the data for this
+layer.}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlapping points
+on this layer}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\description{
- Violin plot.
+Violin plot.
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom",
- "violin")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "violin")}
}
\examples{
\donttest{
diff --git a/man/geom_vline.Rd b/man/geom_vline.Rd
index 4b2d845..d6088d9 100644
--- a/man/geom_vline.Rd
+++ b/man/geom_vline.Rd
@@ -1,49 +1,46 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{geom_vline}
\alias{geom_vline}
\title{Line, vertical.}
\usage{
- geom_vline(mapping = NULL, data = NULL, stat = "vline",
- position = "identity", show_guide = FALSE, ...)
+geom_vline(mapping = NULL, data = NULL, stat = "vline",
+ position = "identity", show_guide = FALSE, ...)
}
\arguments{
- \item{show_guide}{should a legend be drawn? (defaults to
- \code{FALSE})}
+\item{show_guide}{should a legend be drawn? (defaults to \code{FALSE})}
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{stat}{The statistical transformation to use on the
- data for this layer.}
+\item{stat}{The statistical transformation to use on the data for this
+layer.}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlapping points
+on this layer}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\description{
- This geom allows you to annotate the plot with vertical
- lines (see \code{\link{geom_hline}} and
- \code{\link{geom_abline}} for other types of lines.
+This geom allows you to annotate the plot with vertical lines (see
+\code{\link{geom_hline}} and \code{\link{geom_abline}} for other types of
+lines.
}
\details{
- There are two ways to use it. You can either specify the
- intercept of the line in the call to the geom, in which
- case the line will be in the same position in every
- panel. Alternatively, you can supply a different
- intercept for each panel using a data.frame. See the
- examples for the differences.
+There are two ways to use it. You can either specify the intercept of the
+line in the call to the geom, in which case the line will be in the same
+position in every panel. Alternatively, you can supply a different
+intercept for each panel using a data.frame. See the examples for the
+differences.
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom",
- "vline")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("geom", "vline")}
}
\examples{
# Fixed lines
@@ -68,9 +65,8 @@ vline.data <- data.frame(z = c(15, 20, 25, 30), vs = c(0, 0, 1, 1), am = c(0, 1,
p + geom_vline(aes(xintercept = z), vline.data)
}
\seealso{
- \code{\link{geom_hline}} for horizontal lines,
- \code{\link{geom_abline}} for lines defined by a slope
- and intercept, \code{\link{geom_segment}} for a more
- general approach"
+\code{\link{geom_hline}} for horizontal lines,
+ \code{\link{geom_abline}} for lines defined by a slope and intercept,
+ \code{\link{geom_segment}} for a more general approach"
}
diff --git a/man/gg-add.Rd b/man/gg-add.Rd
index 027f4dc..7240eae 100644
--- a/man/gg-add.Rd
+++ b/man/gg-add.Rd
@@ -1,53 +1,52 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{+.gg}
\alias{+.gg}
\alias{\%+\%}
\alias{\%+replace\%}
\title{Modify a ggplot or theme object by adding on new components.}
\usage{
- \method{+}{gg} (e1, e2)
+\method{+}{gg}(e1, e2)
- %+%(e1, e2)
+e1 \%+\% e2
- %+replace%(e1, e2)
+e1 \%+replace\% e2
}
\arguments{
- \item{e1}{An object of class \code{ggplot} or
- \code{theme}}
+\item{e1}{An object of class \code{ggplot} or \code{theme}}
- \item{e2}{A component to add to \code{e1}}
+\item{e2}{A component to add to \code{e1}}
}
\description{
- This operator allows you to add objects to a ggplot or
- theme object.
+This operator allows you to add objects to a ggplot or theme object.
}
\details{
- If the first object is an object of class \code{ggplot},
- you can add the following types of objects, and it will
- return a modified ggplot object.
+If the first object is an object of class \code{ggplot}, you can add
+the following types of objects, and it will return a modified ggplot
+object.
- \itemize{ \item \code{data.frame}: replace current
- data.frame (must use \code{\%+\%}) \item \code{uneval}:
- replace current aesthetics \item \code{layer}: add new
- layer \item \code{theme}: update plot theme \item
- \code{scale}: replace current scale \item \code{coord}:
- override current coordinate system \item \code{facet}:
- override current coordinate faceting }
+\itemize{
+ \item \code{data.frame}: replace current data.frame
+ (must use \code{\%+\%})
+ \item \code{uneval}: replace current aesthetics
+ \item \code{layer}: add new layer
+ \item \code{theme}: update plot theme
+ \item \code{scale}: replace current scale
+ \item \code{coord}: override current coordinate system
+ \item \code{facet}: override current coordinate faceting
+}
- If the first object is an object of class \code{theme},
- you can add another theme object. This will return a
- modified theme object.
+If the first object is an object of class \code{theme}, you can add
+another theme object. This will return a modified theme object.
- For theme objects, the \code{+} operator and the
- \code{\%+replace\%} can be used to modify elements in
- themes.
+For theme objects, the \code{+} operator and the \code{\%+replace\%}
+can be used to modify elements in themes.
- The \code{+} operator completely replaces elements with
- elements from e2.
+The \code{+} operator completely replaces elements
+with elements from e2.
- In contrast, the \code{\%+replace\%} operator does not
- replace the entire element; it only updates element
- properties which are present (not NULL) in the second
- object.
+In contrast, the \code{\%+replace\%} operator does not replace the
+entire element; it only updates element properties which are present
+(not NULL) in the second object.
}
\examples{
### Adding objects to a ggplot object
@@ -71,6 +70,6 @@ add_el$text
rep_el$text
}
\seealso{
- \code{\link{theme}}
+\code{\link{theme}}
}
diff --git a/man/gg_dep.Rd b/man/gg_dep.Rd
index fb71a56..a723c79 100644
--- a/man/gg_dep.Rd
+++ b/man/gg_dep.Rd
@@ -1,38 +1,36 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{gg_dep}
\alias{gg_dep}
\title{Give a deprecation error, warning, or messsage, depending on version number.}
\usage{
- gg_dep(version, msg)
+gg_dep(version, msg)
}
\arguments{
- \item{version}{The last version of ggplot2 where this
- function was good (in other words, the last version where
- it was not deprecated).}
+\item{version}{The last version of ggplot2 where this function was good
+(in other words, the last version where it was not deprecated).}
- \item{msg}{The message to print.}
+\item{msg}{The message to print.}
}
\description{
- Version numbers have the format
- <major>.<minor>.<subminor>, like 0.9.2. This function
- compares the current version number of ggplot2 against
- the specified \code{version}, which is the most recent
- version before the function (or other object) was
- deprecated.
+Version numbers have the format <major>.<minor>.<subminor>, like 0.9.2.
+This function compares the current version number of ggplot2 against the
+specified \code{version}, which is the most recent version before the
+function (or other object) was deprecated.
}
\details{
- \code{gg_dep} will give an error, warning, or message,
- depending on the difference between the current ggplot2
- version and the specified \code{version}.
+\code{gg_dep} will give an error, warning, or message, depending on the
+difference between the current ggplot2 version and the specified
+\code{version}.
- If the current major number is greater than
- \code{version}'s major number, or if the current minor
- number is more than 1 greater than \code{version}'s minor
- number, give an error.
+If the current major number is greater than \code{version}'s major number,
+or if the current minor number is more than 1 greater than \code{version}'s
+minor number, give an error.
- If the current minor number differs from \code{version}'s
- minor number by one, give a warning.
+If the current minor number differs from \code{version}'s minor number by
+one, give a warning.
- If the current subminor number differs from
- \code{version}'s subminor number, print a message.
+If the current subminor number differs from \code{version}'s subminor
+number, print a message.
}
+\keyword{internal}
diff --git a/man/ggfluctuation.Rd b/man/ggfluctuation.Rd
deleted file mode 100644
index 93af3e3..0000000
--- a/man/ggfluctuation.Rd
+++ /dev/null
@@ -1,41 +0,0 @@
-\name{ggfluctuation}
-\alias{ggfluctuation}
-\title{Create a fluctuation plot.}
-\usage{
- ggfluctuation(table, type = "size", floor = 0,
- ceiling = max(table$freq, na.rm = TRUE))
-}
-\arguments{
- \item{table}{a table of values, or a data frame with
- three columns, the last column being frequency}
-
- \item{type}{"size", or "colour" to create traditional
- heatmap}
-
- \item{floor}{don't display cells smaller than this value}
-
- \item{ceiling}{round cells to at most this value}
-
- \item{na.rm}{If \code{TRUE}, silently remove missing
- values.}
-}
-\description{
- A fluctutation diagram is a graphical representation of a
- contingency table. This function only supports 2D
- contingency tables at present but extension to higher
- dimensions should be relatively straightforward.
-}
-\details{
- With the default size fluctuation diagram, area is
- proportional to the count (length of sides proportional
- to sqrt(count)).
-}
-\examples{
-\dontrun{
-ggfluctuation(table(movies$Action, movies$Comedy))
-ggfluctuation(table(movies$Action, movies$mpaa))
-ggfluctuation(table(movies$Action, movies$Comedy), type="colour")
-ggfluctuation(table(warpbreaks$breaks, warpbreaks$tension))
-}
-}
-
diff --git a/man/ggmissing.Rd b/man/ggmissing.Rd
deleted file mode 100644
index faa49e2..0000000
--- a/man/ggmissing.Rd
+++ /dev/null
@@ -1,40 +0,0 @@
-\name{ggmissing}
-\alias{ggmissing}
-\title{Create a plot to illustrate patterns of missing values.}
-\usage{
- ggmissing(data, avoid = "stack", order = TRUE,
- missing.only = TRUE)
-}
-\arguments{
- \item{data}{input data.frame}
-
- \item{avoid}{whether missings should be stacked or
- dodged, see \code{\link{geom_bar}} for more details}
-
- \item{order}{if \code{TRUE}, order variables by number of
- missings}
-
- \item{missing.only}{if \code{TRUE}, only display
- variables with some missing data}
-}
-\description{
- The missing values plot is a useful tool to get a rapid
- overview of the number and pattern of missing values in a
- dataset. Its strength is much more apparent when used
- with interactive graphics, as you can see in Mondrian
- (\url{http://rosuda.org/mondrian}) where this plot was
- copied from.
-}
-\examples{
-\dontrun{
-mmissing <- movies
-mmissing[sample(nrow(movies), 1000), sample(ncol(movies), 5)] <- NA
-ggmissing(mmissing)
-ggmissing(mmissing, order=FALSE, missing.only = FALSE)
-ggmissing(mmissing, avoid="dodge") + scale_y_sqrt()
-}
-}
-\seealso{
- \code{\link{ggstructure}}, \code{\link{ggorder}}
-}
-
diff --git a/man/ggorder.Rd b/man/ggorder.Rd
deleted file mode 100644
index 8543a5e..0000000
--- a/man/ggorder.Rd
+++ /dev/null
@@ -1,14 +0,0 @@
-\name{ggorder}
-\alias{ggorder}
-\title{A plot to investigate the order in which observations were recorded.}
-\usage{
- ggorder(data)
-}
-\arguments{
- \item{data}{data set to plot}
-}
-\description{
- A plot to investigate the order in which observations
- were recorded.
-}
-
diff --git a/man/ggpcp.Rd b/man/ggpcp.Rd
deleted file mode 100644
index 14db6a4..0000000
--- a/man/ggpcp.Rd
+++ /dev/null
@@ -1,39 +0,0 @@
-\name{ggpcp}
-\alias{ggpcp}
-\title{Make a parallel coordinates plot.}
-\usage{
- ggpcp(data, vars = names(data), ...)
-}
-\arguments{
- \item{data}{data frame}
-
- \item{vars}{variables to include in parallel coordinates
- plot}
-
- \item{...}{other arguments passed on plot creation}
-}
-\description{
- One way to think about a parallel coordinates plot, is as
- plotting the data after it has been transformed to gain a
- new variable. This function does this using
- \code{\link[reshape2]{melt}}.
-}
-\details{
- This gives us enormous flexibility as we have separated
- out the type of drawing (lines by tradition) and can now
- use any of the existing geom functions. In particular
- this makes it very easy to create parallel boxplots, as
- shown in the example.
-}
-\examples{
-\dontrun{
-ggpcp(mtcars) + geom_line()
-ggpcp(mtcars, vars=names(mtcars[2:6])) + geom_line()
-ggpcp(mtcars) + geom_boxplot(aes(group=variable))
-
-p <- ggpcp(mtcars, vars=names(mtcars[2:6]))
-p + geom_line()
-p + geom_line(aes(colour=mpg))
-}
-}
-
diff --git a/man/ggplot.Rd b/man/ggplot.Rd
index a64986f..c71aae7 100644
--- a/man/ggplot.Rd
+++ b/man/ggplot.Rd
@@ -1,50 +1,51 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{ggplot}
\alias{ggplot}
\title{Create a new ggplot plot}
\usage{
- ggplot(data = NULL, ...)
+ggplot(data = NULL, ...)
}
\arguments{
- \item{data}{default data set}
+\item{data}{default data set}
- \item{...}{other arguments passed to specific methods}
+\item{...}{other arguments passed to specific methods}
}
\description{
- \code{ggplot()} initializes a ggplot object. It can be
- used to declare the input data frame for a graphic and to
- specify the set of plot aesthetics intended to be common
- throughout all subsequent layers unless specifically
- overridden.
+\code{ggplot()} initializes a ggplot object. It can be used to
+declare the input data frame for a graphic and to specify the
+set of plot aesthetics intended to be common throughout all
+subsequent layers unless specifically overridden.
}
\details{
- \code{ggplot()} is typically used to construct a plot
- incrementally, using the + operator to add layers to the
- existing ggplot object. This is advantageous in that the
- code is explicit about which layers are added and the
- order in which they are added. For complex graphics with
- multiple layers, initialization with \code{ggplot} is
- recommended.
+\code{ggplot()} is typically used to construct a plot
+incrementally, using the + operator to add layers to the
+existing ggplot object. This is advantageous in that the
+code is explicit about which layers are added and the order
+in which they are added. For complex graphics with multiple
+layers, initialization with \code{ggplot} is recommended.
- There are three common ways to invoke \code{ggplot}:
- \itemize{ \item \code{ggplot(df, aes(x, y, <other
- aesthetics>))} \item \code{ggplot(df)} \item
- \code{ggplot()} } The first method is recommended if all
- layers use the same data and the same set of aesthetics,
- although this method can also be used to add a layer
- using data from another data frame. See the first example
- below. The second method specifies the default data frame
- to use for the plot, but no aesthetics are defined up
- front. This is useful when one data frame is used
- predominantly as layers are added, but the aesthetics may
- vary from one layer to another. The third method
- initializes a skeleton \code{ggplot} object which is
- fleshed out as layers are added. This method is useful
- when multiple data frames are used to produce different
- layers, as is often the case in complex graphics.
+There are three common ways to invoke \code{ggplot}:
+\itemize{
+ \item \code{ggplot(df, aes(x, y, <other aesthetics>))}
+ \item \code{ggplot(df)}
+ \item \code{ggplot()}
+ }
+The first method is recommended if all layers use the same
+data and the same set of aesthetics, although this method
+can also be used to add a layer using data from another
+data frame. See the first example below. The second
+method specifies the default data frame to use for the plot,
+but no aesthetics are defined up front. This is useful when
+one data frame is used predominantly as layers are added,
+but the aesthetics may vary from one layer to another. The
+third method initializes a skeleton \code{ggplot} object which
+is fleshed out as layers are added. This method is useful when
+multiple data frames are used to produce different layers, as
+is often the case in complex graphics.
- The examples below illustrate how these methods of
- invoking \code{ggplot} can be used in constructing a
- graphic.
+The examples below illustrate how these methods of
+invoking \code{ggplot} can be used in constructing a
+graphic.
}
\examples{
df <- data.frame(gp = factor(rep(letters[1:3], each = 10)),
@@ -79,7 +80,7 @@ ggplot() +
colour = 'red', width = 0.4)
}
\seealso{
- \url{http://had.co.nz/ggplot2}
+\url{http://had.co.nz/ggplot2}
}
\keyword{internal}
diff --git a/man/ggplot.data.frame.Rd b/man/ggplot.data.frame.Rd
index 65ac1ca..9d75ec6 100644
--- a/man/ggplot.data.frame.Rd
+++ b/man/ggplot.data.frame.Rd
@@ -1,26 +1,25 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{ggplot.data.frame}
\alias{ggplot.data.frame}
\title{Create a new ggplot plot from a data frame}
\usage{
- \method{ggplot}{data.frame} (data, mapping = aes(), ...,
- environment = globalenv())
+\method{ggplot}{data.frame}(data, mapping = aes(), ...,
+ environment = globalenv())
}
\arguments{
- \item{data}{default data frame for plot}
+\item{data}{default data frame for plot}
- \item{mapping}{default list of aesthetic mappings (these
- can be colour, size, shape, line type -- see individual
- geom functions for more details)}
+\item{mapping}{default list of aesthetic mappings (these can be colour,
+size, shape, line type -- see individual geom functions for more details)}
- \item{...}{ignored}
+\item{...}{ignored}
- \item{environment}{in which evaluation of aesthetics
- should occur}
+\item{environment}{in which evaluation of aesthetics should occur}
}
\description{
- Create a new ggplot plot from a data frame
+Create a new ggplot plot from a data frame
}
\seealso{
- \url{http://had.co.nz/ggplot2}
+\url{http://had.co.nz/ggplot2}
}
diff --git a/man/ggplot2.Rd b/man/ggplot2.Rd
index 816f5a3..717c9e4 100644
--- a/man/ggplot2.Rd
+++ b/man/ggplot2.Rd
@@ -1,9 +1,10 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\docType{package}
\name{ggplot2}
\alias{ggplot2}
\alias{ggplot2-package}
\title{ggplot2.}
\description{
- ggplot2.
+ggplot2.
}
diff --git a/man/ggplotGrob.Rd b/man/ggplotGrob.Rd
index a4defb7..8115caf 100644
--- a/man/ggplotGrob.Rd
+++ b/man/ggplotGrob.Rd
@@ -1,14 +1,15 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{ggplotGrob}
\alias{ggplotGrob}
\title{Generate a ggplot2 plot grob.}
\usage{
- ggplotGrob(x)
+ggplotGrob(x)
}
\arguments{
- \item{x}{ggplot2 object}
+\item{x}{ggplot2 object}
}
\description{
- Generate a ggplot2 plot grob.
+Generate a ggplot2 plot grob.
}
\keyword{internal}
diff --git a/man/ggplot_build.Rd b/man/ggplot_build.Rd
index 1bcbed0..60cf508 100644
--- a/man/ggplot_build.Rd
+++ b/man/ggplot_build.Rd
@@ -1,24 +1,23 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{ggplot_build}
\alias{ggplot_build}
\title{Build ggplot for rendering.}
\usage{
- ggplot_build(plot)
+ggplot_build(plot)
}
\arguments{
- \item{plot}{ggplot object}
+\item{plot}{ggplot object}
}
\description{
- This function takes the plot object, and performs all
- steps necessary to produce an object that can be
- rendered. This function outputs two pieces: a list of
- data frames (one for each layer), and a panel object,
- which contain all information about axis limits, breaks
- etc.
+This function takes the plot object, and performs all steps necessary to
+produce an object that can be rendered. This function outputs two pieces:
+a list of data frames (one for each layer), and a panel object, which
+contain all information about axis limits, breaks etc.
}
\seealso{
- \code{\link{print.ggplot}} and \code{link{benchplot}} for
- for functions that contain the complete set of steps for
- generating a ggplot2 plot.
+\code{\link{print.ggplot}} and \code{link{benchplot}} for
+ for functions that contain the complete set of steps for generating
+ a ggplot2 plot.
}
\keyword{internal}
diff --git a/man/ggplot_gtable.Rd b/man/ggplot_gtable.Rd
index c07b7b6..5eda898 100644
--- a/man/ggplot_gtable.Rd
+++ b/man/ggplot_gtable.Rd
@@ -1,31 +1,29 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{ggplot_gtable}
\alias{ggplot_gtable}
\title{Build a plot with all the usual bits and pieces.}
\usage{
- ggplot_gtable(data)
+ggplot_gtable(data)
}
\arguments{
- \item{plot}{plot object}
+\item{plot}{plot object}
- \item{data}{plot data generated by
- \code{\link{ggplot_build}}}
+\item{data}{plot data generated by \code{\link{ggplot_build}}}
}
\value{
- a \code{\link{gtable}} object
+a \code{\link{gtable}} object
}
\description{
- This function builds all grobs necessary for displaying
- the plot, and stores them in a special data structure
- called a \code{\link{gtable}}. This object is amenable to
- programmatic manipulation, should you want to (e.g.) make
- the legend box 2 cm wide, or combine multiple plots into
- a single display, preserving aspect ratios across the
- plots.
+This function builds all grobs necessary for displaying the plot, and
+stores them in a special data structure called a \code{\link{gtable}}.
+This object is amenable to programmatic manipulation, should you want
+to (e.g.) make the legend box 2 cm wide, or combine multiple plots into
+a single display, preserving aspect ratios across the plots.
}
\seealso{
- \code{\link{print.ggplot}} and \code{link{benchplot}} for
- for functions that contain the complete set of steps for
- generating a ggplot2 plot.
+\code{\link{print.ggplot}} and \code{link{benchplot}} for
+ for functions that contain the complete set of steps for generating
+ a ggplot2 plot.
}
\keyword{internal}
diff --git a/man/ggsave.Rd b/man/ggsave.Rd
index 868eea2..ca40ef2 100644
--- a/man/ggsave.Rd
+++ b/man/ggsave.Rd
@@ -1,68 +1,60 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{ggsave}
\alias{ggsave}
\title{Save a ggplot with sensible defaults}
\usage{
- ggsave(filename = default_name(plot), plot = last_plot(),
- device = default_device(filename), path = NULL,
- scale = 1, width = par("din")[1],
- height = par("din")[2], units = c("in", "cm", "mm"),
- dpi = 300, limitsize = TRUE, ...)
+ggsave(filename = default_name(plot), plot = last_plot(),
+ device = default_device(filename), path = NULL, scale = 1,
+ width = par("din")[1], height = par("din")[2], units = c("in", "cm",
+ "mm"), dpi = 300, limitsize = TRUE, ...)
}
\arguments{
- \item{filename}{file name/filename of plot}
+\item{filename}{file name/filename of plot}
- \item{plot}{plot to save, defaults to last plot
- displayed}
+\item{plot}{plot to save, defaults to last plot displayed}
- \item{device}{device to use, automatically extract from
- file name extension}
+\item{device}{device to use, automatically extract from file name extension}
- \item{path}{path to save plot to (if you just want to set
- path and not filename)}
+\item{path}{path to save plot to (if you just want to set path and not
+filename)}
- \item{scale}{scaling factor}
+\item{scale}{scaling factor}
- \item{width}{width (defaults to the width of current
- plotting window)}
+\item{width}{width (defaults to the width of current plotting window)}
- \item{height}{height (defaults to the height of current
- plotting window)}
+\item{height}{height (defaults to the height of current plotting window)}
- \item{units}{units for width and height when either one
- is explicitly specified (in, cm, or mm)}
+\item{units}{units for width and height when either one is explicitly specified (in, cm, or mm)}
- \item{dpi}{dpi to use for raster graphics}
+\item{dpi}{dpi to use for raster graphics}
- \item{limitsize}{when \code{TRUE} (the default),
- \code{ggsave} will not save images larger than 50x50
- inches, to prevent the common error of specifying
- dimensions in pixels.}
+\item{limitsize}{when \code{TRUE} (the default), \code{ggsave} will not
+save images larger than 50x50 inches, to prevent the common error of
+specifying dimensions in pixels.}
- \item{...}{other arguments passed to graphics device}
+\item{...}{other arguments passed to graphics device}
}
\description{
- ggsave is a convenient function for saving a plot. It
- defaults to saving the last plot that you displayed, and
- for a default size uses the size of the current graphics
- device. It also guesses the type of graphics device from
- the extension. This means the only argument you need to
- supply is the filename.
+ggsave is a convenient function for saving a plot. It defaults to
+saving the last plot that you displayed, and for a default size uses
+the size of the current graphics device. It also guesses the type of
+graphics device from the extension. This means the only argument you
+need to supply is the filename.
}
\details{
- \code{ggsave} currently recognises the extensions eps/ps,
- tex (pictex), pdf, jpeg, tiff, png, bmp, svg and wmf
- (windows only).
+\code{ggsave} currently recognises the extensions eps/ps, tex (pictex),
+pdf, jpeg, tiff, png, bmp, svg and wmf (windows only).
}
\examples{
-\donttest{
+\dontrun{
ratings <- qplot(rating, data=movies, geom="histogram")
qplot(length, data=movies, geom="histogram")
-ggsave(file="length-hist.pdf")
-ggsave(file="length-hist.png")
-ggsave(ratings, file="ratings.pdf")
-ggsave(ratings, file="ratings.pdf", width=4, height=4)
+ggsave("length-hist.pdf")
+ggsave("length-hist.png")
+ggsave("ratings.pdf", ratings)
+ggsave("ratings.pdf", ratings, width=4, height=4)
# make twice as big as on screen
-ggsave(ratings, file="ratings.pdf", scale=2)
+ggsave("ratings.pdf", ratings, scale=2)
}
}
diff --git a/man/ggscale.Rd b/man/ggscale.Rd
index 93c1c7e..6f89068 100644
--- a/man/ggscale.Rd
+++ b/man/ggscale.Rd
@@ -1,17 +1,31 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{ggscale}
\alias{ggscale}
\title{Components of a scale:}
\description{
- Guide related: * name * breaks * labels * expand
+Guide related:
}
\details{
- Mapping related: * aesthetic * limits * palette * trans
+\itemize{
+ \item name
+ \item breaks
+ \item labels
+ \item expand
+}
+
+Mapping related:
+\itemize{
+ \item aesthetic
+ \item limits
+ \item palette
+ \item trans
+}
- Scales are an S3 class with a single mutable component
- implemented with a reference class - the range of the
- data. This mutability makes working with scales much
- easier, because it makes it possible to distribute the
- training, without having to worry about collecting all
- the pieces back together again.
+Scales are an S3 class with a single mutable component implemented with
+a reference class - the range of the data. This mutability makes working
+with scales much easier, because it makes it possible to distribute the
+training, without having to worry about collecting all the pieces back
+together again.
}
+\keyword{internal}
diff --git a/man/ggstructure.Rd b/man/ggstructure.Rd
deleted file mode 100644
index 6bc989d..0000000
--- a/man/ggstructure.Rd
+++ /dev/null
@@ -1,19 +0,0 @@
-\name{ggstructure}
-\alias{ggstructure}
-\title{A plot which aims to reveal gross structural anomalies in the data.}
-\usage{
- ggstructure(data)
-}
-\arguments{
- \item{data}{data set to plot}
-}
-\description{
- A plot which aims to reveal gross structural anomalies in
- the data.
-}
-\examples{
-\dontrun{
-ggstructure(mtcars)
-}
-}
-
diff --git a/man/ggtheme.Rd b/man/ggtheme.Rd
new file mode 100644
index 0000000..fa5aadc
--- /dev/null
+++ b/man/ggtheme.Rd
@@ -0,0 +1,77 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
+\name{ggtheme}
+\alias{ggtheme}
+\alias{theme_bw}
+\alias{theme_classic}
+\alias{theme_gray}
+\alias{theme_grey}
+\alias{theme_light}
+\alias{theme_linedraw}
+\alias{theme_minimal}
+\title{ggplot2 themes}
+\usage{
+theme_grey(base_size = 12, base_family = "")
+
+theme_gray(base_size = 12, base_family = "")
+
+theme_bw(base_size = 12, base_family = "")
+
+theme_linedraw(base_size = 12, base_family = "")
+
+theme_light(base_size = 12, base_family = "")
+
+theme_minimal(base_size = 12, base_family = "")
+
+theme_classic(base_size = 12, base_family = "")
+}
+\arguments{
+\item{base_size}{base font size}
+
+\item{base_family}{base font family}
+}
+\description{
+Themes set the general aspect of the plot such as the colour of the
+background, gridlines, the size and colour of fonts.
+}
+\details{
+\describe{
+
+\item{\code{theme_gray}}{
+The signature ggplot2 theme with a grey background and white gridlines,
+designed to put the data forward yet make comparisons easy.}
+
+\item{\code{theme_bw}}{
+The classic dark-on-light ggplot2 theme. May work better for presentations
+displayed with a projector.}
+
+\item{\code{theme_linedraw}}{
+A theme with only black lines of various widths on white backgrounds,
+reminiscent of a line drawings. Serves a purpose similar to \code{theme_bw}.
+Note that this theme has some very thin lines (<< 1 pt) which some journals
+may refuse.}
+
+\item{\code{theme_light}}{
+A theme similar to \code{theme_linedraw} but with light grey lines and axes,
+to direct more attention towards the data.}
+
+\item{\code{theme_minimal}}{
+A minimalistic theme with no background annotations.}
+
+\item{\code{theme_classic}}{
+A classic-looking theme, with x and y axis lines and no gridlines.}
+
+}
+}
+\examples{
+p <- ggplot(mtcars) + geom_point(aes(x = wt, y = mpg,
+ colour=factor(gear))) + facet_wrap(~am)
+
+p
+p + theme_gray()
+p + theme_bw()
+p + theme_linedraw()
+p + theme_light()
+p + theme_minimal()
+p + theme_classic()
+}
+
diff --git a/man/guide_colourbar.Rd b/man/guide_colourbar.Rd
index 5c82884..de279f6 100644
--- a/man/guide_colourbar.Rd
+++ b/man/guide_colourbar.Rd
@@ -1,135 +1,116 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{guide_colourbar}
\alias{guide_colorbar}
\alias{guide_colourbar}
-\title{Contiuous colour bar guide.}
+\title{Continuous colour bar guide.}
\usage{
- guide_colourbar(title = waiver(), title.position = NULL,
- title.theme = NULL, title.hjust = NULL,
- title.vjust = NULL, label = TRUE,
- label.position = NULL, label.theme = NULL,
- label.hjust = NULL, label.vjust = NULL,
- barwidth = NULL, barheight = NULL, nbin = 20,
- raster = TRUE, ticks = TRUE, draw.ulim = TRUE,
- draw.llim = TRUE, direction = NULL,
- default.unit = "line", reverse = FALSE, order = 0, ...)
-
- guide_colorbar(title = waiver(), title.position = NULL,
- title.theme = NULL, title.hjust = NULL,
- title.vjust = NULL, label = TRUE,
- label.position = NULL, label.theme = NULL,
- label.hjust = NULL, label.vjust = NULL,
- barwidth = NULL, barheight = NULL, nbin = 20,
- raster = TRUE, ticks = TRUE, draw.ulim = TRUE,
- draw.llim = TRUE, direction = NULL,
- default.unit = "line", reverse = FALSE, order = 0, ...)
+guide_colourbar(title = waiver(), title.position = NULL,
+ title.theme = NULL, title.hjust = NULL, title.vjust = NULL,
+ label = TRUE, label.position = NULL, label.theme = NULL,
+ label.hjust = NULL, label.vjust = NULL, barwidth = NULL,
+ barheight = NULL, nbin = 20, raster = TRUE, ticks = TRUE,
+ draw.ulim = TRUE, draw.llim = TRUE, direction = NULL,
+ default.unit = "line", reverse = FALSE, order = 0, ...)
+
+guide_colorbar(title = waiver(), title.position = NULL,
+ title.theme = NULL, title.hjust = NULL, title.vjust = NULL,
+ label = TRUE, label.position = NULL, label.theme = NULL,
+ label.hjust = NULL, label.vjust = NULL, barwidth = NULL,
+ barheight = NULL, nbin = 20, raster = TRUE, ticks = TRUE,
+ draw.ulim = TRUE, draw.llim = TRUE, direction = NULL,
+ default.unit = "line", reverse = FALSE, order = 0, ...)
}
\arguments{
- \item{barwidth}{A numeric or a unit object specifying the
- width of the colorbar. Default value is
- \code{legend.key.width} or \code{legend.key.size} in
- \code{\link{theme}} or theme.}
+\item{barwidth}{A numeric or a unit object specifying the width of the
+colorbar. Default value is \code{legend.key.width} or
+\code{legend.key.size} in \code{\link{theme}} or theme.}
- \item{barheight}{A numeric or a unit object specifying
- the height of the colorbar. Default value is
- \code{legend.key.height} or \code{legend.key.size} in
- \code{\link{theme}} or theme.}
+\item{barheight}{A numeric or a unit object specifying the height of the
+colorbar. Default value is \code{legend.key.height} or
+\code{legend.key.size} in \code{\link{theme}} or theme.}
- \item{nbin}{A numeric specifying the number of bins for
- drawing colorbar. A smoother colorbar for a larger
- value.}
+\item{nbin}{A numeric specifying the number of bins for drawing colorbar. A
+smoother colorbar for a larger value.}
- \item{raster}{A logical. If \code{TRUE} then the colorbar
- is rendered as a raster object. If \code{FALSE} then the
- colorbar is rendered as a set of rectangles. Note that
- not all graphics devices are capable of rendering raster
- image.}
+\item{raster}{A logical. If \code{TRUE} then the colorbar is rendered as a
+raster object. If \code{FALSE} then the colorbar is rendered as a set of
+rectangles. Note that not all graphics devices are capable of rendering
+raster image.}
- \item{ticks}{A logical specifying if tick marks on
- colorbar should be visible.}
+\item{ticks}{A logical specifying if tick marks on colorbar should be
+visible.}
- \item{draw.ulim}{A logical specifying if the upper limit
- tick marks should be visible.}
+\item{draw.ulim}{A logical specifying if the upper limit tick marks should
+be visible.}
- \item{draw.llim}{A logical specifying if the lower limit
- tick marks should be visible.}
+\item{draw.llim}{A logical specifying if the lower limit tick marks should
+be visible.}
- \item{direction}{A character string indicating the
- direction of the guide. One of "horizontal" or
- "vertical."}
+\item{direction}{A character string indicating the direction of the guide.
+One of "horizontal" or "vertical."}
- \item{default.unit}{A character string indicating unit
- for \code{barwidth}}
+\item{default.unit}{A character string indicating unit for \code{barwidth}}
- \item{reverse}{logical. If \code{TRUE} the colorbar is
- reversed. By default, the highest value is on the top and
- the lowest value is on the bottom}
+\item{reverse}{logical. If \code{TRUE} the colorbar is reversed. By default,
+the highest value is on the top and the lowest value is on the bottom}
- \item{...}{ignored.}
+\item{...}{ignored.}
- \item{title}{A character string or expression indicating
- a title of guide. If \code{NULL}, the title is not
- shown. By default (\code{\link{waiver}}), the name of the
- scale object or tha name specified in \code{\link{labs}}
- is used for the title.}
+\item{title}{A character string or expression indicating a title of guide.
+If \code{NULL}, the title is not shown. By default
+(\code{\link{waiver}}), the name of the scale object or tha name
+specified in \code{\link{labs}} is used for the title.}
- \item{title.position}{A character string indicating the
- position of a title. One of "top" (default for a vertical
- guide), "bottom", "left" (default for a horizontal
- guide), or "right."}
+\item{title.position}{A character string indicating the position of a
+ title. One of "top" (default for a vertical guide), "bottom", "left"
+(default for a horizontal guide), or "right."}
- \item{title.theme}{A theme object for rendering the title
- text. Usually the object of \code{\link{element_text}} is
- expected. By default, the theme is specified by
- \code{legend.title} in \code{\link{theme}} or theme.}
+\item{title.theme}{A theme object for rendering the title text. Usually the
+object of \code{\link{element_text}} is expected. By default, the theme is
+specified by \code{legend.title} in \code{\link{theme}} or theme.}
- \item{title.hjust}{A number specifying horizontal
- justification of the title text.}
+\item{title.hjust}{A number specifying horizontal justification of the
+title text.}
- \item{title.vjust}{A number specifying vertical
- justification of the title text.}
+\item{title.vjust}{A number specifying vertical justification of the title
+text.}
- \item{label}{logical. If \code{TRUE} then the labels are
- drawn. If \code{FALSE} then the labels are invisible.}
+\item{label}{logical. If \code{TRUE} then the labels are drawn. If
+\code{FALSE} then the labels are invisible.}
- \item{label.position}{A character string indicating the
- position of a label. One of "top", "bottom" (default for
- horizontal guide), "left", or "right" (default for
- vertical gudie).}
+\item{label.position}{A character string indicating the position of a
+label. One of "top", "bottom" (default for horizontal guide), "left", or
+"right" (default for vertical gudie).}
- \item{label.theme}{A theme object for rendering the label
- text. Usually the object of \code{\link{element_text}} is
- expected. By default, the theme is specified by
- \code{legend.text} in \code{\link{theme}} or theme.}
+\item{label.theme}{A theme object for rendering the label text. Usually the
+object of \code{\link{element_text}} is expected. By default, the theme is
+specified by \code{legend.text} in \code{\link{theme}} or theme.}
- \item{label.hjust}{A numeric specifying horizontal
- justification of the label text.}
+\item{label.hjust}{A numeric specifying horizontal justification of the
+label text.}
- \item{label.vjust}{A numeric specifying vertical
- justification of the label text.}
+\item{label.vjust}{A numeric specifying vertical justification of the label
+text.}
- \item{order}{positive integer less that 99 that specify
- the order of this guide in the multiple guides. If 0
- (default), the order is determined by a secret
- algorithm.}
+\item{order}{positive integer less that 99 that specify the order of
+this guide in the multiple guides. If 0 (default), the order is determined
+by a secret algorithm.}
}
\value{
- A guide object
+A guide object
}
\description{
- Colour bar guide shows continuous color scales mapped
- onto values. Colour bar is available with
- \code{scale_fill} and \code{scale_colour}. For more
- information, see the inspiration for this function:
- \href{http://www.mathworks.com/help/techdoc/ref/colorbar.html}{Matlab's
- colorbar function}.
+Colour bar guide shows continuous color scales mapped onto values.
+Colour bar is available with \code{scale_fill} and \code{scale_colour}.
+For more information, see the inspiration for this function:
+\href{http://www.mathworks.com/help/techdoc/ref/colorbar.html}{Matlab's colorbar function}.
}
\details{
- Guides can be specified in each scale or in
- \code{\link{guides}}. \code{guide="legend"} in scale is
- syntax sugar for \code{guide=guide_legend()} - but the
- second form allows you to specify more options. As for
- how to specify the guide for each scales, see
- \code{\link{guides}}.
+Guides can be specified in each scale or in \code{\link{guides}}.
+\code{guide="legend"} in scale is syntax sugar for
+\code{guide=guide_legend()} - but the second form allows you to specify
+more options. As for how to specify the guide for each
+scales, see \code{\link{guides}}.
}
\examples{
library(reshape2) # for melt
@@ -181,7 +162,7 @@ p2 +
scale_size(guide = guide_legend(direction = "vertical"))
}
\seealso{
- Other guides: \code{\link{guide_legend}},
+Other guides: \code{\link{guide_legend}};
\code{\link{guides}}
}
diff --git a/man/guide_legend.Rd b/man/guide_legend.Rd
index af9b264..7bd5868 100644
--- a/man/guide_legend.Rd
+++ b/man/guide_legend.Rd
@@ -1,111 +1,97 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{guide_legend}
\alias{guide_legend}
\title{Legend guide.}
\usage{
- guide_legend(title = waiver(), title.position = NULL,
- title.theme = NULL, title.hjust = NULL,
- title.vjust = NULL, label = TRUE,
- label.position = NULL, label.theme = NULL,
- label.hjust = NULL, label.vjust = NULL,
- keywidth = NULL, keyheight = NULL, direction = NULL,
- default.unit = "line", override.aes = list(),
- nrow = NULL, ncol = NULL, byrow = FALSE,
- reverse = FALSE, order = 0, ...)
+guide_legend(title = waiver(), title.position = NULL, title.theme = NULL,
+ title.hjust = NULL, title.vjust = NULL, label = TRUE,
+ label.position = NULL, label.theme = NULL, label.hjust = NULL,
+ label.vjust = NULL, keywidth = NULL, keyheight = NULL,
+ direction = NULL, default.unit = "line", override.aes = list(),
+ nrow = NULL, ncol = NULL, byrow = FALSE, reverse = FALSE, order = 0,
+ ...)
}
\arguments{
- \item{title}{A character string or expression indicating
- a title of guide. If \code{NULL}, the title is not
- shown. By default (\code{\link{waiver}}), the name of the
- scale object or tha name specified in \code{\link{labs}}
- is used for the title.}
+\item{title}{A character string or expression indicating a title of guide.
+If \code{NULL}, the title is not shown. By default
+(\code{\link{waiver}}), the name of the scale object or tha name
+specified in \code{\link{labs}} is used for the title.}
- \item{title.position}{A character string indicating the
- position of a title. One of "top" (default for a vertical
- guide), "bottom", "left" (default for a horizontal
- guide), or "right."}
+\item{title.position}{A character string indicating the position of a
+ title. One of "top" (default for a vertical guide), "bottom", "left"
+(default for a horizontal guide), or "right."}
- \item{title.theme}{A theme object for rendering the title
- text. Usually the object of \code{\link{element_text}} is
- expected. By default, the theme is specified by
- \code{legend.title} in \code{\link{theme}} or theme.}
+\item{title.theme}{A theme object for rendering the title text. Usually the
+object of \code{\link{element_text}} is expected. By default, the theme is
+specified by \code{legend.title} in \code{\link{theme}} or theme.}
- \item{title.hjust}{A number specifying horizontal
- justification of the title text.}
+\item{title.hjust}{A number specifying horizontal justification of the
+title text.}
- \item{title.vjust}{A number specifying vertical
- justification of the title text.}
+\item{title.vjust}{A number specifying vertical justification of the title
+text.}
- \item{label}{logical. If \code{TRUE} then the labels are
- drawn. If \code{FALSE} then the labels are invisible.}
+\item{label}{logical. If \code{TRUE} then the labels are drawn. If
+\code{FALSE} then the labels are invisible.}
- \item{label.position}{A character string indicating the
- position of a label. One of "top", "bottom" (default for
- horizontal guide), "left", or "right" (default for
- vertical gudie).}
+\item{label.position}{A character string indicating the position of a
+label. One of "top", "bottom" (default for horizontal guide), "left", or
+"right" (default for vertical gudie).}
- \item{label.theme}{A theme object for rendering the label
- text. Usually the object of \code{\link{element_text}} is
- expected. By default, the theme is specified by
- \code{legend.text} in \code{\link{theme}} or theme.}
+\item{label.theme}{A theme object for rendering the label text. Usually the
+object of \code{\link{element_text}} is expected. By default, the theme is
+specified by \code{legend.text} in \code{\link{theme}} or theme.}
- \item{label.hjust}{A numeric specifying horizontal
- justification of the label text.}
+\item{label.hjust}{A numeric specifying horizontal justification of the
+label text.}
- \item{label.vjust}{A numeric specifying vertical
- justification of the label text.}
+\item{label.vjust}{A numeric specifying vertical justification of the label
+text.}
- \item{keywidth}{A numeric or a unit object specifying the
- width of the legend key. Default value is
- \code{legend.key.width} or \code{legend.key.size} in
- \code{\link{theme}} or theme.}
+\item{keywidth}{A numeric or a unit object specifying the width of the
+legend key. Default value is \code{legend.key.width} or
+\code{legend.key.size} in \code{\link{theme}} or theme.}
- \item{keyheight}{A numeric or a unit object specifying
- the height of the legend key. Default value is
- \code{legend.key.height} or \code{legend.key.size} in
- \code{\link{theme}} or theme.}
+\item{keyheight}{A numeric or a unit object specifying the height of the
+legend key. Default value is \code{legend.key.height} or
+\code{legend.key.size} in \code{\link{theme}} or theme.}
- \item{direction}{A character string indicating the
- direction of the guide. One of "horizontal" or
- "vertical."}
+\item{direction}{A character string indicating the direction of the guide.
+One of "horizontal" or "vertical."}
- \item{default.unit}{A character string indicating unit
- for \code{keywidth} and \code{keyheight}.}
+\item{default.unit}{A character string indicating unit for \code{keywidth}
+and \code{keyheight}.}
- \item{override.aes}{A list specifying aesthetic
- parameters of legend key. See details and examples.}
+\item{override.aes}{A list specifying aesthetic parameters of legend key.
+See details and examples.}
- \item{nrow}{The desired number of rows of legends.}
+\item{nrow}{The desired number of rows of legends.}
- \item{ncol}{The desired number of column of legends.}
+\item{ncol}{The desired number of column of legends.}
- \item{byrow}{logical. If \code{FALSE} (the default) the
- legend-matrix is filled by columns, otherwise the
- legend-matrix is filled by rows.}
+\item{byrow}{logical. If \code{FALSE} (the default) the legend-matrix is
+filled by columns, otherwise the legend-matrix is filled by rows.}
- \item{reverse}{logical. If \code{TRUE} the order of
- legends is reversed.}
+\item{reverse}{logical. If \code{TRUE} the order of legends is reversed.}
- \item{order}{positive integer less that 99 that specify
- the order of this guide in the multiple guides. If 0
- (default), the order is determined by a secret
- algorithm.}
+\item{order}{positive integer less that 99 that specify the order of
+this guide in the multiple guides. If 0 (default), the order is determined
+by a secret algorithm.}
- \item{...}{ignored.}
+\item{...}{ignored.}
}
\value{
- A guide object
+A guide object
}
\description{
- Legend type guide shows key (i.e., geoms) mapped onto
- values. Legend guides for various scales are integrated
- if possible.
+Legend type guide shows key (i.e., geoms) mapped onto values.
+Legend guides for various scales are integrated if possible.
}
\details{
- Guides can be specified in each scale or in
- \code{\link{guides}}. \code{guide="legend"} in scale is
- syntactic sugar for \code{guide=guide_legend()}. As for
- how to specify the guide for each scales in more detail,
- see \code{\link{guides}}.
+Guides can be specified in each scale or in \code{\link{guides}}.
+\code{guide="legend"} in scale is syntactic sugar for
+\code{guide=guide_legend()}. As for how to specify the guide for each
+scales in more detail, see \code{\link{guides}}.
}
\examples{
\donttest{
@@ -169,7 +155,7 @@ p + guides(col = guide_legend(reverse = TRUE))
}
}
\seealso{
- Other guides: \code{\link{guide_colorbar}},
- \code{\link{guide_colourbar}}, \code{\link{guides}}
+Other guides: \code{\link{guide_colorbar}},
+ \code{\link{guide_colourbar}}; \code{\link{guides}}
}
diff --git a/man/guides.Rd b/man/guides.Rd
index 3f43a4f..50ed6b9 100644
--- a/man/guides.Rd
+++ b/man/guides.Rd
@@ -1,19 +1,19 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{guides}
\alias{guides}
\title{Set guides for each scale.}
\usage{
- guides(...)
+guides(...)
}
\arguments{
- \item{...}{List of scale guide pairs}
+\item{...}{List of scale guide pairs}
}
\value{
- A list containing the mapping between scale and guide.
+A list containing the mapping between scale and guide.
}
\description{
- Guides for each scale can be set in call of
- \code{scale_*} with argument \code{guide}, or in
- \code{guides}.
+Guides for each scale can be set in call of \code{scale_*} with argument
+\code{guide}, or in \code{guides}.
}
\examples{
\donttest{
@@ -60,7 +60,7 @@ qplot(data = mpg, x = displ, y = cty, size = hwy, colour = cyl, shape = drv) +
}
}
\seealso{
- Other guides: \code{\link{guide_colorbar}},
- \code{\link{guide_colourbar}}, \code{\link{guide_legend}}
+Other guides: \code{\link{guide_colorbar}},
+ \code{\link{guide_colourbar}}; \code{\link{guide_legend}}
}
diff --git a/man/hmisc.Rd b/man/hmisc.Rd
index 87e54eb..c01898c 100644
--- a/man/hmisc.Rd
+++ b/man/hmisc.Rd
@@ -1,3 +1,4 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{hmisc}
\alias{hmisc}
\alias{mean_cl_boot}
@@ -7,27 +8,25 @@
\title{Wrap up a selection of summary functions from Hmisc to make it easy to use
with \code{\link{stat_summary}}.}
\usage{
- mean_cl_boot(x, ...)
+mean_cl_boot(x, ...)
- mean_cl_normal(x, ...)
+mean_cl_normal(x, ...)
- mean_sdl(x, ...)
+mean_sdl(x, ...)
- median_hilow(x, ...)
+median_hilow(x, ...)
}
\arguments{
- \item{x}{a numeric vector}
+\item{x}{a numeric vector}
- \item{...}{other arguments passed on to the respective
- Hmisc function.}
+\item{...}{other arguments passed on to the respective Hmisc function.}
}
\description{
- See the Hmisc documentation for details of their options.
+See the Hmisc documentation for details of their options.
}
\seealso{
- \code{\link[Hmisc]{smean.cl.boot}},
- \code{\link[Hmisc]{smean.cl.normal}},
- \code{\link[Hmisc]{smean.sdl}},
- \code{\link[Hmisc]{smedian.hilow}}
+\code{\link[Hmisc]{smean.cl.boot}},
+ \code{\link[Hmisc]{smean.cl.normal}}, \code{\link[Hmisc]{smean.sdl}},
+ \code{\link[Hmisc]{smedian.hilow}}
}
diff --git a/man/interleave.Rd b/man/interleave.Rd
index 7790ad4..76566c5 100644
--- a/man/interleave.Rd
+++ b/man/interleave.Rd
@@ -1,15 +1,15 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{interleave}
\alias{interleave}
\title{Interleave (or zip) multiple vectors into a single vector.}
\usage{
- interleave(...)
+interleave(...)
}
\arguments{
- \item{...}{vectors to interleave}
+\item{...}{vectors to interleave}
}
\description{
- Interleave (or zip) multiple vectors into a single
- vector.
+Interleave (or zip) multiple vectors into a single vector.
}
\keyword{internal}
diff --git a/man/is.coord.Rd b/man/is.coord.Rd
index d2feedd..cea179f 100644
--- a/man/is.coord.Rd
+++ b/man/is.coord.Rd
@@ -1,11 +1,12 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{is.coord}
\alias{is.coord}
\title{Is this object a coordinate system?}
\usage{
- is.coord(x)
+is.coord(x)
}
\description{
- Is this object a coordinate system?
+Is this object a coordinate system?
}
\keyword{internal}
diff --git a/man/is.facet.Rd b/man/is.facet.Rd
index cf33fff..40a4a35 100644
--- a/man/is.facet.Rd
+++ b/man/is.facet.Rd
@@ -1,14 +1,15 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{is.facet}
\alias{is.facet}
\title{Is this object a facetting specification?}
\usage{
- is.facet(x)
+is.facet(x)
}
\arguments{
- \item{x}{object to test}
+\item{x}{object to test}
}
\description{
- Is this object a facetting specification?
+Is this object a facetting specification?
}
\keyword{internal}
diff --git a/man/is.ggplot.Rd b/man/is.ggplot.Rd
index 5972bf1..4d69134 100644
--- a/man/is.ggplot.Rd
+++ b/man/is.ggplot.Rd
@@ -1,13 +1,14 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{is.ggplot}
\alias{is.ggplot}
\title{Reports whether x is a ggplot object}
\usage{
- is.ggplot(x)
+is.ggplot(x)
}
\arguments{
- \item{x}{An object to test}
+\item{x}{An object to test}
}
\description{
- Reports whether x is a ggplot object
+Reports whether x is a ggplot object
}
diff --git a/man/is.rel.Rd b/man/is.rel.Rd
index 28fe2cc..144cac7 100644
--- a/man/is.rel.Rd
+++ b/man/is.rel.Rd
@@ -1,13 +1,14 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{is.rel}
\alias{is.rel}
\title{Reports whether x is a rel object}
\usage{
- is.rel(x)
+is.rel(x)
}
\arguments{
- \item{x}{An object to test}
+\item{x}{An object to test}
}
\description{
- Reports whether x is a rel object
+Reports whether x is a rel object
}
diff --git a/man/is.theme.Rd b/man/is.theme.Rd
index 3e2afeb..9182264 100644
--- a/man/is.theme.Rd
+++ b/man/is.theme.Rd
@@ -1,13 +1,14 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{is.theme}
\alias{is.theme}
\title{Reports whether x is a theme object}
\usage{
- is.theme(x)
+is.theme(x)
}
\arguments{
- \item{x}{An object to test}
+\item{x}{An object to test}
}
\description{
- Reports whether x is a theme object
+Reports whether x is a theme object
}
diff --git a/man/label_both.Rd b/man/label_both.Rd
index 1e29c55..e822931 100644
--- a/man/label_both.Rd
+++ b/man/label_both.Rd
@@ -1,16 +1,17 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{label_both}
\alias{label_both}
\title{Label facets with value and variable.}
\usage{
- label_both(variable, value)
+label_both(variable, value)
}
\arguments{
- \item{variable}{variable name passed in by facetter}
+\item{variable}{variable name passed in by facetter}
- \item{value}{variable value passed in by facetter}
+\item{value}{variable value passed in by facetter}
}
\description{
- Label facets with value and variable.
+Label facets with value and variable.
}
\examples{
p <- qplot(wt, mpg, data = mtcars)
@@ -18,7 +19,7 @@ p + facet_grid(. ~ cyl)
p + facet_grid(. ~ cyl, labeller = label_both)
}
\seealso{
- Other facet labellers: \code{\link{label_bquote}},
- \code{\link{label_parsed}}, \code{\link{label_value}}
+Other facet labellers: \code{\link{label_bquote}};
+ \code{\link{label_parsed}}; \code{\link{label_value}}
}
diff --git a/man/label_bquote.Rd b/man/label_bquote.Rd
index f0cdc3c..159dac7 100644
--- a/man/label_bquote.Rd
+++ b/man/label_bquote.Rd
@@ -1,15 +1,16 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{label_bquote}
\alias{label_bquote}
\title{Label facet with 'bquoted' expressions}
\usage{
- label_bquote(expr = beta^.(x))
+label_bquote(expr = beta^.(x))
}
\arguments{
- \item{expr}{labelling expression to use}
+\item{expr}{labelling expression to use}
}
\description{
- See \code{\link{bquote}} for details on the syntax of the
- argument. The label value is x.
+See \code{\link{bquote}} for details on the syntax of the argument. The
+label value is x.
}
\examples{
p <- qplot(wt, mpg, data = mtcars)
@@ -17,9 +18,9 @@ p + facet_grid(. ~ vs, labeller = label_bquote(alpha ^ .(x)))
p + facet_grid(. ~ vs, labeller = label_bquote(.(x) ^ .(x)))
}
\seealso{
- \code{\link{plotmath}}
+\code{\link{plotmath}}
- Other facet labellers: \code{\link{label_both}},
- \code{\link{label_parsed}}, \code{\link{label_value}}
+Other facet labellers: \code{\link{label_both}};
+ \code{\link{label_parsed}}; \code{\link{label_value}}
}
diff --git a/man/label_parsed.Rd b/man/label_parsed.Rd
index b267bc7..4803a3d 100644
--- a/man/label_parsed.Rd
+++ b/man/label_parsed.Rd
@@ -1,16 +1,17 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{label_parsed}
\alias{label_parsed}
\title{Label facets with parsed label.}
\usage{
- label_parsed(variable, value)
+label_parsed(variable, value)
}
\arguments{
- \item{variable}{variable name passed in by facetter}
+\item{variable}{variable name passed in by facetter}
- \item{value}{variable value passed in by facetter}
+\item{value}{variable value passed in by facetter}
}
\description{
- Label facets with parsed label.
+Label facets with parsed label.
}
\examples{
mtcars$cyl2 <- factor(mtcars$cyl, labels = c("alpha", "beta", "gamma"))
@@ -19,9 +20,9 @@ qplot(wt, mpg, data = mtcars) + facet_grid(. ~ cyl2,
labeller = label_parsed)
}
\seealso{
- \code{\link{plotmath}}
+\code{\link{plotmath}}
- Other facet labellers: \code{\link{label_both}},
- \code{\link{label_bquote}}, \code{\link{label_value}}
+Other facet labellers: \code{\link{label_both}};
+ \code{\link{label_bquote}}; \code{\link{label_value}}
}
diff --git a/man/label_value.Rd b/man/label_value.Rd
index 49257a1..d37859d 100644
--- a/man/label_value.Rd
+++ b/man/label_value.Rd
@@ -1,18 +1,19 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{label_value}
\alias{label_value}
\title{Label facets with their value.
This is the default labelling scheme.}
\usage{
- label_value(variable, value)
+label_value(variable, value)
}
\arguments{
- \item{variable}{variable name passed in by facetter}
+\item{variable}{variable name passed in by facetter}
- \item{value}{variable value passed in by facetter}
+\item{value}{variable value passed in by facetter}
}
\description{
- Label facets with their value. This is the default
- labelling scheme.
+Label facets with their value.
+This is the default labelling scheme.
}
\examples{
p <- qplot(wt, mpg, data = mtcars)
@@ -20,7 +21,7 @@ p + facet_grid(. ~ cyl)
p + facet_grid(. ~ cyl, labeller = label_value)
}
\seealso{
- Other facet labellers: \code{\link{label_both}},
- \code{\link{label_bquote}}, \code{\link{label_parsed}}
+Other facet labellers: \code{\link{label_both}};
+ \code{\link{label_bquote}}; \code{\link{label_parsed}}
}
diff --git a/man/label_wrap_gen.Rd b/man/label_wrap_gen.Rd
new file mode 100644
index 0000000..ffaf21a
--- /dev/null
+++ b/man/label_wrap_gen.Rd
@@ -0,0 +1,17 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
+\name{label_wrap_gen}
+\alias{label_wrap_gen}
+\title{Label facets with a word wrapped label.}
+\usage{
+label_wrap_gen(width = 25)
+}
+\arguments{
+\item{width}{integer, target column width for output.}
+}
+\description{
+Uses \code{\link[base]{strwrap}} for line wrapping.
+}
+\seealso{
+, \code{\link{labeller}}
+}
+
diff --git a/man/labeller.Rd b/man/labeller.Rd
new file mode 100644
index 0000000..6ce524e
--- /dev/null
+++ b/man/labeller.Rd
@@ -0,0 +1,74 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
+\name{labeller}
+\alias{labeller}
+\title{Generic labeller function for facets}
+\usage{
+labeller(..., keep.as.numeric = FALSE)
+}
+\arguments{
+\item{...}{Named arguments of the form \code{variable=values},
+where \code{values} could be a vector or method.}
+
+\item{keep.as.numeric}{logical, default TRUE. When FALSE, converts numeric
+values supplied as margins to the facet to characters.}
+}
+\value{
+Function to supply to
+ \code{\link{facet_grid}} for the argument \code{labeller}.
+}
+\description{
+One-step function for providing methods or named character vectors
+for displaying labels in facets.
+}
+\details{
+The provided methods are checked for number of arguments.
+If the provided method takes less than two
+(e.g. \code{\link[Hmisc]{capitalize}}),
+the method is passed \code{values}.
+Else (e.g. \code{\link{label_both}}),
+it is passed \code{variable} and \code{values} (in that order).
+If you want to be certain, use e.g. an anonymous function.
+If errors are returned such as ``argument ".." is missing, with no default''
+or ``unused argument (variable)'', matching the method's arguments does not
+work as expected; make a wrapper function.
+}
+\examples{
+\donttest{
+p1 <- ggplot(mpg, aes(cty, hwy)) + geom_point()
+p1 + facet_grid(cyl ~ class, labeller=label_both)
+p1 + facet_grid(cyl ~ class, labeller=labeller(cyl=label_both))
+
+ggplot(mtcars, aes(x = mpg, y = wt)) + geom_point() +
+ facet_grid(vs + am ~ gear, margins=TRUE,
+ labeller=labeller(vs=label_both, am=label_both))
+
+capitalize <- function(string) {
+ substr(string, 1, 1) <- toupper(substr(string, 1, 1))
+ string
+}
+conservation_status <- c('cd'='Conservation Dependent',
+ 'en'='Endangered',
+ 'lc'='Least concern',
+ 'nt'='Near Threatened',
+ 'vu'='Vulnerable',
+ 'domesticated'='Domesticated')
+## Source: http://en.wikipedia.org/wiki/Wikipedia:Conservation_status
+
+p2 <- ggplot(msleep, aes(x=sleep_total, y=awake)) + geom_point()
+p2 + facet_grid(vore ~ conservation, labeller = labeller(vore = capitalize))
+
+p2 + facet_grid(vore ~ conservation,
+ labeller=labeller(vore = capitalize, conservation = conservation_status ))
+
+# We could of course have renamed the levels;
+# then we can apply another nifty function
+msleep$conservation2 <- plyr::revalue(msleep$conservation, conservation_status)
+
+p2 \%+\% msleep +
+ facet_grid(vore ~ conservation2, labeller = labeller(vore = capitalize))
+p2 \%+\% msleep +
+ facet_grid(vore ~ conservation2, labeller = labeller(conservation2 =
+ label_wrap_gen(10)))
+}
+}
+
diff --git a/man/labs.Rd b/man/labs.Rd
index d66373f..52b055d 100644
--- a/man/labs.Rd
+++ b/man/labs.Rd
@@ -1,3 +1,4 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{labs}
\alias{ggtitle}
\alias{labs}
@@ -5,22 +6,21 @@
\alias{ylab}
\title{Change axis labels and legend titles}
\usage{
- labs(...)
+labs(...)
- xlab(label)
+xlab(label)
- ylab(label)
+ylab(label)
- ggtitle(label)
+ggtitle(label)
}
\arguments{
- \item{label}{The text for the axis or plot title.}
+\item{label}{The text for the axis or plot title.}
- \item{...}{a list of new names in the form aesthetic =
- "new name"}
+\item{...}{a list of new names in the form aesthetic = "new name"}
}
\description{
- Change axis labels and legend titles
+Change axis labels and legend titles
}
\examples{
p <- qplot(mpg, wt, data = mtcars)
diff --git a/man/last_plot.Rd b/man/last_plot.Rd
index 3f8c280..994cbee 100644
--- a/man/last_plot.Rd
+++ b/man/last_plot.Rd
@@ -1,13 +1,14 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{last_plot}
\alias{last_plot}
\title{Retrieve the last plot to be modified or created.}
\usage{
- last_plot()
+last_plot()
}
\description{
- Retrieve the last plot to be modified or created.
+Retrieve the last plot to be modified or created.
}
\seealso{
- \code{\link{ggsave}}
+\code{\link{ggsave}}
}
diff --git a/man/layer.Rd b/man/layer.Rd
index e63c155..4d50c70 100644
--- a/man/layer.Rd
+++ b/man/layer.Rd
@@ -1,11 +1,12 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{layer}
\alias{layer}
\title{Create a new layer}
\usage{
- layer(...)
+layer(...)
}
\description{
- Create a new layer
+Create a new layer
}
\keyword{internal}
diff --git a/man/limits.Rd b/man/limits.Rd
index d62dfde..60c8020 100644
--- a/man/limits.Rd
+++ b/man/limits.Rd
@@ -1,16 +1,17 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{limits}
\alias{limits}
\title{Generate correct scale type for specified limits}
\usage{
- limits(lims, var)
+limits(lims, var)
}
\arguments{
- \item{limts}{vector of limits}
+\item{limts}{vector of limits}
- \item{var}{name of variable}
+\item{var}{name of variable}
}
\description{
- Generate correct scale type for specified limits
+Generate correct scale type for specified limits
}
\examples{
ggplot2:::limits(c(1, 5), "x")
diff --git a/man/map_data.Rd b/man/map_data.Rd
index 12d3cf5..4029878 100644
--- a/man/map_data.Rd
+++ b/man/map_data.Rd
@@ -1,30 +1,28 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{map_data}
\alias{map_data}
\title{Create a data frame of map data.}
\usage{
- map_data(map, region = ".", exact = FALSE, ...)
+map_data(map, region = ".", exact = FALSE, ...)
}
\arguments{
- \item{map}{name of map provided by the \pkg{maps}
- package. These include \code{\link[maps]{county}},
- \code{\link[maps]{france}}, \code{\link[maps]{italy}},
- \code{\link[maps]{nz}}, \code{\link[maps]{state}},
- \code{\link[maps]{usa}}, \code{\link[maps]{world}},
- \code{\link[maps]{world2}}.}
+\item{map}{name of map provided by the \pkg{maps} package. These
+include \code{\link[maps]{county}}, \code{\link[maps]{france}},
+\code{\link[maps]{italy}}, \code{\link[maps]{nz}},
+\code{\link[maps]{state}}, \code{\link[maps]{usa}},
+\code{\link[maps]{world}}, \code{\link[maps]{world2}}.}
- \item{region}{name of subregions to include. Defaults to
- \code{.} which includes all subregion. See documentation
- for \code{\link[maps]{map}} for more details.}
+\item{region}{name of subregions to include. Defaults to \code{.} which
+includes all subregion. See documentation for \code{\link[maps]{map}}
+for more details.}
- \item{exact}{should the \code{region} be treated as a
- regular expression (\code{FALSE}) or as a fixed string
- (\code{TRUE}).}
+\item{exact}{should the \code{region} be treated as a regular expression
+(\code{FALSE}) or as a fixed string (\code{TRUE}).}
- \item{...}{all other arguments passed on to
- \code{\link[maps]{map}}}
+\item{...}{all other arguments passed on to \code{\link[maps]{map}}}
}
\description{
- Create a data frame of map data.
+Create a data frame of map data.
}
\examples{
if (require("maps")) {
diff --git a/man/mean_se.Rd b/man/mean_se.Rd
index 8a66828..b89c54f 100644
--- a/man/mean_se.Rd
+++ b/man/mean_se.Rd
@@ -1,18 +1,19 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{mean_se}
\alias{mean_se}
\title{Calculate mean and standard errors on either side.}
\usage{
- mean_se(x, mult = 1)
+mean_se(x, mult = 1)
}
\arguments{
- \item{x}{numeric vector}
+\item{x}{numeric vector}
- \item{mult}{number of multiples of standard error}
+\item{mult}{number of multiples of standard error}
}
\description{
- Calculate mean and standard errors on either side.
+Calculate mean and standard errors on either side.
}
\seealso{
- for use with \code{\link{stat_summary}}
+for use with \code{\link{stat_summary}}
}
diff --git a/man/midwest.Rd b/man/midwest.Rd
index 3cacf91..b872756 100644
--- a/man/midwest.Rd
+++ b/man/midwest.Rd
@@ -1,30 +1,48 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\docType{data}
\name{midwest}
\alias{midwest}
\title{Midwest demographics.}
\format{A data frame with 437 rows and 28 variables}
+\usage{
+data(midwest)
+}
\description{
- Demographic information of midwest counties
+Demographic information of midwest counties
}
\details{
- The variables are as follows:
+The variables are as follows:
- \itemize{ \item PID \item county \item state \item area
- \item poptotal. Total population \item popdensity.
- Population density \item popwhite. Number of whites.
- \item popblack. Number of blacks. \item popamerindian.
- Number of American Indians. \item popasian. Number of
- Asians. \item popother. Number of other races. \item
- percwhite. Percent white. \item percblack. Percent
- black. \item percamerindan. Percent American Indian.
- \item percasian. Percent Asian. \item percother. Percent
- other races. \item popadults. Number of adults. \item
- perchsd. \item percollege. Percent college educated.
- \item percprof. Percent profession. \item
- poppovertyknown. \item percpovertyknown \item
- percbelowpoverty \item percchildbelowpovert \item
- percadultpoverty \item percelderlypoverty \item inmetro.
- In a metro area. \item category' }
+\itemize{
+ \item PID
+ \item county
+ \item state
+ \item area
+ \item poptotal. Total population
+ \item popdensity. Population density
+ \item popwhite. Number of whites.
+ \item popblack. Number of blacks.
+ \item popamerindian. Number of American Indians.
+ \item popasian. Number of Asians.
+ \item popother. Number of other races.
+ \item percwhite. Percent white.
+ \item percblack. Percent black.
+ \item percamerindan. Percent American Indian.
+ \item percasian. Percent Asian.
+ \item percother. Percent other races.
+ \item popadults. Number of adults.
+ \item perchsd.
+ \item percollege. Percent college educated.
+ \item percprof. Percent profession.
+ \item poppovertyknown.
+ \item percpovertyknown
+ \item percbelowpoverty
+ \item percchildbelowpovert
+ \item percadultpoverty
+ \item percelderlypoverty
+ \item inmetro. In a metro area.
+ \item category'
+}
}
\keyword{datasets}
diff --git a/man/movies.Rd b/man/movies.Rd
index d2a451a..b5049ff 100644
--- a/man/movies.Rd
+++ b/man/movies.Rd
@@ -1,37 +1,38 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\docType{data}
\name{movies}
\alias{movies}
\title{Movie information and user ratings from IMDB.com.}
\format{A data frame with 28819 rows and 24 variables}
+\usage{
+data(movies)
+}
\description{
- The internet movie database, \url{http://imdb.com/}, is a
- website devoted to collecting movie data supplied by
- studios and fans. It claims to be the biggest movie
- database on the web and is run by amazon. More about
- information imdb.com can be found online,
- \url{http://imdb.com/help/show_leaf?about}, including
- information about the data collection process,
- \url{http://imdb.com/help/show_leaf?infosource}.
+The internet movie database, \url{http://imdb.com/}, is a website devoted
+to collecting movie data supplied by studios and fans. It claims to be the
+biggest movie database on the web and is run by amazon. More about
+information imdb.com can be found online,
+\url{http://imdb.com/help/show_leaf?about}, including information about
+the data collection process,
+\url{http://imdb.com/help/show_leaf?infosource}.
}
\details{
- Movies were selected for inclusion if they had a known
- length and had been rated by at least one imdb user. The
- data set contains the following fields:
+Movies were selected for inclusion if they had a known length and had been rated by at least one imdb user. The data set contains the following fields:
- \itemize{ \item title. Title of the movie. \item year.
- Year of release. \item budget. Total budget (if known)
- in US dollars \item length. Length in minutes. \item
- rating. Average IMDB user rating. \item votes. Number
- of IMDB users who rated this movie. \item r1-10.
- Multiplying by ten gives percentile (to nearest 10\%) of
- users who rated this movie a 1. \item mpaa. MPAA
- rating. \item action, animation, comedy, drama,
- documentary, romance, short. Binary variables
- representing if movie was classified as belonging to that
- genre. }
+\itemize{
+ \item title. Title of the movie.
+ \item year. Year of release.
+ \item budget. Total budget (if known) in US dollars
+ \item length. Length in minutes.
+ \item rating. Average IMDB user rating.
+ \item votes. Number of IMDB users who rated this movie.
+ \item r1-10. Multiplying by ten gives percentile (to nearest 10\%) of users who rated this movie a 1.
+ \item mpaa. MPAA rating.
+ \item action, animation, comedy, drama, documentary, romance, short. Binary variables representing if movie was classified as belonging to that genre.
+}
}
\references{
- \url{http://had.co.nz/data/movies/}
+\url{http://had.co.nz/data/movies/}
}
\keyword{datasets}
diff --git a/man/mpg.Rd b/man/mpg.Rd
index 0636c00..c19c234 100644
--- a/man/mpg.Rd
+++ b/man/mpg.Rd
@@ -1,22 +1,32 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\docType{data}
\name{mpg}
\alias{mpg}
\title{Fuel economy data from 1999 and 2008 for 38 popular models of car}
\format{A data frame with 234 rows and 11 variables}
+\usage{
+data(mpg)
+}
\description{
- This dataset contains a subset of the fuel economy data
- that the EPA makes available on
- \url{http://fueleconomy.gov}. It contains only models
- which had a new release every year between 1999 and 2008
- - this was used as a proxy for the popularity of the car.
+This dataset contains a subset of the fuel economy data that the EPA makes
+available on \url{http://fueleconomy.gov}. It contains only models which
+had a new release every year between 1999 and 2008 - this was used as a
+proxy for the popularity of the car.
}
\details{
- \itemize{ \item manufacturer. \item model. \item displ.
- engine displacement, in litres \item year. \item cyl.
- number of cylinders \item trans. type of transmission
- \item drv. f = front-wheel drive, r = rear wheel drive, 4
- = 4wd \item cty. city miles per gallon \item hwy. highway
- miles per gallon \item fl. \item class. }
+\itemize{
+ \item manufacturer.
+ \item model.
+ \item displ. engine displacement, in litres
+ \item year.
+ \item cyl. number of cylinders
+ \item trans. type of transmission
+ \item drv. f = front-wheel drive, r = rear wheel drive, 4 = 4wd
+ \item cty. city miles per gallon
+ \item hwy. highway miles per gallon
+ \item fl.
+ \item class.
+}
}
\keyword{datasets}
diff --git a/man/msleep.Rd b/man/msleep.Rd
index 85e7218..d68cff0 100644
--- a/man/msleep.Rd
+++ b/man/msleep.Rd
@@ -1,28 +1,36 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\docType{data}
\name{msleep}
\alias{msleep}
\title{An updated and expanded version of the mammals sleep dataset.}
\format{A data frame with 83 rows and 11 variables}
+\usage{
+data(msleep)
+}
\description{
- This is an updated and expanded version of the mammals
- sleep dataset. Updated sleep times and weights were taken
- from V. M. Savage and G. B. West. A quantitative,
- theoretical framework for understanding mammalian sleep.
- Proceedings of the National Academy of Sciences, 104
- (3):1051-1056, 2007.
+This is an updated and expanded version of the mammals sleep dataset.
+Updated sleep times and weights were taken from V. M. Savage and G. B.
+West. A quantitative, theoretical framework for understanding mammalian
+sleep. Proceedings of the National Academy of Sciences, 104 (3):1051-1056,
+2007.
}
\details{
- Additional variables order, conservation status and vore
- were added from wikipedia.
+Additional variables order, conservation status and vore were added from
+wikipedia.
- \itemize{ \item name. common name \item genus. \item
- vore. carnivore, omnivore or herbivore? \item order.
+\itemize{
+ \item name. common name
+ \item genus.
+ \item vore. carnivore, omnivore or herbivore?
+ \item order.
\item conservation. the conservation status of the animal
- \item sleep\_total. total amount of sleep, in hours \item
- sleep\_rem. rem sleep, in hours \item sleep\_cycle.
- length of sleep cycle, in hours \item awake. amount of
- time spent awake, in hours \item brainwt. brain weight in
- kilograms \item bodywt. body weight in kilograms }
+ \item sleep\_total. total amount of sleep, in hours
+ \item sleep\_rem. rem sleep, in hours
+ \item sleep\_cycle. length of sleep cycle, in hours
+ \item awake. amount of time spent awake, in hours
+ \item brainwt. brain weight in kilograms
+ \item bodywt. body weight in kilograms
+}
}
\keyword{datasets}
diff --git a/man/opts.Rd b/man/opts.Rd
index 7098563..9cb722a 100644
--- a/man/opts.Rd
+++ b/man/opts.Rd
@@ -1,15 +1,14 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{opts}
\alias{opts}
\title{Build a theme (or partial theme) from theme elements}
\usage{
- opts(...)
+opts(...)
}
\arguments{
- \item{...}{Arguments to be passed on to the \code{theme}
- function.}
+\item{...}{Arguments to be passed on to the \code{theme} function.}
}
\description{
- \code{opts} is deprecated. See the \code{\link{theme}}
- function.
+\code{opts} is deprecated. See the \code{\link{theme}} function.
}
diff --git a/man/plot-templates.Rd b/man/plot-templates.Rd
new file mode 100644
index 0000000..7db9484
--- /dev/null
+++ b/man/plot-templates.Rd
@@ -0,0 +1,31 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
+\name{plot-templates}
+\alias{ggfluctuation}
+\alias{ggmissing}
+\alias{ggorder}
+\alias{ggpcp}
+\alias{ggstructure}
+\alias{plot-templates}
+\alias{plotmatrix}
+\title{Plot templates.}
+\usage{
+ggpcp(data, vars = names(data), ...)
+
+ggfluctuation(table, type = "size", floor = 0, ceiling = max(table$freq,
+ na.rm = TRUE))
+
+ggmissing(data, avoid = "stack", order = TRUE, missing.only = TRUE)
+
+ggstructure(data)
+
+ggorder(data)
+
+plotmatrix(data, mapping = aes(), colour = "black")
+}
+\description{
+These plot templates are deprecated in an attempt to make ggplot2 as
+streamlined as possible, and to avoid bugs in these poorly tested
+functions. See the \pkg{GGally} package for some alternatives.
+}
+\keyword{internal}
+
diff --git a/man/plotmatrix.Rd b/man/plotmatrix.Rd
deleted file mode 100644
index 1c9544c..0000000
--- a/man/plotmatrix.Rd
+++ /dev/null
@@ -1,23 +0,0 @@
-\name{plotmatrix}
-\alias{plotmatrix}
-\title{Code to create a scatterplot matrix (experimental)}
-\usage{
- plotmatrix(data, mapping = aes(), colour = "black")
-}
-\arguments{
- \item{data}{data frame}
-
- \item{mapping}{any additional aesthetic mappings (do not
- use x and y)}
-
- \item{colour}{default point colour}
-}
-\description{
- Code to create a scatterplot matrix (experimental)
-}
-\examples{
-plotmatrix(mtcars[, 1:3])
-plotmatrix(mtcars[, 1:3]) + geom_smooth(method="lm")
-}
-\keyword{hplot}
-
diff --git a/man/position_dodge.Rd b/man/position_dodge.Rd
index 5d209b7..2a57c47 100644
--- a/man/position_dodge.Rd
+++ b/man/position_dodge.Rd
@@ -1,18 +1,19 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{position_dodge}
\alias{position_dodge}
\title{Adjust position by dodging overlaps to the side.}
\usage{
- position_dodge(width = NULL, height = NULL)
+position_dodge(width = NULL, height = NULL)
}
\arguments{
- \item{width}{Manually specify width (does not affect all
- position adjustments)}
+\item{width}{Manually specify width (does not affect all position
+adjustments)}
- \item{height}{Manually specify height (does not affect
- all position adjustments)}
+\item{height}{Manually specify height (does not affect all position
+adjustments)}
}
\description{
- Adjust position by dodging overlaps to the side.
+Adjust position by dodging overlaps to the side.
}
\examples{
\donttest{
@@ -39,9 +40,10 @@ p + geom_errorbar(aes(ymin = y-1, ymax = y+1, width = 0.2),
}
}
\seealso{
- Other position adjustments: \code{\link{position_fill}},
- \code{\link{position_identity}},
- \code{\link{position_jitter}},
+Other position adjustments: \code{\link{position_fill}};
+ \code{\link{position_identity}};
+ \code{\link{position_jitterdodge}};
+ \code{\link{position_jitter}};
\code{\link{position_stack}}
}
diff --git a/man/position_fill.Rd b/man/position_fill.Rd
index 3ca1d47..eae4c72 100644
--- a/man/position_fill.Rd
+++ b/man/position_fill.Rd
@@ -1,20 +1,21 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{position_fill}
\alias{position_fill}
\title{Stack overlapping objects on top of one another, and standardise to have
equal height.}
\usage{
- position_fill(width = NULL, height = NULL)
+position_fill(width = NULL, height = NULL)
}
\arguments{
- \item{width}{Manually specify width (does not affect all
- position adjustments)}
+\item{width}{Manually specify width (does not affect all position
+adjustments)}
- \item{height}{Manually specify height (does not affect
- all position adjustments)}
+\item{height}{Manually specify height (does not affect all position
+adjustments)}
}
\description{
- Stack overlapping objects on top of one another, and
- standardise to have equal height.
+Stack overlapping objects on top of one another, and standardise to have
+equal height.
}
\examples{
\donttest{
@@ -31,12 +32,13 @@ ggplot(diamonds, aes(x=price, fill=color)) + cde
}
}
\seealso{
- See \code{\link{geom_bar}} and \code{\link{geom_area}}
- for more examples.
+See \code{\link{geom_bar}} and \code{\link{geom_area}} for
+ more examples.
- Other position adjustments: \code{\link{position_dodge}},
- \code{\link{position_identity}},
- \code{\link{position_jitter}},
+Other position adjustments: \code{\link{position_dodge}};
+ \code{\link{position_identity}};
+ \code{\link{position_jitterdodge}};
+ \code{\link{position_jitter}};
\code{\link{position_stack}}
}
diff --git a/man/position_identity.Rd b/man/position_identity.Rd
index e4b36f3..a3f6697 100644
--- a/man/position_identity.Rd
+++ b/man/position_identity.Rd
@@ -1,23 +1,25 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{position_identity}
\alias{position_identity}
\title{Don't adjust position}
\usage{
- position_identity(width = NULL, height = NULL)
+position_identity(width = NULL, height = NULL)
}
\arguments{
- \item{width}{Manually specify width (does not affect all
- position adjustments)}
+\item{width}{Manually specify width (does not affect all position
+adjustments)}
- \item{height}{Manually specify height (does not affect
- all position adjustments)}
+\item{height}{Manually specify height (does not affect all position
+adjustments)}
}
\description{
- Don't adjust position
+Don't adjust position
}
\seealso{
- Other position adjustments: \code{\link{position_dodge}},
- \code{\link{position_fill}},
- \code{\link{position_jitter}},
+Other position adjustments: \code{\link{position_dodge}};
+ \code{\link{position_fill}};
+ \code{\link{position_jitterdodge}};
+ \code{\link{position_jitter}};
\code{\link{position_stack}}
}
diff --git a/man/position_jitter.Rd b/man/position_jitter.Rd
index 46988ac..28e89e1 100644
--- a/man/position_jitter.Rd
+++ b/man/position_jitter.Rd
@@ -1,18 +1,19 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{position_jitter}
\alias{position_jitter}
\title{Jitter points to avoid overplotting.}
\usage{
- position_jitter(width = NULL, height = NULL)
+position_jitter(width = NULL, height = NULL)
}
\arguments{
- \item{width}{degree of jitter in x direction. Defaults to
- 40\% of the resolution of the data.}
+\item{width}{degree of jitter in x direction. Defaults to 40\% of the
+resolution of the data.}
- \item{height}{degree of jitter in y direction. Defaults
- to 40\% of the resolution of the data}
+\item{height}{degree of jitter in y direction. Defaults to 40\% of the
+resolution of the data}
}
\description{
- Jitter points to avoid overplotting.
+Jitter points to avoid overplotting.
}
\examples{
qplot(am, vs, data = mtcars)
@@ -32,9 +33,10 @@ ggplot(mtcars, aes(x = am, y = vs)) + geom_point(position = position_jitter(w =
qplot(class, hwy, data = mpg, geom = c("boxplot", "jitter"))
}
\seealso{
- Other position adjustments: \code{\link{position_dodge}},
- \code{\link{position_fill}},
- \code{\link{position_identity}},
+Other position adjustments: \code{\link{position_dodge}};
+ \code{\link{position_fill}};
+ \code{\link{position_identity}};
+ \code{\link{position_jitterdodge}};
\code{\link{position_stack}}
}
diff --git a/man/position_jitterdodge.Rd b/man/position_jitterdodge.Rd
new file mode 100644
index 0000000..b80221e
--- /dev/null
+++ b/man/position_jitterdodge.Rd
@@ -0,0 +1,36 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
+\name{position_jitterdodge}
+\alias{position_jitterdodge}
+\title{Adjust position by simultaneously dodging and jittering}
+\usage{
+position_jitterdodge(jitter.width = NULL, jitter.height = NULL,
+ dodge.width = NULL)
+}
+\arguments{
+\item{jitter.width}{degree of jitter in x direction. Defaults to 40\% of the
+resolution of the data.}
+
+\item{jitter.height}{degree of jitter in y direction. Defaults to 0.}
+
+\item{dodge.width}{the amount to dodge in the x direction. Defaults to 0.75,
+the default \code{position_dodge()} width.}
+}
+\description{
+This is primarily used for aligning points generated through
+\code{geom_point()} with dodged boxplots (e.g., a \code{geom_boxplot()} with
+a fill aesthetic supplied).
+}
+\examples{
+dsub <- diamonds[ sample(nrow(diamonds), 1000), ]
+ggplot(dsub, aes(x = cut, y = carat, fill = clarity)) +
+ geom_boxplot(outlier.size = 0) +
+ geom_point(pch = 21, position = position_jitterdodge())
+}
+\seealso{
+Other position adjustments: \code{\link{position_dodge}};
+ \code{\link{position_fill}};
+ \code{\link{position_identity}};
+ \code{\link{position_jitter}};
+ \code{\link{position_stack}}
+}
+
diff --git a/man/position_stack.Rd b/man/position_stack.Rd
index 7d00a81..6186ece 100644
--- a/man/position_stack.Rd
+++ b/man/position_stack.Rd
@@ -1,18 +1,19 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{position_stack}
\alias{position_stack}
\title{Stack overlapping objects on top of one another.}
\usage{
- position_stack(width = NULL, height = NULL)
+position_stack(width = NULL, height = NULL)
}
\arguments{
- \item{width}{Manually specify width (does not affect all
- position adjustments)}
+\item{width}{Manually specify width (does not affect all position
+adjustments)}
- \item{height}{Manually specify height (does not affect
- all position adjustments)}
+\item{height}{Manually specify height (does not affect all position
+adjustments)}
}
\description{
- Stack overlapping objects on top of one another.
+Stack overlapping objects on top of one another.
}
\examples{
# Stacking is the default behaviour for most area plots:
@@ -41,9 +42,10 @@ qplot(Time, Value, data = data.set, colour = Type, geom = "line",
# trends
}
\seealso{
- Other position adjustments: \code{\link{position_dodge}},
- \code{\link{position_fill}},
- \code{\link{position_identity}},
+Other position adjustments: \code{\link{position_dodge}};
+ \code{\link{position_fill}};
+ \code{\link{position_identity}};
+ \code{\link{position_jitterdodge}};
\code{\link{position_jitter}}
}
diff --git a/man/presidential.Rd b/man/presidential.Rd
index 90f1173..17b872c 100644
--- a/man/presidential.Rd
+++ b/man/presidential.Rd
@@ -1,12 +1,15 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\docType{data}
\name{presidential}
\alias{presidential}
\title{Terms of 10 presidents from Eisenhower to Bush W.}
\format{A data frame with 10 rows and 4 variables}
+\usage{
+data(presidential)
+}
\description{
- The names of each president, the start and end date of
- their term, and their party of 10 US presidents from
- Eisenhower to Bush W.
+The names of each president, the start and end date of their term, and
+their party of 10 US presidents from Eisenhower to Bush W.
}
\keyword{datasets}
diff --git a/man/print.ggplot.Rd b/man/print.ggplot.Rd
index 85d249a..2453f2d 100644
--- a/man/print.ggplot.Rd
+++ b/man/print.ggplot.Rd
@@ -1,25 +1,24 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{print.ggplot}
\alias{plot.ggplot}
\alias{print.ggplot}
\title{Draw plot on current graphics device.}
\usage{
- \method{print}{ggplot} (x, newpage = is.null(vp),
- vp = NULL, ...)
+\method{print}{ggplot}(x, newpage = is.null(vp), vp = NULL, ...)
- \method{plot}{ggplot} (x, newpage = is.null(vp),
- vp = NULL, ...)
+\method{plot}{ggplot}(x, newpage = is.null(vp), vp = NULL, ...)
}
\arguments{
- \item{x}{plot to display}
+\item{x}{plot to display}
- \item{newpage}{draw new (empty) page first?}
+\item{newpage}{draw new (empty) page first?}
- \item{vp}{viewport to draw plot in}
+\item{vp}{viewport to draw plot in}
- \item{...}{other arguments not used by this method}
+\item{...}{other arguments not used by this method}
}
\description{
- Draw plot on current graphics device.
+Draw plot on current graphics device.
}
\keyword{hplot}
diff --git a/man/qplot.Rd b/man/qplot.Rd
index 0777ac2..a3f6170 100644
--- a/man/qplot.Rd
+++ b/man/qplot.Rd
@@ -1,70 +1,59 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{qplot}
\alias{qplot}
\alias{quickplot}
\title{Quick plot}
\usage{
- qplot(x, y = NULL, ..., data, facets = NULL,
- margins = FALSE, geom = "auto", stat = list(NULL),
- position = list(NULL), xlim = c(NA, NA),
- ylim = c(NA, NA), log = "", main = NULL,
- xlab = deparse(substitute(x)),
- ylab = deparse(substitute(y)), asp = NA)
+qplot(x, y = NULL, ..., data, facets = NULL, margins = FALSE,
+ geom = "auto", stat = list(NULL), position = list(NULL), xlim = c(NA,
+ NA), ylim = c(NA, NA), log = "", main = NULL,
+ xlab = deparse(substitute(x)), ylab = deparse(substitute(y)), asp = NA)
}
\arguments{
- \item{x}{x values}
+\item{x}{x values}
- \item{y}{y values}
+\item{y}{y values}
- \item{...}{other aesthetics passed for each layer}
+\item{...}{other aesthetics passed for each layer}
- \item{data}{data frame to use (optional). If not
- specified, will create one, extracting vectors from the
- current environment.}
+\item{data}{data frame to use (optional). If not specified, will create
+one, extracting vectors from the current environment.}
- \item{facets}{faceting formula to use. Picks
- \code{\link{facet_wrap}} or \code{\link{facet_grid}}
- depending on whether the formula is one sided or
- two-sided}
+\item{facets}{faceting formula to use. Picks \code{\link{facet_wrap}} or
+\code{\link{facet_grid}} depending on whether the formula is one sided
+or two-sided}
- \item{margins}{whether or not margins will be displayed}
+\item{margins}{whether or not margins will be displayed}
- \item{geom}{character vector specifying geom to use.
- Defaults to "point" if x and y are specified, and
- "histogram" if only x is specified.}
+\item{geom}{character vector specifying geom to use. Defaults to
+"point" if x and y are specified, and "histogram" if only x is specified.}
- \item{stat}{character vector specifying statistics to
- use}
+\item{stat}{character vector specifying statistics to use}
- \item{position}{character vector giving position
- adjustment to use}
+\item{position}{character vector giving position adjustment to use}
- \item{xlim}{limits for x axis}
+\item{xlim}{limits for x axis}
- \item{ylim}{limits for y axis}
+\item{ylim}{limits for y axis}
- \item{log}{which variables to log transform ("x", "y", or
- "xy")}
+\item{log}{which variables to log transform ("x", "y", or "xy")}
- \item{main}{character vector or expression for plot
- title}
+\item{main}{character vector or expression for plot title}
- \item{xlab}{character vector or expression for x axis
- label}
+\item{xlab}{character vector or expression for x axis label}
- \item{ylab}{character vector or expression for y axis
- label}
+\item{ylab}{character vector or expression for y axis label}
- \item{asp}{the y/x aspect ratio}
+\item{asp}{the y/x aspect ratio}
}
\description{
- \code{qplot} is the basic plotting function in the
- ggplot2 package, designed to be familiar if you're used
- to \code{\link{plot}} from the base package. It is a
- convenient wrapper for creating a number of different
- types of plots using a consistent calling scheme. See
- \url{http://had.co.nz/ggplot2/book/qplot.pdf} for the
- chapter in the \code{ggplot2} book which describes the
- usage of \code{qplot} in detail.
+\code{qplot} is the basic plotting function in the ggplot2 package,
+designed to be familiar if you're used to \code{\link{plot}}
+from the base package. It is a convenient wrapper for creating
+a number of different types of plots using a consistent
+calling scheme. See \url{http://had.co.nz/ggplot2/book/qplot.pdf}
+for the chapter in the \code{ggplot2} book which describes the usage
+of \code{qplot} in detail.
}
\examples{
\donttest{
@@ -109,6 +98,7 @@ qplot(y = mpg, data = mtcars)
# Use different geoms
qplot(mpg, wt, data = mtcars, geom="path")
qplot(factor(cyl), wt, data = mtcars, geom=c("boxplot", "jitter"))
+qplot(mpg, data = mtcars, geom = "dotplot")
}
}
diff --git a/man/rel.Rd b/man/rel.Rd
index d3befc3..2d83104 100644
--- a/man/rel.Rd
+++ b/man/rel.Rd
@@ -1,14 +1,15 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{rel}
\alias{rel}
\title{Relative sizing for theme elements}
\usage{
- rel(x)
+rel(x)
}
\arguments{
- \item{x}{A number representing the relative size}
+\item{x}{A number representing the relative size}
}
\description{
- Relative sizing for theme elements
+Relative sizing for theme elements
}
\examples{
qplot(1:3, 1:3) + theme(axis.title.x = element_text(size = rel(2.5)))
diff --git a/man/resolution.Rd b/man/resolution.Rd
index 204b7fc..f7da5af 100644
--- a/man/resolution.Rd
+++ b/man/resolution.Rd
@@ -1,23 +1,24 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{resolution}
\alias{resolution}
\title{Compute the "resolution" of a data vector.}
\usage{
- resolution(x, zero = TRUE)
+resolution(x, zero = TRUE)
}
\arguments{
- \item{x}{numeric vector}
+\item{x}{numeric vector}
- \item{zero}{should a zero value be automatically included
- in the computation of resolution}
+\item{zero}{should a zero value be automatically included in the
+computation of resolution}
}
\description{
- The resolution is is the smallest non-zero distance
- between adjacent values. If there is only one unique
- value, then the resolution is defined to be one.
+The resolution is is the smallest non-zero distance between adjacent
+values. If there is only one unique value, then the resolution is defined
+to be one.
}
\details{
- If x is an integer vector, then it is assumed to
- represent a discrete variable, and the resolution is 1.
+If x is an integer vector, then it is assumed to represent a discrete
+variable, and the resolution is 1.
}
\examples{
resolution(1:10)
diff --git a/man/rweave.Rd b/man/rweave.Rd
index 502117d..db1e09f 100644
--- a/man/rweave.Rd
+++ b/man/rweave.Rd
@@ -1,17 +1,18 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{rweave}
\alias{rweave}
\title{Row weave.}
\usage{
- rweave(...)
+rweave(...)
}
\arguments{
- \item{...}{matrices to weave together}
+\item{...}{matrices to weave together}
}
\description{
- Weave together two (or more) matrices by row.
+Weave together two (or more) matrices by row.
}
\details{
- Matrices must have same dimensions.
+Matrices must have same dimensions.
}
\keyword{internal}
diff --git a/man/scale_alpha.Rd b/man/scale_alpha.Rd
index 2fb5213..db74898 100644
--- a/man/scale_alpha.Rd
+++ b/man/scale_alpha.Rd
@@ -1,28 +1,26 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{scale_alpha}
\alias{scale_alpha}
\alias{scale_alpha_continuous}
\alias{scale_alpha_discrete}
\title{Alpha scales.}
\usage{
- scale_alpha(..., range = c(0.1, 1))
+scale_alpha(..., range = c(0.1, 1))
- scale_alpha_continuous(..., range = c(0.1, 1))
+scale_alpha_continuous(..., range = c(0.1, 1))
- scale_alpha_discrete(..., range = c(0.1, 1))
+scale_alpha_discrete(..., range = c(0.1, 1))
}
\arguments{
- \item{...}{Other arguments passed on to
- \code{\link{continuous_scale}} or
- \code{\link{discrete_scale}} as appropriate, to control
- name, limits, breaks, labels and so forth.}
+\item{...}{Other arguments passed on to \code{\link{continuous_scale}}
+or \code{\link{discrete_scale}} as appropriate, to control name, limits,
+breaks, labels and so forth.}
- \item{range}{range of output alpha values. Should lie
- between 0 and 1.}
+\item{range}{range of output alpha values. Should lie between 0 and 1.}
}
\description{
- \code{scale_alpha} is an alias for
- \code{scale_alpha_continuous} since that is the most
- common use of alpha, and it saves a bit of typing.
+\code{scale_alpha} is an alias for \code{scale_alpha_continuous} since
+that is the most common use of alpha, and it saves a bit of typing.
}
\examples{
(p <- qplot(mpg, cyl, data = mtcars, alpha = cyl))
diff --git a/man/scale_area.Rd b/man/scale_area.Rd
index c57f9b6..cb4140f 100644
--- a/man/scale_area.Rd
+++ b/man/scale_area.Rd
@@ -1,23 +1,20 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{scale_area}
\alias{scale_area}
\title{Scale area instead of radius (for size).}
\usage{
- scale_area(..., range = c(1, 6))
+scale_area(..., range = c(1, 6))
}
\arguments{
- \item{...}{Other arguments passed on to
- \code{\link{continuous_scale}} to control name, limits,
- breaks, labels and so forth.}
+\item{...}{Other arguments passed on to \code{\link{continuous_scale}}
+to control name, limits, breaks, labels and so forth.}
- \item{range}{Range of output sizes. Should be greater
- than 0.}
+\item{range}{Range of output sizes. Should be greater than 0.}
}
\description{
- \code{\link{scale_area}} is deprecated and will be
- removed in a future version of ggplot2. Use
- \code{\link{scale_size_area}} instead. Note that the
- default behavir of \code{\link{scale_size_area}} is
- slightly different: by default, it makes the area
- proportional to the numeric value.
+\code{\link{scale_area}} is deprecated and will be removed in a future
+version of ggplot2. Use \code{\link{scale_size_area}} instead. Note that the
+default behavir of \code{\link{scale_size_area}} is slightly different: by
+default, it makes the area proportional to the numeric value.
}
diff --git a/man/scale_brewer.Rd b/man/scale_brewer.Rd
index 6f007c6..230ed85 100644
--- a/man/scale_brewer.Rd
+++ b/man/scale_brewer.Rd
@@ -1,33 +1,63 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{scale_colour_brewer}
\alias{scale_color_brewer}
+\alias{scale_color_distiller}
\alias{scale_colour_brewer}
+\alias{scale_colour_distiller}
\alias{scale_fill_brewer}
+\alias{scale_fill_distiller}
\title{Sequential, diverging and qualitative colour scales from colorbrewer.org}
\usage{
- scale_colour_brewer(..., type = "seq", palette = 1)
+scale_colour_brewer(..., type = "seq", palette = 1)
- scale_fill_brewer(..., type = "seq", palette = 1)
+scale_fill_brewer(..., type = "seq", palette = 1)
- scale_color_brewer(..., type = "seq", palette = 1)
+scale_colour_distiller(..., type = "seq", palette = 1, values = NULL,
+ space = "Lab", na.value = "grey50")
+
+scale_fill_distiller(..., type = "seq", palette = 1, values = NULL,
+ space = "Lab", na.value = "grey50")
+
+scale_color_brewer(..., type = "seq", palette = 1)
+
+scale_color_distiller(..., type = "seq", palette = 1, values = NULL,
+ space = "Lab", na.value = "grey50")
}
\arguments{
- \item{type}{One of seq (sequential), div (diverging) or
- qual (qualitative)}
+\item{type}{One of seq (sequential), div (diverging) or qual (qualitative)}
+
+\item{palette}{If a string, will use that named palette. If a number, will
+index into the list of palettes of appropriate \code{type}}
- \item{palette}{If a string, will use that named palette.
- If a number, will index into the list of palettes of
- appropriate \code{type}}
+\item{...}{Other arguments passed on to \code{\link{discrete_scale}}
+to control name, limits, breaks, labels and so forth.}
- \item{...}{Other arguments passed on to
- \code{\link{discrete_scale}} to control name, limits,
- breaks, labels and so forth.}
+\item{na.value}{Colour to use for missing values}
+
+\item{values}{if colours should not be evenly positioned along the gradient
+this vector gives the position (between 0 and 1) for each colour in the
+\code{colours} vector. See \code{\link{rescale}} for a convience function
+to map an arbitrary range to between 0 and 1.}
+
+\item{space}{colour space in which to calculate gradient. "Lab" usually
+best unless gradient goes through white.}
}
\description{
- See \url{http://colorbrewer2.org} for more information.
+ColorBrewer provides sequential, diverging and qualitative colour schemes
+which are particularly suited and tested to display discrete values (levels
+of a factor) on a map. ggplot2 can use those colours in discrete scales. It
+also allows to smoothly interpolate 6 colours from any palette to a
+continuous scale (6 colours per palette gives nice gradients; more results in
+more saturated colours which do not look as good). However, the original
+colour schemes (particularly the qualitative ones) were not intended for this
+and the perceptual result is left to the appreciation of the user.
+}
+\details{
+See \url{http://colorbrewer2.org} for more information.
}
\examples{
dsamp <- diamonds[sample(nrow(diamonds), 1000), ]
-(d <- qplot(carat, price, data=dsamp, colour=clarity))
+(d <- qplot(carat, price, data = dsamp, colour = clarity))
# Change scale label
d + scale_colour_brewer()
@@ -35,40 +65,55 @@ d + scale_colour_brewer("clarity")
d + scale_colour_brewer(expression(clarity[beta]))
# Select brewer palette to use, see ?scales::brewer_pal for more details
-d + scale_colour_brewer(type="seq")
-d + scale_colour_brewer(type="seq", palette=3)
+d + scale_colour_brewer(type = "seq")
+d + scale_colour_brewer(type = "seq", palette = 3)
-d + scale_colour_brewer(palette="Blues")
-d + scale_colour_brewer(palette="Set1")
+d + scale_colour_brewer(palette = "Blues")
+d + scale_colour_brewer(palette = "Set1")
# scale_fill_brewer works just the same as
# scale_colour_brewer but for fill colours
-ggplot(diamonds, aes(x=price, fill=cut)) +
- geom_histogram(position="dodge", binwidth=1000) +
+ggplot(diamonds, aes(x = price, fill = cut)) +
+ geom_histogram(position = "dodge", binwidth = 1000) +
scale_fill_brewer()
+
+# Generate map data
+library(reshape2) # for melt
+volcano3d <- melt(volcano)
+names(volcano3d) <- c("x", "y", "z")
+
+# Basic plot
+v <- ggplot() + geom_tile(aes(x = x, y = y, fill = z), data = volcano3d)
+v
+v + scale_fill_distiller()
+v + scale_fill_distiller(palette = 2)
+v + scale_fill_distiller(type = "div")
+v + scale_fill_distiller(palette = "Spectral")
+v + scale_fill_distiller(palette = "Spectral", trans = "reverse")
+v + scale_fill_distiller(type = "qual")
+# Not appropriate for continuous data, issues a warning
}
\seealso{
- Other colour scales:
- \code{\link{scale_color_continuous}},
- \code{\link{scale_color_discrete}},
+Other colour scales: \code{\link{scale_color_continuous}},
\code{\link{scale_color_gradient}},
- \code{\link{scale_color_gradient2}},
- \code{\link{scale_color_gradientn}},
- \code{\link{scale_color_grey}},
- \code{\link{scale_color_hue}},
\code{\link{scale_colour_continuous}},
- \code{\link{scale_colour_discrete}},
\code{\link{scale_colour_gradient}},
+ \code{\link{scale_fill_continuous}},
+ \code{\link{scale_fill_gradient}};
+ \code{\link{scale_color_discrete}},
+ \code{\link{scale_color_hue}},
+ \code{\link{scale_colour_discrete}},
+ \code{\link{scale_colour_hue}},
+ \code{\link{scale_fill_discrete}},
+ \code{\link{scale_fill_hue}};
+ \code{\link{scale_color_gradient2}},
\code{\link{scale_colour_gradient2}},
+ \code{\link{scale_fill_gradient2}};
+ \code{\link{scale_color_gradientn}},
\code{\link{scale_colour_gradientn}},
+ \code{\link{scale_fill_gradientn}};
+ \code{\link{scale_color_grey}},
\code{\link{scale_colour_grey}},
- \code{\link{scale_colour_hue}},
- \code{\link{scale_fill_continuous}},
- \code{\link{scale_fill_discrete}},
- \code{\link{scale_fill_gradient}},
- \code{\link{scale_fill_gradient2}},
- \code{\link{scale_fill_gradientn}},
- \code{\link{scale_fill_grey}},
- \code{\link{scale_fill_hue}}
+ \code{\link{scale_fill_grey}}
}
diff --git a/man/scale_continuous.Rd b/man/scale_continuous.Rd
index 7ca06a7..d4471f0 100644
--- a/man/scale_continuous.Rd
+++ b/man/scale_continuous.Rd
@@ -1,3 +1,4 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{scale_x_continuous}
\alias{scale_x_continuous}
\alias{scale_x_log10}
@@ -9,35 +10,33 @@
\alias{scale_y_sqrt}
\title{Continuous position scales (x & y).}
\usage{
- scale_x_continuous(..., expand = waiver())
+scale_x_continuous(..., expand = waiver())
- scale_y_continuous(..., expand = waiver())
+scale_y_continuous(..., expand = waiver())
- scale_x_log10(...)
+scale_x_log10(...)
- scale_y_log10(...)
+scale_y_log10(...)
- scale_x_reverse(...)
+scale_x_reverse(...)
- scale_y_reverse(...)
+scale_y_reverse(...)
- scale_x_sqrt(...)
+scale_x_sqrt(...)
- scale_y_sqrt(...)
+scale_y_sqrt(...)
}
\arguments{
- \item{...}{common continuous scale parameters:
- \code{name}, \code{breaks}, \code{labels},
- \code{na.value}, \code{limits} and \code{trans}. See
- \code{\link{continuous_scale}} for more details}
-
- \item{expand}{a numeric vector of length two giving
- multiplicative and additive expansion constants. These
- constants ensure that the data is placed some distance
- away from the axes.}
+\item{...}{common continuous scale parameters: \code{name}, \code{breaks},
+\code{labels}, \code{na.value}, \code{limits} and \code{trans}. See
+\code{\link{continuous_scale}} for more details}
+
+\item{expand}{a numeric vector of length two giving multiplicative and
+additive expansion constants. These constants ensure that the data is
+placed some distance away from the axes.}
}
\description{
- Continuous position scales (x & y).
+Continuous position scales (x & y).
}
\examples{
\donttest{
@@ -96,11 +95,10 @@ qplot(rating, votes, data=movies, log="xy")
}
}
\seealso{
- Other position scales: \code{\link{scale_x_date}},
- \code{\link{scale_x_datetime}},
+Other position scales: \code{\link{scale_x_datetime}},
+ \code{\link{scale_y_datetime}};
+ \code{\link{scale_x_date}}, \code{\link{scale_y_date}};
\code{\link{scale_x_discrete}},
- \code{\link{scale_y_date}},
- \code{\link{scale_y_datetime}},
\code{\link{scale_y_discrete}}
}
diff --git a/man/scale_date.Rd b/man/scale_date.Rd
index 9435657..7827476 100644
--- a/man/scale_date.Rd
+++ b/man/scale_date.Rd
@@ -1,40 +1,37 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{scale_x_date}
\alias{scale_x_date}
\alias{scale_y_date}
\title{Position scale, date}
\usage{
- scale_x_date(..., expand = waiver(),
- breaks = pretty_breaks(), minor_breaks = waiver())
+scale_x_date(..., expand = waiver(), breaks = pretty_breaks(),
+ minor_breaks = waiver())
- scale_y_date(..., expand = waiver(),
- breaks = pretty_breaks(), minor_breaks = waiver())
+scale_y_date(..., expand = waiver(), breaks = pretty_breaks(),
+ minor_breaks = waiver())
}
\arguments{
- \item{breaks}{A vector of breaks, a function that given
- the scale limits returns a vector of breaks, or a
- character vector, specifying the width between breaks.
- For more information about the first two, see
- \code{\link{continuous_scale}}, for more information
- about the last, see \code{\link[scales]{date_breaks}}`.}
+\item{breaks}{A vector of breaks, a function that given the scale limits
+returns a vector of breaks, or a character vector, specifying the width
+between breaks. For more information about the first two, see
+\code{\link{continuous_scale}}, for more information about the last,
+see \code{\link[scales]{date_breaks}}`.}
- \item{minor_breaks}{Either \code{NULL} for no minor
- breaks, \code{waiver()} for the default breaks (one minor
- break between each major break), a numeric vector of
- positions, or a function that given the limits returns a
- vector of minor breaks.}
+\item{minor_breaks}{Either \code{NULL} for no minor breaks, \code{waiver()}
+for the default breaks (one minor break between each major break), a
+numeric vector of positions, or a function that given the limits returns
+a vector of minor breaks.}
- \item{...}{common continuous scale parameters:
- \code{name}, \code{breaks}, \code{labels},
- \code{na.value}, \code{limits} and \code{trans}. See
- \code{\link{continuous_scale}} for more details}
+\item{...}{common continuous scale parameters: \code{name}, \code{breaks},
+\code{labels}, \code{na.value}, \code{limits} and \code{trans}. See
+\code{\link{continuous_scale}} for more details}
- \item{expand}{a numeric vector of length two giving
- multiplicative and additive expansion constants. These
- constants ensure that the data is placed some distance
- away from the axes.}
+\item{expand}{a numeric vector of length two giving multiplicative and
+additive expansion constants. These constants ensure that the data is
+placed some distance away from the axes.}
}
\description{
- Position scale, date
+Position scale, date
}
\examples{
# We'll start by creating some nonsense data with dates
@@ -96,16 +93,17 @@ qplot(date, value, data = em, geom = "line", group = variable) +
facet_grid(variable ~ ., scale = "free_y")
}
\seealso{
- Other position scales: \code{\link{scale_x_continuous}},
- \code{\link{scale_x_datetime}},
- \code{\link{scale_x_discrete}},
+Other position scales: \code{\link{scale_x_continuous}},
\code{\link{scale_x_log10}},
\code{\link{scale_x_reverse}},
\code{\link{scale_x_sqrt}},
\code{\link{scale_y_continuous}},
- \code{\link{scale_y_datetime}},
- \code{\link{scale_y_discrete}},
\code{\link{scale_y_log10}},
- \code{\link{scale_y_reverse}}, \code{\link{scale_y_sqrt}}
+ \code{\link{scale_y_reverse}},
+ \code{\link{scale_y_sqrt}};
+ \code{\link{scale_x_datetime}},
+ \code{\link{scale_y_datetime}};
+ \code{\link{scale_x_discrete}},
+ \code{\link{scale_y_discrete}}
}
diff --git a/man/scale_datetime.Rd b/man/scale_datetime.Rd
index 5fd9918..70f9c61 100644
--- a/man/scale_datetime.Rd
+++ b/man/scale_datetime.Rd
@@ -1,40 +1,37 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{scale_x_datetime}
\alias{scale_x_datetime}
\alias{scale_y_datetime}
\title{Position scale, date}
\usage{
- scale_x_datetime(..., expand = waiver(),
- breaks = pretty_breaks(), minor_breaks = waiver())
+scale_x_datetime(..., expand = waiver(), breaks = pretty_breaks(),
+ minor_breaks = waiver())
- scale_y_datetime(..., expand = waiver(),
- breaks = pretty_breaks(), minor_breaks = waiver())
+scale_y_datetime(..., expand = waiver(), breaks = pretty_breaks(),
+ minor_breaks = waiver())
}
\arguments{
- \item{breaks}{A vector of breaks, a function that given
- the scale limits returns a vector of breaks, or a
- character vector, specifying the width between breaks.
- For more information about the first two, see
- \code{\link{continuous_scale}}, for more information
- about the last, see \code{\link[scales]{date_breaks}}`.}
+\item{breaks}{A vector of breaks, a function that given the scale limits
+returns a vector of breaks, or a character vector, specifying the width
+between breaks. For more information about the first two, see
+\code{\link{continuous_scale}}, for more information about the last,
+see \code{\link[scales]{date_breaks}}.}
- \item{minor_breaks}{Either \code{NULL} for no minor
- breaks, \code{waiver()} for the default breaks (one minor
- break between each major break), a numeric vector of
- positions, or a function that given the limits returns a
- vector of minor breaks.}
+\item{minor_breaks}{Either \code{NULL} for no minor breaks, \code{waiver()}
+for the default breaks (one minor break between each major break), a
+numeric vector of positions, or a function that given the limits returns
+a vector of minor breaks.}
- \item{...}{common continuous scale parameters:
- \code{name}, \code{breaks}, \code{labels},
- \code{na.value}, \code{limits} and \code{trans}. See
- \code{\link{continuous_scale}} for more details}
+\item{...}{common continuous scale parameters: \code{name}, \code{breaks},
+\code{labels}, \code{na.value}, \code{limits} and \code{trans}. See
+\code{\link{continuous_scale}} for more details}
- \item{expand}{a numeric vector of length two giving
- multiplicative and additive expansion constants. These
- constants ensure that the data is placed some distance
- away from the axes.}
+\item{expand}{a numeric vector of length two giving multiplicative and
+additive expansion constants. These constants ensure that the data is
+placed some distance away from the axes.}
}
\description{
- Position scale, date
+Position scale, date
}
\examples{
start <- ISOdate(2001, 1, 1, tz = "")
@@ -75,16 +72,16 @@ last_plot() + scale_x_datetime(breaks = date_breaks("1 day"),
minor_breaks = date_breaks("2 hour"))
}
\seealso{
- Other position scales: \code{\link{scale_x_continuous}},
- \code{\link{scale_x_date}},
- \code{\link{scale_x_discrete}},
+Other position scales: \code{\link{scale_x_continuous}},
\code{\link{scale_x_log10}},
\code{\link{scale_x_reverse}},
\code{\link{scale_x_sqrt}},
\code{\link{scale_y_continuous}},
- \code{\link{scale_y_date}},
- \code{\link{scale_y_discrete}},
\code{\link{scale_y_log10}},
- \code{\link{scale_y_reverse}}, \code{\link{scale_y_sqrt}}
+ \code{\link{scale_y_reverse}},
+ \code{\link{scale_y_sqrt}}; \code{\link{scale_x_date}},
+ \code{\link{scale_y_date}};
+ \code{\link{scale_x_discrete}},
+ \code{\link{scale_y_discrete}}
}
diff --git a/man/scale_discrete.Rd b/man/scale_discrete.Rd
index c0b1f5d..704cbb0 100644
--- a/man/scale_discrete.Rd
+++ b/man/scale_discrete.Rd
@@ -1,31 +1,28 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{scale_x_discrete}
\alias{scale_x_discrete}
\alias{scale_y_discrete}
\title{Discrete position.}
\usage{
- scale_x_discrete(..., expand = waiver())
+scale_x_discrete(..., expand = waiver())
- scale_y_discrete(..., expand = waiver())
+scale_y_discrete(..., expand = waiver())
}
\arguments{
- \item{...}{common discrete scale parameters: \code{name},
- \code{breaks}, \code{labels}, \code{na.value},
- \code{limits} and \code{guide}. See
- \code{\link{discrete_scale}} for more details}
+\item{...}{common discrete scale parameters: \code{name}, \code{breaks},
+\code{labels}, \code{na.value}, \code{limits} and \code{guide}. See
+\code{\link{discrete_scale}} for more details}
- \item{expand}{a numeric vector of length two giving
- multiplicative and additive expansion constants. These
- constants ensure that the data is placed some distance
- away from the axes.}
+\item{expand}{a numeric vector of length two giving multiplicative and
+additive expansion constants. These constants ensure that the data is
+placed some distance away from the axes.}
}
\description{
- You can use continuous positions even with a discrete
- position scale - this allows you (e.g.) to place labels
- between bars in a bar chart. Continuous positions are
- numeric values starting at one for the first level, and
- increasing by one for each level (i.e. the labels are
- placed at integer positions). This is what allows
- jittering to work.
+You can use continuous positions even with a discrete position scale -
+this allows you (e.g.) to place labels between bars in a bar chart.
+Continuous positions are numeric values starting at one for the first
+level, and increasing by one for each level (i.e. the labels are placed
+at integer positions). This is what allows jittering to work.
}
\examples{
\donttest{
@@ -63,16 +60,16 @@ qplot(reorder(manufacturer, cty), cty, data=mpg) +
}
}
\seealso{
- Other position scales: \code{\link{scale_x_continuous}},
- \code{\link{scale_x_date}},
- \code{\link{scale_x_datetime}},
+Other position scales: \code{\link{scale_x_continuous}},
\code{\link{scale_x_log10}},
\code{\link{scale_x_reverse}},
\code{\link{scale_x_sqrt}},
\code{\link{scale_y_continuous}},
- \code{\link{scale_y_date}},
- \code{\link{scale_y_datetime}},
\code{\link{scale_y_log10}},
- \code{\link{scale_y_reverse}}, \code{\link{scale_y_sqrt}}
+ \code{\link{scale_y_reverse}},
+ \code{\link{scale_y_sqrt}};
+ \code{\link{scale_x_datetime}},
+ \code{\link{scale_y_datetime}};
+ \code{\link{scale_x_date}}, \code{\link{scale_y_date}}
}
diff --git a/man/scale_gradient.Rd b/man/scale_gradient.Rd
index 12022ee..cbdfdc5 100644
--- a/man/scale_gradient.Rd
+++ b/man/scale_gradient.Rd
@@ -1,3 +1,4 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{scale_colour_gradient}
\alias{scale_color_continuous}
\alias{scale_color_gradient}
@@ -7,54 +8,46 @@
\alias{scale_fill_gradient}
\title{Smooth gradient between two colours}
\usage{
- scale_colour_gradient(..., low = "#132B43",
- high = "#56B1F7", space = "Lab", na.value = "grey50",
- guide = "colourbar")
+scale_colour_gradient(..., low = "#132B43", high = "#56B1F7",
+ space = "Lab", na.value = "grey50", guide = "colourbar")
- scale_fill_gradient(..., low = "#132B43",
- high = "#56B1F7", space = "Lab", na.value = "grey50",
- guide = "colourbar")
+scale_fill_gradient(..., low = "#132B43", high = "#56B1F7", space = "Lab",
+ na.value = "grey50", guide = "colourbar")
- scale_colour_continuous(..., low = "#132B43",
- high = "#56B1F7", space = "Lab", na.value = "grey50",
- guide = "colourbar")
+scale_colour_continuous(..., low = "#132B43", high = "#56B1F7",
+ space = "Lab", na.value = "grey50", guide = "colourbar")
- scale_fill_continuous(..., low = "#132B43",
- high = "#56B1F7", space = "Lab", na.value = "grey50",
- guide = "colourbar")
+scale_fill_continuous(..., low = "#132B43", high = "#56B1F7",
+ space = "Lab", na.value = "grey50", guide = "colourbar")
- scale_color_continuous(..., low = "#132B43",
- high = "#56B1F7", space = "Lab", na.value = "grey50",
- guide = "colourbar")
+scale_color_continuous(..., low = "#132B43", high = "#56B1F7",
+ space = "Lab", na.value = "grey50", guide = "colourbar")
- scale_color_gradient(..., low = "#132B43",
- high = "#56B1F7", space = "Lab", na.value = "grey50",
- guide = "colourbar")
+scale_color_gradient(..., low = "#132B43", high = "#56B1F7",
+ space = "Lab", na.value = "grey50", guide = "colourbar")
}
\arguments{
- \item{guide}{Type of legend. Use \code{"colourbar"} for
- continuous colour bar, or \code{"legend"} for discrete
- colour legend.}
+\item{guide}{Type of legend. Use \code{"colourbar"} for continuous
+colour bar, or \code{"legend"} for discrete colour legend.}
- \item{...}{Other arguments passed on to
- \code{\link{discrete_scale}} to control name, limits,
- breaks, labels and so forth.}
+\item{...}{Other arguments passed on to \code{\link{discrete_scale}}
+to control name, limits, breaks, labels and so forth.}
- \item{na.value}{Colour to use for missing values}
+\item{na.value}{Colour to use for missing values}
- \item{low}{colour for low end of gradient.}
+\item{low}{colour for low end of gradient.}
- \item{high}{colour for high end of gradient.}
+\item{high}{colour for high end of gradient.}
- \item{space}{colour space in which to calculate gradient.
- "Lab" usually best unless gradient goes through white.}
+\item{space}{colour space in which to calculate gradient. "Lab" usually
+best unless gradient goes through white.}
}
\description{
- Default colours are generated with \pkg{munsell} and
- \code{mnsl(c("2.5PB 2/4", "2.5PB 7/10")}. Generally, for
- continuous colour scales you want to keep hue constant,
- but vary chroma and luminance. The \pkg{munsell} package
- makes this easy to do using the Munsell colour system.
+Default colours are generated with \pkg{munsell} and
+\code{mnsl(c("2.5PB 2/4", "2.5PB 7/10")}. Generally, for continuous
+colour scales you want to keep hue constant, but vary chroma and
+luminance. The \pkg{munsell} package makes this easy to do using the
+Munsell colour system.
}
\examples{
\donttest{
@@ -100,26 +93,29 @@ qplot(mpg, wt, data = mtcars, colour = miss) +
}
}
\seealso{
- \code{\link[scales]{seq_gradient_pal}} for details on
- underlying palette
+\code{\link[scales]{seq_gradient_pal}} for details on underlying
+ palette
- Other colour scales: \code{\link{scale_color_brewer}},
+Other colour scales: \code{\link{scale_color_brewer}},
+ \code{\link{scale_color_distiller}},
+ \code{\link{scale_colour_brewer}},
+ \code{\link{scale_colour_distiller}},
+ \code{\link{scale_fill_brewer}},
+ \code{\link{scale_fill_distiller}};
\code{\link{scale_color_discrete}},
- \code{\link{scale_color_gradient2}},
- \code{\link{scale_color_gradientn}},
- \code{\link{scale_color_grey}},
\code{\link{scale_color_hue}},
- \code{\link{scale_colour_brewer}},
\code{\link{scale_colour_discrete}},
+ \code{\link{scale_colour_hue}},
+ \code{\link{scale_fill_discrete}},
+ \code{\link{scale_fill_hue}};
+ \code{\link{scale_color_gradient2}},
\code{\link{scale_colour_gradient2}},
+ \code{\link{scale_fill_gradient2}};
+ \code{\link{scale_color_gradientn}},
\code{\link{scale_colour_gradientn}},
+ \code{\link{scale_fill_gradientn}};
+ \code{\link{scale_color_grey}},
\code{\link{scale_colour_grey}},
- \code{\link{scale_colour_hue}},
- \code{\link{scale_fill_brewer}},
- \code{\link{scale_fill_discrete}},
- \code{\link{scale_fill_gradient2}},
- \code{\link{scale_fill_gradientn}},
- \code{\link{scale_fill_grey}},
- \code{\link{scale_fill_hue}}
+ \code{\link{scale_fill_grey}}
}
diff --git a/man/scale_gradient2.Rd b/man/scale_gradient2.Rd
index ef455f5..69d9564 100644
--- a/man/scale_gradient2.Rd
+++ b/man/scale_gradient2.Rd
@@ -1,49 +1,45 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{scale_colour_gradient2}
\alias{scale_color_gradient2}
\alias{scale_colour_gradient2}
\alias{scale_fill_gradient2}
\title{Diverging colour gradient}
\usage{
- scale_colour_gradient2(..., low = muted("red"),
- mid = "white", high = muted("blue"), midpoint = 0,
- space = "rgb", na.value = "grey50",
- guide = "colourbar")
-
- scale_fill_gradient2(..., low = muted("red"),
- mid = "white", high = muted("blue"), midpoint = 0,
- space = "rgb", na.value = "grey50",
- guide = "colourbar")
-
- scale_color_gradient2(..., low = muted("red"),
- mid = "white", high = muted("blue"), midpoint = 0,
- space = "rgb", na.value = "grey50",
- guide = "colourbar")
+scale_colour_gradient2(..., low = muted("red"), mid = "white",
+ high = muted("blue"), midpoint = 0, space = "rgb",
+ na.value = "grey50", guide = "colourbar")
+
+scale_fill_gradient2(..., low = muted("red"), mid = "white",
+ high = muted("blue"), midpoint = 0, space = "rgb",
+ na.value = "grey50", guide = "colourbar")
+
+scale_color_gradient2(..., low = muted("red"), mid = "white",
+ high = muted("blue"), midpoint = 0, space = "rgb",
+ na.value = "grey50", guide = "colourbar")
}
\arguments{
- \item{midpoint}{The midpoint (in data value) of the
- diverging scale. Defaults to 0.}
+\item{midpoint}{The midpoint (in data value) of the diverging scale.
+Defaults to 0.}
- \item{guide}{Type of legend. Use \code{"colourbar"} for
- continuous colour bar, or \code{"legend"} for discrete
- colour legend.}
+\item{guide}{Type of legend. Use \code{"colourbar"} for continuous
+colour bar, or \code{"legend"} for discrete colour legend.}
- \item{...}{Other arguments passed on to
- \code{\link{discrete_scale}} to control name, limits,
- breaks, labels and so forth.}
+\item{...}{Other arguments passed on to \code{\link{discrete_scale}}
+to control name, limits, breaks, labels and so forth.}
- \item{na.value}{Colour to use for missing values}
+\item{na.value}{Colour to use for missing values}
- \item{low}{colour for low end of gradient.}
+\item{low}{colour for low end of gradient.}
- \item{mid}{colour for mid point}
+\item{mid}{colour for mid point}
- \item{high}{colour for high end of gradient.}
+\item{high}{colour for high end of gradient.}
- \item{space}{colour space in which to calculate gradient.
- "Lab" usually best unless gradient goes through white.}
+\item{space}{colour space in which to calculate gradient. "Lab" usually
+best unless gradient goes through white.}
}
\description{
- Diverging colour gradient
+Diverging colour gradient
}
\examples{
\donttest{
@@ -81,33 +77,37 @@ d + scale_colour_gradient2(mid=muted("green"), high="white", low="white")
d + scale_colour_gradient2(midpoint=mean(diamonds$price / diamonds$carat))
# Fill gradients work much the same way
-p <- qplot(letters[1:5], 1:5, fill= c(-3, 3, 5, 2, -2), geom="bar")
+p <- qplot(letters[1:5], 1:5, fill= c(-3, 3, 5, 2, -2), geom = "bar",
+ stat = "identity")
p + scale_fill_gradient2("fill")
# Note how positive and negative values of the same magnitude
# have similar intensity
}
}
\seealso{
- Other colour scales: \code{\link{scale_color_brewer}},
+Other colour scales: \code{\link{scale_color_brewer}},
+ \code{\link{scale_color_distiller}},
+ \code{\link{scale_colour_brewer}},
+ \code{\link{scale_colour_distiller}},
+ \code{\link{scale_fill_brewer}},
+ \code{\link{scale_fill_distiller}};
\code{\link{scale_color_continuous}},
- \code{\link{scale_color_discrete}},
\code{\link{scale_color_gradient}},
- \code{\link{scale_color_gradientn}},
- \code{\link{scale_color_grey}},
- \code{\link{scale_color_hue}},
- \code{\link{scale_colour_brewer}},
\code{\link{scale_colour_continuous}},
- \code{\link{scale_colour_discrete}},
\code{\link{scale_colour_gradient}},
- \code{\link{scale_colour_gradientn}},
- \code{\link{scale_colour_grey}},
- \code{\link{scale_colour_hue}},
- \code{\link{scale_fill_brewer}},
\code{\link{scale_fill_continuous}},
+ \code{\link{scale_fill_gradient}};
+ \code{\link{scale_color_discrete}},
+ \code{\link{scale_color_hue}},
+ \code{\link{scale_colour_discrete}},
+ \code{\link{scale_colour_hue}},
\code{\link{scale_fill_discrete}},
- \code{\link{scale_fill_gradient}},
- \code{\link{scale_fill_gradientn}},
- \code{\link{scale_fill_grey}},
- \code{\link{scale_fill_hue}}
+ \code{\link{scale_fill_hue}};
+ \code{\link{scale_color_gradientn}},
+ \code{\link{scale_colour_gradientn}},
+ \code{\link{scale_fill_gradientn}};
+ \code{\link{scale_color_grey}},
+ \code{\link{scale_colour_grey}},
+ \code{\link{scale_fill_grey}}
}
diff --git a/man/scale_gradientn.Rd b/man/scale_gradientn.Rd
index 97cfd98..167cb6b 100644
--- a/man/scale_gradientn.Rd
+++ b/man/scale_gradientn.Rd
@@ -1,45 +1,40 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{scale_colour_gradientn}
\alias{scale_color_gradientn}
\alias{scale_colour_gradientn}
\alias{scale_fill_gradientn}
\title{Smooth colour gradient between n colours}
\usage{
- scale_colour_gradientn(..., colours, values = NULL,
- space = "Lab", na.value = "grey50",
- guide = "colourbar")
+scale_colour_gradientn(..., colours, values = NULL, space = "Lab",
+ na.value = "grey50", guide = "colourbar")
- scale_fill_gradientn(..., colours, values = NULL,
- space = "Lab", na.value = "grey50",
- guide = "colourbar")
+scale_fill_gradientn(..., colours, values = NULL, space = "Lab",
+ na.value = "grey50", guide = "colourbar")
- scale_color_gradientn(..., colours, values = NULL,
- space = "Lab", na.value = "grey50",
- guide = "colourbar")
+scale_color_gradientn(..., colours, values = NULL, space = "Lab",
+ na.value = "grey50", guide = "colourbar")
}
\arguments{
- \item{guide}{Type of legend. Use \code{"colourbar"} for
- continuous colour bar, or \code{"legend"} for discrete
- colour legend.}
+\item{guide}{Type of legend. Use \code{"colourbar"} for continuous
+colour bar, or \code{"legend"} for discrete colour legend.}
- \item{colours}{vector of colours}
+\item{colours}{vector of colours}
- \item{values}{if colours should not be evenly positioned
- along the gradient this vector gives the position
- (between 0 and 1) for each colour in the \code{colours}
- vector. See \code{\link{rescale}} for a convience
- function to map an arbitrary range to between 0 and 1.}
+\item{values}{if colours should not be evenly positioned along the gradient
+this vector gives the position (between 0 and 1) for each colour in the
+\code{colours} vector. See \code{\link{rescale}} for a convience function
+to map an arbitrary range to between 0 and 1.}
- \item{space}{colour space in which to calculate gradient.
- "Lab" usually best unless gradient goes through white.}
+\item{space}{colour space in which to calculate gradient. "Lab" usually
+best unless gradient goes through white.}
- \item{...}{Other arguments passed on to
- \code{\link{discrete_scale}} to control name, limits,
- breaks, labels and so forth.}
+\item{...}{Other arguments passed on to \code{\link{discrete_scale}}
+to control name, limits, breaks, labels and so forth.}
- \item{na.value}{Colour to use for missing values}
+\item{na.value}{Colour to use for missing values}
}
\description{
- Smooth colour gradient between n colours
+Smooth colour gradient between n colours
}
\examples{
\donttest{
@@ -69,26 +64,29 @@ d + scale_colour_gradientn(colours = terrain.colors(10),
}
}
\seealso{
- Other colour scales: \code{\link{scale_color_brewer}},
+Other colour scales: \code{\link{scale_color_brewer}},
+ \code{\link{scale_color_distiller}},
+ \code{\link{scale_colour_brewer}},
+ \code{\link{scale_colour_distiller}},
+ \code{\link{scale_fill_brewer}},
+ \code{\link{scale_fill_distiller}};
\code{\link{scale_color_continuous}},
- \code{\link{scale_color_discrete}},
\code{\link{scale_color_gradient}},
- \code{\link{scale_color_gradient2}},
- \code{\link{scale_color_grey}},
- \code{\link{scale_color_hue}},
- \code{\link{scale_colour_brewer}},
\code{\link{scale_colour_continuous}},
- \code{\link{scale_colour_discrete}},
\code{\link{scale_colour_gradient}},
- \code{\link{scale_colour_gradient2}},
- \code{\link{scale_colour_grey}},
- \code{\link{scale_colour_hue}},
- \code{\link{scale_fill_brewer}},
\code{\link{scale_fill_continuous}},
+ \code{\link{scale_fill_gradient}};
+ \code{\link{scale_color_discrete}},
+ \code{\link{scale_color_hue}},
+ \code{\link{scale_colour_discrete}},
+ \code{\link{scale_colour_hue}},
\code{\link{scale_fill_discrete}},
- \code{\link{scale_fill_gradient}},
- \code{\link{scale_fill_gradient2}},
- \code{\link{scale_fill_grey}},
- \code{\link{scale_fill_hue}}
+ \code{\link{scale_fill_hue}};
+ \code{\link{scale_color_gradient2}},
+ \code{\link{scale_colour_gradient2}},
+ \code{\link{scale_fill_gradient2}};
+ \code{\link{scale_color_grey}},
+ \code{\link{scale_colour_grey}},
+ \code{\link{scale_fill_grey}}
}
diff --git a/man/scale_grey.Rd b/man/scale_grey.Rd
index c3e8c89..6f30809 100644
--- a/man/scale_grey.Rd
+++ b/man/scale_grey.Rd
@@ -1,31 +1,28 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{scale_colour_grey}
\alias{scale_color_grey}
\alias{scale_colour_grey}
\alias{scale_fill_grey}
\title{Sequential grey colour scale.}
\usage{
- scale_colour_grey(..., start = 0.2, end = 0.8,
- na.value = "red")
+scale_colour_grey(..., start = 0.2, end = 0.8, na.value = "red")
- scale_fill_grey(..., start = 0.2, end = 0.8,
- na.value = "grey50")
+scale_fill_grey(..., start = 0.2, end = 0.8, na.value = "grey50")
- scale_color_grey(..., start = 0.2, end = 0.8,
- na.value = "red")
+scale_color_grey(..., start = 0.2, end = 0.8, na.value = "red")
}
\arguments{
- \item{start}{gray value at low end of palette}
+\item{start}{gray value at low end of palette}
- \item{end}{gray value at high end of palette}
+\item{end}{gray value at high end of palette}
- \item{...}{Other arguments passed on to
- \code{\link{discrete_scale}} to control name, limits,
- breaks, labels and so forth.}
+\item{...}{Other arguments passed on to \code{\link{discrete_scale}}
+to control name, limits, breaks, labels and so forth.}
- \item{na.value}{Colour to use for missing values}
+\item{na.value}{Colour to use for missing values}
}
\description{
- Based on \code{\link{gray.colors}}
+Based on \code{\link{gray.colors}}
}
\examples{
p <- qplot(mpg, wt, data=mtcars, colour=factor(cyl))
@@ -42,26 +39,29 @@ qplot(mpg, wt, data = mtcars, colour = miss) +
scale_colour_grey(na.value = "green")
}
\seealso{
- Other colour scales: \code{\link{scale_color_brewer}},
+Other colour scales: \code{\link{scale_color_brewer}},
+ \code{\link{scale_color_distiller}},
+ \code{\link{scale_colour_brewer}},
+ \code{\link{scale_colour_distiller}},
+ \code{\link{scale_fill_brewer}},
+ \code{\link{scale_fill_distiller}};
\code{\link{scale_color_continuous}},
- \code{\link{scale_color_discrete}},
\code{\link{scale_color_gradient}},
- \code{\link{scale_color_gradient2}},
- \code{\link{scale_color_gradientn}},
- \code{\link{scale_color_hue}},
- \code{\link{scale_colour_brewer}},
\code{\link{scale_colour_continuous}},
- \code{\link{scale_colour_discrete}},
\code{\link{scale_colour_gradient}},
- \code{\link{scale_colour_gradient2}},
- \code{\link{scale_colour_gradientn}},
- \code{\link{scale_colour_hue}},
- \code{\link{scale_fill_brewer}},
\code{\link{scale_fill_continuous}},
+ \code{\link{scale_fill_gradient}};
+ \code{\link{scale_color_discrete}},
+ \code{\link{scale_color_hue}},
+ \code{\link{scale_colour_discrete}},
+ \code{\link{scale_colour_hue}},
\code{\link{scale_fill_discrete}},
- \code{\link{scale_fill_gradient}},
- \code{\link{scale_fill_gradient2}},
- \code{\link{scale_fill_gradientn}},
- \code{\link{scale_fill_hue}}
+ \code{\link{scale_fill_hue}};
+ \code{\link{scale_color_gradient2}},
+ \code{\link{scale_colour_gradient2}},
+ \code{\link{scale_fill_gradient2}};
+ \code{\link{scale_color_gradientn}},
+ \code{\link{scale_colour_gradientn}},
+ \code{\link{scale_fill_gradientn}}
}
diff --git a/man/scale_hue.Rd b/man/scale_hue.Rd
index a60431e..10304ad 100644
--- a/man/scale_hue.Rd
+++ b/man/scale_hue.Rd
@@ -1,3 +1,4 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{scale_colour_hue}
\alias{scale_color_discrete}
\alias{scale_color_hue}
@@ -7,49 +8,43 @@
\alias{scale_fill_hue}
\title{Qualitative colour scale with evenly spaced hues.}
\usage{
- scale_colour_hue(..., h = c(0, 360) + 15, c = 100,
- l = 65, h.start = 0, direction = 1,
- na.value = "grey50")
+scale_colour_hue(..., h = c(0, 360) + 15, c = 100, l = 65, h.start = 0,
+ direction = 1, na.value = "grey50")
- scale_fill_hue(..., h = c(0, 360) + 15, c = 100, l = 65,
- h.start = 0, direction = 1, na.value = "grey50")
+scale_fill_hue(..., h = c(0, 360) + 15, c = 100, l = 65, h.start = 0,
+ direction = 1, na.value = "grey50")
- scale_colour_discrete(..., h = c(0, 360) + 15, c = 100,
- l = 65, h.start = 0, direction = 1,
- na.value = "grey50")
+scale_colour_discrete(..., h = c(0, 360) + 15, c = 100, l = 65,
+ h.start = 0, direction = 1, na.value = "grey50")
- scale_fill_discrete(..., h = c(0, 360) + 15, c = 100,
- l = 65, h.start = 0, direction = 1,
- na.value = "grey50")
+scale_fill_discrete(..., h = c(0, 360) + 15, c = 100, l = 65,
+ h.start = 0, direction = 1, na.value = "grey50")
- scale_color_discrete(..., h = c(0, 360) + 15, c = 100,
- l = 65, h.start = 0, direction = 1,
- na.value = "grey50")
+scale_color_discrete(..., h = c(0, 360) + 15, c = 100, l = 65,
+ h.start = 0, direction = 1, na.value = "grey50")
- scale_color_hue(..., h = c(0, 360) + 15, c = 100, l = 65,
- h.start = 0, direction = 1, na.value = "grey50")
+scale_color_hue(..., h = c(0, 360) + 15, c = 100, l = 65, h.start = 0,
+ direction = 1, na.value = "grey50")
}
\arguments{
- \item{na.value}{Colour to use for missing values}
+\item{na.value}{Colour to use for missing values}
- \item{...}{Other arguments passed on to
- \code{\link{discrete_scale}} to control name, limits,
- breaks, labels and so forth.}
+\item{...}{Other arguments passed on to \code{\link{discrete_scale}}
+to control name, limits, breaks, labels and so forth.}
- \item{h}{range of hues to use, in [0, 360]}
+\item{h}{range of hues to use, in [0, 360]}
- \item{c}{chroma (intensity of colour), maximum value
- varies depending on}
+\item{c}{chroma (intensity of colour), maximum value varies depending on}
- \item{l}{luminance (lightness), in [0, 100]}
+\item{l}{luminance (lightness), in [0, 100]}
- \item{h.start}{hue to start at}
+\item{h.start}{hue to start at}
- \item{direction}{direction to travel around the colour
- wheel, 1 = clockwise, -1 = counter-clockwise}
+\item{direction}{direction to travel around the colour wheel,
+1 = clockwise, -1 = counter-clockwise}
}
\description{
- Qualitative colour scale with evenly spaced hues.
+Qualitative colour scale with evenly spaced hues.
}
\examples{
\donttest{
@@ -88,23 +83,26 @@ qplot(mpg, wt, data = mtcars, colour = miss) +
}
}
\seealso{
- Other colour scales: \code{\link{scale_color_brewer}},
+Other colour scales: \code{\link{scale_color_brewer}},
+ \code{\link{scale_color_distiller}},
+ \code{\link{scale_colour_brewer}},
+ \code{\link{scale_colour_distiller}},
+ \code{\link{scale_fill_brewer}},
+ \code{\link{scale_fill_distiller}};
\code{\link{scale_color_continuous}},
\code{\link{scale_color_gradient}},
- \code{\link{scale_color_gradient2}},
- \code{\link{scale_color_gradientn}},
- \code{\link{scale_color_grey}},
- \code{\link{scale_colour_brewer}},
\code{\link{scale_colour_continuous}},
\code{\link{scale_colour_gradient}},
+ \code{\link{scale_fill_continuous}},
+ \code{\link{scale_fill_gradient}};
+ \code{\link{scale_color_gradient2}},
\code{\link{scale_colour_gradient2}},
+ \code{\link{scale_fill_gradient2}};
+ \code{\link{scale_color_gradientn}},
\code{\link{scale_colour_gradientn}},
+ \code{\link{scale_fill_gradientn}};
+ \code{\link{scale_color_grey}},
\code{\link{scale_colour_grey}},
- \code{\link{scale_fill_brewer}},
- \code{\link{scale_fill_continuous}},
- \code{\link{scale_fill_gradient}},
- \code{\link{scale_fill_gradient2}},
- \code{\link{scale_fill_gradientn}},
\code{\link{scale_fill_grey}}
}
diff --git a/man/scale_identity.Rd b/man/scale_identity.Rd
index 080222e..e32c320 100644
--- a/man/scale_identity.Rd
+++ b/man/scale_identity.Rd
@@ -1,3 +1,4 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{scale_identity}
\alias{scale_alpha_identity}
\alias{scale_color_identity}
@@ -9,30 +10,28 @@
\alias{scale_size_identity}
\title{Use values without scaling.}
\usage{
- scale_colour_identity(..., guide = "none")
+scale_colour_identity(..., guide = "none")
- scale_fill_identity(..., guide = "none")
+scale_fill_identity(..., guide = "none")
- scale_shape_identity(..., guide = "none")
+scale_shape_identity(..., guide = "none")
- scale_linetype_identity(..., guide = "none")
+scale_linetype_identity(..., guide = "none")
- scale_alpha_identity(..., guide = "none")
+scale_alpha_identity(..., guide = "none")
- scale_size_identity(..., guide = "none")
+scale_size_identity(..., guide = "none")
- scale_color_identity(..., guide = "none")
+scale_color_identity(..., guide = "none")
}
\arguments{
- \item{...}{Other arguments passed on to
- \code{\link{discrete_scale}} or
- \code{\link{continuous_scale}}}
+\item{...}{Other arguments passed on to \code{\link{discrete_scale}} or
+\code{\link{continuous_scale}}}
- \item{guide}{Guide to use for this scale - defaults to
- \code{"none"}.}
+\item{guide}{Guide to use for this scale - defaults to \code{"none"}.}
}
\description{
- Use values without scaling.
+Use values without scaling.
}
\examples{
colour <- c("red", "green", "blue", "yellow")
diff --git a/man/scale_linetype.Rd b/man/scale_linetype.Rd
index c98c729..1e6de86 100644
--- a/man/scale_linetype.Rd
+++ b/man/scale_linetype.Rd
@@ -1,28 +1,27 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{scale_linetype}
\alias{scale_linetype}
\alias{scale_linetype_continuous}
\alias{scale_linetype_discrete}
\title{Scale for line patterns.}
\usage{
- scale_linetype(..., na.value = "blank")
+scale_linetype(..., na.value = "blank")
- scale_linetype_continuous(...)
+scale_linetype_continuous(...)
- scale_linetype_discrete(..., na.value = "blank")
+scale_linetype_discrete(..., na.value = "blank")
}
\arguments{
- \item{na.value}{The linetype to use for \code{NA}
- values.}
+\item{na.value}{The linetype to use for \code{NA} values.}
- \item{...}{common discrete scale parameters: \code{name},
- \code{breaks}, \code{labels}, \code{na.value},
- \code{limits} and \code{guide}. See
- \code{\link{discrete_scale}} for more details}
+\item{...}{common discrete scale parameters: \code{name}, \code{breaks},
+\code{labels}, \code{na.value}, \code{limits} and \code{guide}. See
+\code{\link{discrete_scale}} for more details}
}
\description{
- Default line types based on a set supplied by Richard
- Pearson, University of Manchester. Line types can not be
- mapped to continuous values.
+Default line types based on a set supplied by Richard Pearson,
+University of Manchester. Line types can not be mapped to continuous
+values.
}
\examples{
library(reshape2) # for melt
diff --git a/man/scale_manual.Rd b/man/scale_manual.Rd
index 8a266c7..a1f074e 100644
--- a/man/scale_manual.Rd
+++ b/man/scale_manual.Rd
@@ -1,3 +1,4 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{scale_manual}
\alias{scale_alpha_manual}
\alias{scale_color_manual}
@@ -9,35 +10,33 @@
\alias{scale_size_manual}
\title{Create your own discrete scale.}
\usage{
- scale_colour_manual(..., values)
+scale_colour_manual(..., values)
- scale_fill_manual(..., values)
+scale_fill_manual(..., values)
- scale_size_manual(..., values)
+scale_size_manual(..., values)
- scale_shape_manual(..., values)
+scale_shape_manual(..., values)
- scale_linetype_manual(..., values)
+scale_linetype_manual(..., values)
- scale_alpha_manual(..., values)
+scale_alpha_manual(..., values)
- scale_color_manual(..., values)
+scale_color_manual(..., values)
}
\arguments{
- \item{values}{a set of aesthetic values to map data
- values to. If this is a named vector, then the values
- will be matched based on the names. If unnamed, values
- will be matched in order (usually alphabetical) with the
- limits of the scale. Any data values that don't match
- will be given \code{na.value}.}
+\item{values}{a set of aesthetic values to map data values to. If this
+is a named vector, then the values will be matched based on the names.
+If unnamed, values will be matched in order (usually alphabetical) with
+the limits of the scale. Any data values that don't match will be
+given \code{na.value}.}
- \item{...}{common discrete scale parameters: \code{name},
- \code{breaks}, \code{labels}, \code{na.value},
- \code{limits} and \code{guide}. See
- \code{\link{discrete_scale}} for more details}
+\item{...}{common discrete scale parameters: \code{name}, \code{breaks},
+\code{labels}, \code{na.value}, \code{limits} and \code{guide}. See
+\code{\link{discrete_scale}} for more details}
}
\description{
- Create your own discrete scale.
+Create your own discrete scale.
}
\examples{
\donttest{
diff --git a/man/scale_shape.Rd b/man/scale_shape.Rd
index ad1a2a3..e541ad5 100644
--- a/man/scale_shape.Rd
+++ b/man/scale_shape.Rd
@@ -1,26 +1,25 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{scale_shape}
\alias{scale_shape}
\alias{scale_shape_continuous}
\alias{scale_shape_discrete}
\title{Scale for shapes, aka glyphs.}
\usage{
- scale_shape(..., solid = TRUE)
+scale_shape(..., solid = TRUE)
- scale_shape_discrete(..., solid = TRUE)
+scale_shape_discrete(..., solid = TRUE)
- scale_shape_continuous(...)
+scale_shape_continuous(...)
}
\arguments{
- \item{solid}{Are the shapes solid, \code{TRUE}, or hollow
- \code{FALSE}?}
+\item{solid}{Are the shapes solid, \code{TRUE}, or hollow \code{FALSE}?}
- \item{...}{common discrete scale parameters: \code{name},
- \code{breaks}, \code{labels}, \code{na.value},
- \code{limits} and \code{guide}. See
- \code{\link{discrete_scale}} for more details}
+\item{...}{common discrete scale parameters: \code{name}, \code{breaks},
+\code{labels}, \code{na.value}, \code{limits} and \code{guide}. See
+\code{\link{discrete_scale}} for more details}
}
\description{
- A continuous variable can not be mapped to shape.
+A continuous variable can not be mapped to shape.
}
\examples{
dsmall <- diamonds[sample(nrow(diamonds), 100), ]
diff --git a/man/scale_size.Rd b/man/scale_size.Rd
index bcc06e5..2217863 100644
--- a/man/scale_size.Rd
+++ b/man/scale_size.Rd
@@ -1,27 +1,26 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{scale_size}
\alias{scale_size}
\alias{scale_size_continuous}
\alias{scale_size_discrete}
\title{Size scale.}
\usage{
- scale_size_continuous(..., range = c(1, 6))
+scale_size_continuous(..., range = c(1, 6))
- scale_size(..., range = c(1, 6))
+scale_size(..., range = c(1, 6))
- scale_size_discrete(..., range = c(1, 6))
+scale_size_discrete(..., range = c(1, 6))
}
\arguments{
- \item{range}{a numeric vector of length 2 that specifies
- the minimum and maximum size of the plotting symbol after
- transformation.}
-
- \item{...}{common continuous scale parameters:
- \code{name}, \code{breaks}, \code{labels},
- \code{na.value}, \code{limits} and \code{trans}. See
- \code{\link{continuous_scale}} for more details}
+\item{range}{a numeric vector of length 2 that specifies the minimum and
+maximum size of the plotting symbol after transformation.}
+
+\item{...}{common continuous scale parameters: \code{name}, \code{breaks},
+\code{labels}, \code{na.value}, \code{limits} and \code{trans}. See
+\code{\link{continuous_scale}} for more details}
}
\description{
- Size scale.
+Size scale.
}
\examples{
\donttest{
@@ -34,8 +33,8 @@ p + scale_size(range = c(1, 2))
# Map area, instead of width/radius
# Perceptually, this is a little better
-p + scale_area()
-p + scale_area(range = c(1, 25))
+p + scale_size_area()
+p + scale_size_area(max_size = 25)
# Also works with factors, but not a terribly good
# idea, unless your factor is ordered, as in this example
diff --git a/man/scale_size_area.Rd b/man/scale_size_area.Rd
index e3ea4b9..d7c2114 100644
--- a/man/scale_size_area.Rd
+++ b/man/scale_size_area.Rd
@@ -1,25 +1,23 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{scale_size_area}
\alias{scale_size_area}
\title{Scale area instead of radius, for size.}
\usage{
- scale_size_area(..., max_size = 6)
+scale_size_area(..., max_size = 6)
}
\arguments{
- \item{...}{Other arguments passed on to
- \code{\link{continuous_scale}} to control name, limits,
- breaks, labels and so forth.}
+\item{...}{Other arguments passed on to \code{\link{continuous_scale}}
+to control name, limits, breaks, labels and so forth.}
- \item{max_size}{Size of largest points.}
+\item{max_size}{Size of largest points.}
}
\description{
- When \code{scale_size_area} is used, the default behavior
- is to scale the area of points to be proportional to the
- value.
+When \code{scale_size_area} is used, the default behavior is to scale the
+area of points to be proportional to the value.
}
\details{
- Note that this controls the size scale, so it will also
- control the thickness of lines. Line thickness will be
- proportional to the square root of the value, which is
- probably undesirable in most cases.
+Note that this controls the size scale, so it will also control
+the thickness of lines. Line thickness will be proportional to the square
+root of the value, which is probably undesirable in most cases.
}
diff --git a/man/seals.Rd b/man/seals.Rd
index 01edd0c..d4135e6 100644
--- a/man/seals.Rd
+++ b/man/seals.Rd
@@ -1,19 +1,22 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\docType{data}
\name{seals}
\alias{seals}
\title{Vector field of seal movements.}
\format{A data frame with 1155 rows and 4 variables}
+\usage{
+data(seals)
+}
\description{
- This vector field was produced from the data described in
- Brillinger, D.R., Preisler, H.K., Ager, A.A. and Kie,
- J.G. "An exploratory data analysis (EDA) of the paths of
- moving animals". J. Statistical Planning and Inference
- 122 (2004), 43-63, using the methods of Brillinger, D.R.,
- "Learning a potential function from a trajectory", Signal
- Processing Letters. December (2007).
+This vector field was produced from the data described in Brillinger, D.R.,
+Preisler, H.K., Ager, A.A. and Kie, J.G. "An exploratory data analysis
+(EDA) of the paths of moving animals". J. Statistical Planning and
+Inference 122 (2004), 43-63, using the methods of Brillinger, D.R.,
+"Learning a potential function from a trajectory", Signal Processing
+ Letters. December (2007).
}
\references{
- \url{http://www.stat.berkeley.edu/~brill/Papers/jspifinal.pdf}
+\url{http://www.stat.berkeley.edu/~brill/Papers/jspifinal.pdf}
}
\keyword{datasets}
diff --git a/man/should_stop.Rd b/man/should_stop.Rd
index 73da261..17af22d 100644
--- a/man/should_stop.Rd
+++ b/man/should_stop.Rd
@@ -1,14 +1,15 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{should_stop}
\alias{should_stop}
\title{Used in examples to illustrate when errors should occur.}
\usage{
- should_stop(expr)
+should_stop(expr)
}
\arguments{
- \item{expr}{code to evaluate.}
+\item{expr}{code to evaluate.}
}
\description{
- Used in examples to illustrate when errors should occur.
+Used in examples to illustrate when errors should occur.
}
\examples{
should_stop(stop("Hi!"))
diff --git a/man/stat_abline.Rd b/man/stat_abline.Rd
index cd784f0..738dbe8 100644
--- a/man/stat_abline.Rd
+++ b/man/stat_abline.Rd
@@ -1,37 +1,36 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{stat_abline}
\alias{stat_abline}
\title{Add a line with slope and intercept.}
\usage{
- stat_abline(mapping = NULL, data = NULL, geom = "abline",
- position = "identity", ...)
+stat_abline(mapping = NULL, data = NULL, geom = "abline",
+ position = "identity", ...)
}
\arguments{
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{geom}{The geometric object to use display the data}
+\item{geom}{The geometric object to use display the data}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlappling points
+on this layer}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\description{
- Add a line with slope and intercept.
+Add a line with slope and intercept.
}
\examples{
# see geom_abline
}
\seealso{
- \code{\link{geom_abline}} for code examples.
+\code{\link{geom_abline}} for code examples.
}
\keyword{internal}
diff --git a/man/stat_bin.Rd b/man/stat_bin.Rd
index 2eb00ed..ba1fc16 100644
--- a/man/stat_bin.Rd
+++ b/man/stat_bin.Rd
@@ -1,69 +1,65 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{stat_bin}
\alias{stat_bin}
\title{Bin data.}
\usage{
- stat_bin(mapping = NULL, data = NULL, geom = "bar",
- position = "stack", width = 0.9, drop = FALSE,
- right = FALSE, binwidth = NULL, origin = NULL,
- breaks = NULL, ...)
+stat_bin(mapping = NULL, data = NULL, geom = "bar", position = "stack",
+ width = 0.9, drop = FALSE, right = FALSE, binwidth = NULL,
+ origin = NULL, breaks = NULL, ...)
}
\arguments{
- \item{binwidth}{Bin width to use. Defaults to 1/30 of the
- range of the data}
+\item{binwidth}{Bin width to use. Defaults to 1/30 of the range of the
+data}
- \item{breaks}{Actual breaks to use. Overrides bin width
- and origin}
+\item{breaks}{Actual breaks to use. Overrides bin width and origin}
- \item{origin}{Origin of first bin}
+\item{origin}{Origin of first bin}
- \item{width}{Width of bars when used with categorical
- data}
+\item{width}{Width of bars when used with categorical data}
- \item{right}{If \code{TRUE}, right-closed, left-open, if
- \code{FALSE},}
+\item{right}{If \code{TRUE}, right-closed, left-open, if \code{FALSE},
+the default, right-open, left-closed.}
- \item{drop}{If TRUE, remove all bins with zero counts}
+\item{drop}{If TRUE, remove all bins with zero counts}
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{geom}{The geometric object to use display the data}
+\item{geom}{The geometric object to use display the data}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlappling points
+on this layer}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\value{
- New data frame with additional columns:
+New data frame with additional columns:
\item{count}{number of points in bin}
- \item{density}{density of points in bin, scaled to
- integrate to 1} \item{ncount}{count, scaled to maximum of
- 1} \item{ndensity}{density, scaled to maximum of 1}
+ \item{density}{density of points in bin, scaled to integrate to 1}
+ \item{ncount}{count, scaled to maximum of 1}
+ \item{ndensity}{density, scaled to maximum of 1}
}
\description{
- Missing values are currently silently dropped.
+Missing values are currently silently dropped.
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat",
- "bin")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat", "bin")}
}
\examples{
\donttest{
simple <- data.frame(x = rep(1:10, each = 2))
base <- ggplot(simple, aes(x))
-# By default, right = TRUE, and intervals are of the form (a, b]
-base + stat_bin(binwidth = 1, drop = FALSE, right = TRUE, col = "black")
-# If right = FALSE intervals are of the form [a, b)
+# By default, right = FALSE intervals are of the form [a, b)
base + stat_bin(binwidth = 1, drop = FALSE, right = FALSE, col = "black")
+# If right = TRUE, and intervals are of the form (a, b]
+base + stat_bin(binwidth = 1, drop = FALSE, right = TRUE, col = "black")
m <- ggplot(movies, aes(x=rating))
m + stat_bin()
diff --git a/man/stat_bin2d.Rd b/man/stat_bin2d.Rd
index b42ef33..6408dbb 100644
--- a/man/stat_bin2d.Rd
+++ b/man/stat_bin2d.Rd
@@ -1,42 +1,39 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{stat_bin2d}
\alias{stat_bin2d}
\title{Count number of observation in rectangular bins.}
\usage{
- stat_bin2d(mapping = NULL, data = NULL, geom = NULL,
- position = "identity", bins = 30, drop = TRUE, ...)
+stat_bin2d(mapping = NULL, data = NULL, geom = NULL,
+ position = "identity", bins = 30, drop = TRUE, ...)
}
\arguments{
- \item{bins}{numeric vector giving number of bins in both
- vertical and horizontal directions. Set to 30 by
- default.}
+\item{bins}{numeric vector giving number of bins in both vertical and
+horizontal directions. Set to 30 by default.}
- \item{drop}{if \code{TRUE} removes all cells with 0
- counts.}
+\item{drop}{if \code{TRUE} removes all cells with 0 counts.}
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{geom}{The geometric object to use display the data}
+\item{geom}{The geometric object to use display the data}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlappling points
+on this layer}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\description{
- Count number of observation in rectangular bins.
+Count number of observation in rectangular bins.
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat",
- "bin2d")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat", "bin2d")}
}
\examples{
\donttest{
@@ -66,6 +63,6 @@ qplot(x, y, data = diamonds, geom="bin2d", binwidth = c(0.1, 0.1),
}
}
\seealso{
- \code{\link{stat_binhex}} for hexagonal binning
+\code{\link{stat_binhex}} for hexagonal binning
}
diff --git a/man/stat_bindot.Rd b/man/stat_bindot.Rd
index a719660..1ce74f2 100644
--- a/man/stat_bindot.Rd
+++ b/man/stat_bindot.Rd
@@ -1,90 +1,81 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{stat_bindot}
\alias{stat_bindot}
\title{Bin data for dot plot.}
\usage{
- stat_bindot(mapping = NULL, data = NULL,
- geom = "dotplot", position = "identity",
- binwidth = NULL, origin = NULL, width = 0.9,
- binaxis = "x", method = "dotdensity",
- binpositions = "bygroup", drop = FALSE, right = TRUE,
- na.rm = FALSE, ...)
+stat_bindot(mapping = NULL, data = NULL, geom = "dotplot",
+ position = "identity", binwidth = NULL, origin = NULL, width = 0.9,
+ binaxis = "x", method = "dotdensity", binpositions = "bygroup",
+ drop = FALSE, right = TRUE, na.rm = FALSE, ...)
}
\arguments{
- \item{binaxis}{The axis to bin along, "x" (default) or
- "y"}
+\item{binaxis}{The axis to bin along, "x" (default) or "y"}
- \item{method}{"dotdensity" (default) for dot-density
- binning, or "histodot" for fixed bin widths (like
- stat_bin)}
+\item{method}{"dotdensity" (default) for dot-density binning, or
+"histodot" for fixed bin widths (like stat_bin)}
- \item{binwidth}{When \code{method} is "dotdensity, this
- specifies maximum bin width. When \code{method} is
- "histodot", this specifies bin width. Defaults to 1/30
- of the range of the data}
+\item{binwidth}{When \code{method} is "dotdensity, this specifies maximum bin width.
+When \code{method} is "histodot", this specifies bin width.
+Defaults to 1/30 of the range of the data}
- \item{binpositions}{When \code{method} is "dotdensity",
- "bygroup" (default) determines positions of the bins for
- each group separately. "all" determines positions of the
- bins with all the data taken together; this is used for
- aligning dot stacks across multiple groups.}
+\item{binpositions}{When \code{method} is "dotdensity", "bygroup" (default)
+determines positions of the bins for each group separately. "all" determines
+positions of the bins with all the data taken together; this is used for
+aligning dot stacks across multiple groups.}
- \item{origin}{When \code{method} is "histodot", origin of
- first bin}
+\item{origin}{When \code{method} is "histodot", origin of first bin}
- \item{right}{When \code{method} is "histodot", should
- intervals be closed on the right (a, b], or not [a, b)}
+\item{right}{When \code{method} is "histodot", should intervals be closed
+on the right (a, b], or not [a, b)}
- \item{width}{When \code{binaxis} is "y", the spacing of
- the dot stacks for dodging.}
+\item{width}{When \code{binaxis} is "y", the spacing of the dot stacks
+for dodging.}
- \item{na.rm}{If \code{FALSE} (the default), removes
- missing values with a warning. If \code{TRUE} silently
- removes missing values.}
+\item{na.rm}{If \code{FALSE} (the default), removes missing values with
+a warning. If \code{TRUE} silently removes missing values.}
- \item{drop}{If TRUE, remove all bins with zero counts}
+\item{drop}{If TRUE, remove all bins with zero counts}
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{geom}{The geometric object to use display the data}
+\item{geom}{The geometric object to use display the data}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlappling points
+on this layer}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\value{
- New data frame with additional columns: \item{x}{center
- of each bin, if binaxis is "x"} \item{y}{center of each
- bin, if binaxis is "x"} \item{binwidth}{max width of each
- bin if method is "dotdensity"; width of each bin if
- method is "histodot"} \item{count}{number of points in
- bin} \item{ncount}{count, scaled to maximum of 1}
- \item{density}{density of points in bin, scaled to
- integrate to 1, if method is "histodot"}
- \item{ndensity}{density, scaled to maximum of 1, if
- method is "histodot"}
+New data frame with additional columns:
+ \item{x}{center of each bin, if binaxis is "x"}
+ \item{y}{center of each bin, if binaxis is "x"}
+ \item{binwidth}{max width of each bin if method is "dotdensity";
+ width of each bin if method is "histodot"}
+ \item{count}{number of points in bin}
+ \item{ncount}{count, scaled to maximum of 1}
+ \item{density}{density of points in bin, scaled to integrate to 1,
+ if method is "histodot"}
+ \item{ndensity}{density, scaled to maximum of 1, if method is "histodot"}
}
\description{
- Missing values are currently silently dropped. If weights
- are used, they must be integer values.
+Missing values are currently silently dropped.
+If weights are used, they must be integer values.
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat",
- "bindot")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat", "bindot")}
}
\examples{
# See geom_dotplot for examples
}
\seealso{
- See \code{\link{geom_dotplot}} for examples.
+See \code{\link{geom_dotplot}} for examples.
}
diff --git a/man/stat_binhex.Rd b/man/stat_binhex.Rd
index 7db04e3..7727222 100644
--- a/man/stat_binhex.Rd
+++ b/man/stat_binhex.Rd
@@ -1,42 +1,40 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{stat_binhex}
\alias{stat_binhex}
\title{Bin 2d plane into hexagons.}
\usage{
- stat_binhex(mapping = NULL, data = NULL, geom = "hex",
- position = "identity", bins = 30, na.rm = FALSE, ...)
+stat_binhex(mapping = NULL, data = NULL, geom = "hex",
+ position = "identity", bins = 30, na.rm = FALSE, ...)
}
\arguments{
- \item{bins}{numeric vector specifying number of bins in
- both x and y directions. Set to 30 by default.}
+\item{bins}{numeric vector specifying number of bins in both x and y
+directions. Set to 30 by default.}
- \item{na.rm}{If \code{FALSE} (the default), removes
- missing values with a warning. If \code{TRUE} silently
- removes missing values.}
+\item{na.rm}{If \code{FALSE} (the default), removes missing values with
+a warning. If \code{TRUE} silently removes missing values.}
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{geom}{The geometric object to use display the data}
+\item{geom}{The geometric object to use display the data}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlappling points
+on this layer}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\description{
- Bin 2d plane into hexagons.
+Bin 2d plane into hexagons.
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat",
- "binhex")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat", "binhex")}
}
\examples{
\donttest{
@@ -60,6 +58,6 @@ qplot(x, y, data = diamonds, geom="hex", xlim = c(4, 10), ylim = c(4, 10),
}
}
\seealso{
- \code{\link{stat_bin2d}} for rectangular binning
+\code{\link{stat_bin2d}} for rectangular binning
}
diff --git a/man/stat_boxplot.Rd b/man/stat_boxplot.Rd
index 4c5e8b4..69e02ce 100644
--- a/man/stat_boxplot.Rd
+++ b/man/stat_boxplot.Rd
@@ -1,60 +1,55 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{stat_boxplot}
\alias{stat_boxplot}
\title{Calculate components of box and whisker plot.}
\usage{
- stat_boxplot(mapping = NULL, data = NULL,
- geom = "boxplot", position = "dodge", na.rm = FALSE,
- coef = 1.5, ...)
+stat_boxplot(mapping = NULL, data = NULL, geom = "boxplot",
+ position = "dodge", na.rm = FALSE, coef = 1.5, ...)
}
\arguments{
- \item{coef}{length of the whiskers as multiple of IQR.
- Defaults to 1.5}
+\item{coef}{length of the whiskers as multiple of IQR. Defaults to 1.5}
- \item{na.rm}{If \code{FALSE} (the default), removes
- missing values with a warning. If \code{TRUE} silently
- removes missing values.}
+\item{na.rm}{If \code{FALSE} (the default), removes missing values with
+a warning. If \code{TRUE} silently removes missing values.}
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{geom}{The geometric object to use display the data}
+\item{geom}{The geometric object to use display the data}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlappling points
+on this layer}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\value{
- A data frame with additional columns: \item{width}{width
- of boxplot} \item{ymin}{lower whisker = smallest
- observation greater than or equal to lower hinge - 1.5 *
- IQR} \item{lower}{lower hinge, 25\% quantile}
- \item{notchlower}{lower edge of notch = median - 1.58 *
- IQR / sqrt(n)} \item{middle}{median, 50\% quantile}
- \item{notchupper}{upper edge of notch = median + 1.58 *
- IQR / sqrt(n)} \item{upper}{upper hinge, 75\% quantile}
- \item{ymax}{upper whisker = largest observation less than
- or equal to upper hinge + 1.5 * IQR}
+A data frame with additional columns:
+ \item{width}{width of boxplot}
+ \item{ymin}{lower whisker = smallest observation greater than or equal to lower hinge - 1.5 * IQR}
+ \item{lower}{lower hinge, 25\% quantile}
+ \item{notchlower}{lower edge of notch = median - 1.58 * IQR / sqrt(n)}
+ \item{middle}{median, 50\% quantile}
+ \item{notchupper}{upper edge of notch = median + 1.58 * IQR / sqrt(n)}
+ \item{upper}{upper hinge, 75\% quantile}
+ \item{ymax}{upper whisker = largest observation less than or equal to upper hinge + 1.5 * IQR}
}
\description{
- Calculate components of box and whisker plot.
+Calculate components of box and whisker plot.
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat",
- "boxplot")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat", "boxplot")}
}
\examples{
# See geom_boxplot for examples
}
\seealso{
- See \code{\link{geom_boxplot}} for examples.
+See \code{\link{geom_boxplot}} for examples.
}
diff --git a/man/stat_contour.Rd b/man/stat_contour.Rd
index 4f8e0e7..52d14bf 100644
--- a/man/stat_contour.Rd
+++ b/man/stat_contour.Rd
@@ -1,43 +1,41 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{stat_contour}
\alias{stat_contour}
\title{Calculate contours of 3d data.}
\usage{
- stat_contour(mapping = NULL, data = NULL, geom = "path",
- position = "identity", na.rm = FALSE, ...)
+stat_contour(mapping = NULL, data = NULL, geom = "path",
+ position = "identity", na.rm = FALSE, ...)
}
\arguments{
- \item{na.rm}{If \code{FALSE} (the default), removes
- missing values with a warning. If \code{TRUE} silently
- removes missing values.}
+\item{na.rm}{If \code{FALSE} (the default), removes missing values with
+a warning. If \code{TRUE} silently removes missing values.}
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{geom}{The geometric object to use display the data}
+\item{geom}{The geometric object to use display the data}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlappling points
+on this layer}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\value{
- A data frame with additional column: \item{level}{height
- of contour}
+A data frame with additional column:
+ \item{level}{height of contour}
}
\description{
- Calculate contours of 3d data.
+Calculate contours of 3d data.
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat",
- "contour")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat", "contour")}
}
\examples{
\donttest{
diff --git a/man/stat_density.Rd b/man/stat_density.Rd
index 441ba1a..2490803 100644
--- a/man/stat_density.Rd
+++ b/man/stat_density.Rd
@@ -1,57 +1,55 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{stat_density}
\alias{stat_density}
\title{1d kernel density estimate.}
\usage{
- stat_density(mapping = NULL, data = NULL, geom = "area",
- position = "stack", adjust = 1, kernel = "gaussian",
- trim = FALSE, na.rm = FALSE, ...)
+stat_density(mapping = NULL, data = NULL, geom = "area",
+ position = "stack", adjust = 1, kernel = "gaussian", trim = FALSE,
+ na.rm = FALSE, ...)
}
\arguments{
- \item{adjust}{see \code{\link{density}} for details}
+\item{adjust}{see \code{\link{density}} for details}
- \item{kernel}{kernel used for density estimation, see
- \code{\link{density}} for details}
+\item{kernel}{kernel used for density estimation, see
+\code{\link{density}} for details}
- \item{trim}{if \code{TRUE}, the default, densities are
- trimmed to the actual range of the data. If
- \code{FALSE}, they are extended by the default 3
- bandwidths (as specified by the \code{cut} parameter to
- \code{\link{density}})}
+\item{trim}{if \code{TRUE}, the default, densities are trimmed to the
+actual range of the data. If \code{FALSE}, they are extended by the
+default 3 bandwidths (as specified by the \code{cut} parameter to
+\code{\link{density}})}
- \item{na.rm}{If \code{FALSE} (the default), removes
- missing values with a warning. If \code{TRUE} silently
- removes missing values.}
+\item{na.rm}{If \code{FALSE} (the default), removes missing values with
+a warning. If \code{TRUE} silently removes missing values.}
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{geom}{The geometric object to use display the data}
+\item{geom}{The geometric object to use display the data}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlappling points
+on this layer}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\value{
- data.frame with additional columns:
- \item{density}{density estimate} \item{count}{density *
- number of points - useful for stacked density plots}
+data.frame with additional columns:
+ \item{density}{density estimate}
+ \item{count}{density * number of points - useful for stacked density
+ plots}
\item{scaled}{density estimate, scaled to maximum of 1}
}
\description{
- 1d kernel density estimate.
+1d kernel density estimate.
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat",
- "density")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat", "density")}
}
\examples{
\donttest{
@@ -122,6 +120,6 @@ qplot(length, data=movies, geom="density", weight=rating/sum(rating))
}
}
\seealso{
- \code{\link{stat_bin}} for the histogram
+\code{\link{stat_bin}} for the histogram
}
diff --git a/man/stat_density2d.Rd b/man/stat_density2d.Rd
index c643bc3..3e48235 100644
--- a/man/stat_density2d.Rd
+++ b/man/stat_density2d.Rd
@@ -1,47 +1,43 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{stat_density2d}
\alias{stat_density2d}
\title{2d density estimation.}
\usage{
- stat_density2d(mapping = NULL, data = NULL,
- geom = "density2d", position = "identity",
- na.rm = FALSE, contour = TRUE, n = 100, ...)
+stat_density2d(mapping = NULL, data = NULL, geom = "density2d",
+ position = "identity", na.rm = FALSE, contour = TRUE, n = 100, ...)
}
\arguments{
- \item{contour}{If \code{TRUE}, contour the results of the
- 2d density estimation}
+\item{contour}{If \code{TRUE}, contour the results of the 2d density
+estimation}
- \item{n}{number of grid points in each direction}
+\item{n}{number of grid points in each direction}
- \item{...}{other arguments passed on to
- \code{\link{kde2d}}}
+\item{...}{other arguments passed on to \code{\link{kde2d}}}
- \item{na.rm}{If \code{FALSE} (the default), removes
- missing values with a warning. If \code{TRUE} silently
- removes missing values.}
+\item{na.rm}{If \code{FALSE} (the default), removes missing values with
+a warning. If \code{TRUE} silently removes missing values.}
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{geom}{The geometric object to use display the data}
+\item{geom}{The geometric object to use display the data}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlappling points
+on this layer}
}
\value{
- A data frame in the same format as
- \code{\link{stat_contour}}
+A data frame in the same format as \code{\link{stat_contour}}
}
\description{
- 2d density estimation.
+2d density estimation.
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat",
- "density2d")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat", "density2d")}
}
\examples{
\donttest{
diff --git a/man/stat_ecdf.Rd b/man/stat_ecdf.Rd
index c525348..26893dc 100644
--- a/man/stat_ecdf.Rd
+++ b/man/stat_ecdf.Rd
@@ -1,38 +1,38 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{stat_ecdf}
\alias{stat_ecdf}
\title{Empirical Cumulative Density Function}
\usage{
- stat_ecdf(mapping = NULL, data = NULL, geom = "step",
- position = "identity", n = NULL, ...)
+stat_ecdf(mapping = NULL, data = NULL, geom = "step",
+ position = "identity", n = NULL, ...)
}
\arguments{
- \item{n}{if NULL, do not interpolate. If not NULL, this
- is the number of points to interpolate with.}
+\item{n}{if NULL, do not interpolate. If not NULL, this is the number
+of points to interpolate with.}
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{geom}{The geometric object to use display the data}
+\item{geom}{The geometric object to use display the data}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlappling points
+on this layer}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\value{
- a data.frame with additional columns: \item{x}{x in data}
+a data.frame with additional columns:
+ \item{x}{x in data}
\item{y}{cumulative density corresponding x}
}
\description{
- Empirical Cumulative Density Function
+Empirical Cumulative Density Function
}
\examples{
\donttest{
diff --git a/man/stat_ellipse.Rd b/man/stat_ellipse.Rd
new file mode 100644
index 0000000..04a6a1b
--- /dev/null
+++ b/man/stat_ellipse.Rd
@@ -0,0 +1,74 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
+\name{stat_ellipse}
+\alias{stat_ellipse}
+\title{Plot data ellipses.}
+\usage{
+stat_ellipse(mapping = NULL, data = NULL, geom = "path",
+ position = "identity", type = "t", level = 0.95, segments = 51,
+ na.rm = FALSE, ...)
+}
+\arguments{
+\item{level}{The confidence level at which to draw an ellipse (default is 0.95),
+or, if \code{type="euclid"}, the radius of the circle to be drawn.}
+
+\item{type}{The type of ellipse.
+The default \code{"t"} assumes a multivariate t-distribution, and
+\code{"norm"} assumes a multivariate normal distribution.
+\code{"euclid"} draws a circle with the radius equal to \code{level},
+representing the euclidian distance from the center.
+This ellipse probably won't appear circular unless \code{coord_fixed()} is applied.}
+
+\item{segments}{The number of segments to be used in drawing the ellipse.}
+
+\item{na.rm}{If \code{FALSE} (the default), removes missing values with
+a warning. If \code{TRUE} silently removes missing values.}
+
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
+
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
+
+\item{geom}{The geometric object to use display the data}
+
+\item{position}{The position adjustment to use for overlappling points
+on this layer}
+
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
+}
+\description{
+Plot data ellipses.
+}
+\details{
+The method for calculating the ellipses has been modified from car::ellipse (Fox and Weisberg, 2011)
+}
+\examples{
+ggplot(faithful, aes(waiting, eruptions))+
+ geom_point()+
+ stat_ellipse()
+
+ggplot(faithful, aes(waiting, eruptions, color = eruptions > 3))+
+ geom_point()+
+ stat_ellipse()
+
+ggplot(faithful, aes(waiting, eruptions, color = eruptions > 3))+
+ geom_point()+
+ stat_ellipse(type = "norm", linetype = 2)+
+ stat_ellipse(type = "t")
+
+ggplot(faithful, aes(waiting, eruptions, color = eruptions > 3))+
+ geom_point()+
+ stat_ellipse(type = "norm", linetype = 2)+
+ stat_ellipse(type = "euclid", level = 3)+
+ coord_fixed()
+
+ggplot(faithful, aes(waiting, eruptions, color = eruptions > 3))+
+ stat_ellipse(geom = "polygon")
+}
+\references{
+John Fox and Sanford Weisberg (2011). An {R} Companion to Applied Regression, Second Edition. Thousand Oaks CA: Sage. URL: http://socserv.socsci.mcmaster.ca/jfox/Books/Companion
+}
+
diff --git a/man/stat_function.Rd b/man/stat_function.Rd
index fb4415f..f859c88 100644
--- a/man/stat_function.Rd
+++ b/man/stat_function.Rd
@@ -1,48 +1,45 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{stat_function}
\alias{stat_function}
\title{Superimpose a function.}
\usage{
- stat_function(mapping = NULL, data = NULL, geom = "path",
- position = "identity", fun, n = 101, args = list(),
- ...)
+stat_function(mapping = NULL, data = NULL, geom = "path",
+ position = "identity", fun, n = 101, args = list(), ...)
}
\arguments{
- \item{fun}{function to use}
+\item{fun}{function to use}
- \item{n}{number of points to interpolate along}
+\item{n}{number of points to interpolate along}
- \item{args}{list of additional arguments to pass to
- \code{fun}}
+\item{args}{list of additional arguments to pass to \code{fun}}
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{geom}{The geometric object to use display the data}
+\item{geom}{The geometric object to use display the data}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlappling points
+on this layer}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\value{
- a data.frame with additional columns: \item{x}{x's along
- a grid} \item{y}{value of function evaluated at
- corresponding x}
+a data.frame with additional columns:
+ \item{x}{x's along a grid}
+ \item{y}{value of function evaluated at corresponding x}
}
\description{
- Superimpose a function.
+Superimpose a function.
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat",
- "function")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat", "function")}
}
\examples{
x <- rnorm(100)
@@ -63,11 +60,13 @@ qplot(c(-5, 5), stat = "function", fun = dnorm, geom = "line")
# Or
qplot(c(-5, 5), geom = "blank") + stat_function(fun = dnorm)
# To specify a different mean or sd, use the args parameter to supply new values
-ggplot(data.frame(x = c(-5, 5)), aes(x)) + stat_function(fun = dnorm, args = list(mean = 2, sd = .5))
+ggplot(data.frame(x = c(-5, 5)), aes(x)) +
+ stat_function(fun = dnorm, args = list(mean = 2, sd = .5))
# Two functions on the same plot
f <- ggplot(data.frame(x = c(0, 10)), aes(x))
-f + stat_function(fun = sin, colour = "red") + stat_function(fun = cos, colour = "blue")
+f + stat_function(fun = sin, colour = "red") +
+ stat_function(fun = cos, colour = "blue")
# Using a custom function
test <- function(x) {x ^ 2 + x + 20}
diff --git a/man/stat_hline.Rd b/man/stat_hline.Rd
index 775bdef..217e32a 100644
--- a/man/stat_hline.Rd
+++ b/man/stat_hline.Rd
@@ -1,37 +1,36 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{stat_hline}
\alias{stat_hline}
\title{Add a horizontal line}
\usage{
- stat_hline(mapping = NULL, data = NULL, geom = "hline",
- position = "identity", yintercept, ...)
+stat_hline(mapping = NULL, data = NULL, geom = "hline",
+ position = "identity", yintercept, ...)
}
\arguments{
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{geom}{The geometric object to use display the data}
+\item{geom}{The geometric object to use display the data}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlappling points
+on this layer}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\description{
- Add a horizontal line
+Add a horizontal line
}
\examples{
# see geom_hline
}
\seealso{
- \code{\link{geom_hline}} for code examples.
+\code{\link{geom_hline}} for code examples.
}
\keyword{internal}
diff --git a/man/stat_identity.Rd b/man/stat_identity.Rd
index ba63163..9dbad3c 100644
--- a/man/stat_identity.Rd
+++ b/man/stat_identity.Rd
@@ -1,40 +1,38 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{stat_identity}
\alias{stat_identity}
\title{Identity statistic.}
\usage{
- stat_identity(mapping = NULL, data = NULL,
- geom = "point", position = "identity", width = NULL,
- height = NULL, ...)
+stat_identity(mapping = NULL, data = NULL, geom = "point",
+ position = "identity", width = NULL, height = NULL, ...)
}
\arguments{
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{geom}{The geometric object to use display the data}
+\item{geom}{The geometric object to use display the data}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlappling points
+on this layer}
- \item{width}{The width of the tiles.}
+\item{width}{The width of the tiles.}
- \item{height}{The height of the tiles.}
+\item{height}{The height of the tiles.}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\description{
- Identity statistic.
+Identity statistic.
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat",
- "identity")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat", "identity")}
}
\examples{
# Doesn't do anything, so hard to come up a useful example
diff --git a/man/stat_qq.Rd b/man/stat_qq.Rd
index f7972d8..139d18d 100644
--- a/man/stat_qq.Rd
+++ b/man/stat_qq.Rd
@@ -1,48 +1,45 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{stat_qq}
\alias{stat_qq}
\title{Calculation for quantile-quantile plot.}
\usage{
- stat_qq(mapping = NULL, data = NULL, geom = "point",
- position = "identity", distribution = qnorm,
- dparams = list(), na.rm = FALSE, ...)
+stat_qq(mapping = NULL, data = NULL, geom = "point",
+ position = "identity", distribution = qnorm, dparams = list(),
+ na.rm = FALSE, ...)
}
\arguments{
- \item{distribution}{Distribution function to use, if x
- not specified}
+\item{distribution}{Distribution function to use, if x not specified}
- \item{dparams}{Parameters for distribution function}
+\item{dparams}{Parameters for distribution function}
- \item{...}{Other arguments passed to distribution
- function}
+\item{...}{Other arguments passed to distribution function}
- \item{na.rm}{If \code{FALSE} (the default), removes
- missing values with a warning. If \code{TRUE} silently
- removes missing values.}
+\item{na.rm}{If \code{FALSE} (the default), removes missing values with
+a warning. If \code{TRUE} silently removes missing values.}
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{geom}{The geometric object to use display the data}
+\item{geom}{The geometric object to use display the data}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlappling points
+on this layer}
}
\value{
- a data.frame with additional columns:
+a data.frame with additional columns:
\item{sample}{sample quantiles}
\item{theoretical}{theoretical quantiles}
}
\description{
- Calculation for quantile-quantile plot.
+Calculation for quantile-quantile plot.
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat",
- "qq")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat", "qq")}
}
\examples{
\donttest{
diff --git a/man/stat_quantile.Rd b/man/stat_quantile.Rd
index 3a2667b..28f52c5 100644
--- a/man/stat_quantile.Rd
+++ b/man/stat_quantile.Rd
@@ -1,54 +1,49 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{stat_quantile}
\alias{stat_quantile}
\title{Continuous quantiles.}
\usage{
- stat_quantile(mapping = NULL, data = NULL,
- geom = "quantile", position = "identity",
- quantiles = c(0.25, 0.5, 0.75), formula = NULL,
- method = "rq", na.rm = FALSE, ...)
+stat_quantile(mapping = NULL, data = NULL, geom = "quantile",
+ position = "identity", quantiles = c(0.25, 0.5, 0.75), formula = NULL,
+ method = "rq", na.rm = FALSE, ...)
}
\arguments{
- \item{quantiles}{conditional quantiles of y to calculate
- and display}
+\item{quantiles}{conditional quantiles of y to calculate and display}
- \item{formula}{formula relating y variables to x
- variables}
+\item{formula}{formula relating y variables to x variables}
- \item{method}{Quantile regression method to use.
- Currently only supports \code{\link[quantreg]{rq}}.}
+\item{method}{Quantile regression method to use. Currently only supports
+\code{\link[quantreg]{rq}}.}
- \item{na.rm}{If \code{FALSE} (the default), removes
- missing values with a warning. If \code{TRUE} silently
- removes missing values.}
+\item{na.rm}{If \code{FALSE} (the default), removes missing values with
+a warning. If \code{TRUE} silently removes missing values.}
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{geom}{The geometric object to use display the data}
+\item{geom}{The geometric object to use display the data}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlappling points
+on this layer}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\value{
- a data.frame with additional columns:
+a data.frame with additional columns:
\item{quantile}{quantile of distribution}
}
\description{
- Continuous quantiles.
+Continuous quantiles.
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat",
- "quantile")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat", "quantile")}
}
\examples{
\donttest{
diff --git a/man/stat_smooth.Rd b/man/stat_smooth.Rd
index f1eadcc..4034223 100644
--- a/man/stat_smooth.Rd
+++ b/man/stat_smooth.Rd
@@ -1,76 +1,70 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{stat_smooth}
\alias{stat_smooth}
\title{Add a smoother.}
\usage{
- stat_smooth(mapping = NULL, data = NULL, geom = "smooth",
- position = "identity", method = "auto",
- formula = y ~ x, se = TRUE, n = 80, fullrange = FALSE,
- level = 0.95, na.rm = FALSE, ...)
+stat_smooth(mapping = NULL, data = NULL, geom = "smooth",
+ position = "identity", method = "auto", formula = y ~ x, se = TRUE,
+ n = 80, fullrange = FALSE, level = 0.95, na.rm = FALSE, ...)
}
\arguments{
- \item{method}{smoothing method (function) to use, eg. lm,
- glm, gam, loess, rlm. For datasets with n < 1000 default
- is \code{\link{loess}}. For datasets with 1000 or more
- observations defaults to gam, see \code{\link[mgcv]{gam}}
- for more details.}
+\item{method}{smoothing method (function) to use, eg. lm, glm, gam, loess,
+rlm. For datasets with n < 1000 default is \code{\link{loess}}. For datasets
+with 1000 or more observations defaults to gam, see \code{\link[mgcv]{gam}}
+for more details.}
- \item{formula}{formula to use in smoothing function, eg.
- \code{y ~ x}, \code{y ~ poly(x, 2)}, \code{y ~ log(x)}}
+\item{formula}{formula to use in smoothing function, eg. \code{y ~ x},
+\code{y ~ poly(x, 2)}, \code{y ~ log(x)}}
- \item{se}{display confidence interval around smooth?
- (TRUE by default, see level to control}
+\item{se}{display confidence interval around smooth? (TRUE by default, see
+level to control}
- \item{fullrange}{should the fit span the full range of
- the plot, or just the data}
+\item{fullrange}{should the fit span the full range of the plot, or just
+the data}
- \item{level}{level of confidence interval to use (0.95 by
- default)}
+\item{level}{level of confidence interval to use (0.95 by default)}
- \item{n}{number of points to evaluate smoother at}
+\item{n}{number of points to evaluate smoother at}
- \item{na.rm}{If \code{FALSE} (the default), removes
- missing values with a warning. If \code{TRUE} silently
- removes missing values.}
+\item{na.rm}{If \code{FALSE} (the default), removes missing values with
+a warning. If \code{TRUE} silently removes missing values.}
- \item{...}{other arguments are passed to smoothing
- function}
+\item{...}{other arguments are passed to smoothing function}
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{geom}{The geometric object to use display the data}
+\item{geom}{The geometric object to use display the data}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlappling points
+on this layer}
}
\value{
- a data.frame with additional columns \item{y}{predicted
- value} \item{ymin}{lower pointwise confidence interval
- around the mean} \item{ymax}{upper pointwise confidence
- interval around the mean} \item{se}{standard error}
+a data.frame with additional columns
+ \item{y}{predicted value}
+ \item{ymin}{lower pointwise confidence interval around the mean}
+ \item{ymax}{upper pointwise confidence interval around the mean}
+ \item{se}{standard error}
}
\description{
- Aids the eye in seeing patterns in the presence of
- overplotting.
+Aids the eye in seeing patterns in the presence of overplotting.
}
\details{
- Calculation is performed by the (currently undocumented)
- \code{predictdf} generic function and its methods. For
- most methods the confidence bounds are computed using the
- \code{\link{predict}} method - the exceptions are
- \code{loess} which uses a t-based approximation, and for
- \code{glm} where the normal confidence interval is
- constructed on the link scale, and then back-transformed
- to the response scale.
+Calculation is performed by the (currently undocumented)
+\code{predictdf} generic function and its methods. For most methods
+the confidence bounds are computed using the \code{\link{predict}}
+method - the exceptions are \code{loess} which uses a t-based
+approximation, and for \code{glm} where the normal confidence interval
+is constructed on the link scale, and then back-transformed to the response
+scale.
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat",
- "smooth")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat", "smooth")}
}
\examples{
\donttest{
@@ -132,8 +126,8 @@ qplot(Age, as.numeric(Kyphosis) - 1, data=kyphosis) +
}
}
\seealso{
- \code{\link{lm}} for linear smooths, \code{\link{glm}}
- for generalised linear smooths, \code{\link{loess}} for
- local smooths
+\code{\link{lm}} for linear smooths,
+ \code{\link{glm}} for generalised linear smooths,
+ \code{\link{loess}} for local smooths
}
diff --git a/man/stat_spoke.Rd b/man/stat_spoke.Rd
index 7fa4ebb..483e63a 100644
--- a/man/stat_spoke.Rd
+++ b/man/stat_spoke.Rd
@@ -1,40 +1,39 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{stat_spoke}
\alias{stat_spoke}
\title{Convert angle and radius to xend and yend.}
\usage{
- stat_spoke(mapping = NULL, data = NULL, geom = "segment",
- position = "identity", ...)
+stat_spoke(mapping = NULL, data = NULL, geom = "segment",
+ position = "identity", ...)
}
\arguments{
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{geom}{The geometric object to use display the data}
+\item{geom}{The geometric object to use display the data}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlappling points
+on this layer}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\value{
- a data.frame with additional columns \item{xend}{x
- position of end of line segment} \item{yend}{x position
- of end of line segment}
+a data.frame with additional columns
+ \item{xend}{x position of end of line segment}
+ \item{yend}{x position of end of line segment}
}
\description{
- Convert angle and radius to xend and yend.
+Convert angle and radius to xend and yend.
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat",
- "spoke")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat", "spoke")}
}
\examples{
df <- expand.grid(x = 1:10, y=1:10)
diff --git a/man/stat_sum.Rd b/man/stat_sum.Rd
index 575aa8a..d7e481a 100644
--- a/man/stat_sum.Rd
+++ b/man/stat_sum.Rd
@@ -1,41 +1,39 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{stat_sum}
\alias{stat_sum}
\title{Sum unique values. Useful for overplotting on scatterplots.}
\usage{
- stat_sum(mapping = NULL, data = NULL, geom = "point",
- position = "identity", ...)
+stat_sum(mapping = NULL, data = NULL, geom = "point",
+ position = "identity", ...)
}
\arguments{
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{geom}{The geometric object to use display the data}
+\item{geom}{The geometric object to use display the data}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlappling points
+on this layer}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\value{
- a data.frame with additional columns \item{n}{number of
- observations at position} \item{prop}{percent of points
- in that panel at that position}
+a data.frame with additional columns
+ \item{n}{number of observations at position}
+ \item{prop}{percent of points in that panel at that position}
}
\description{
- Sum unique values. Useful for overplotting on
- scatterplots.
+Sum unique values. Useful for overplotting on scatterplots.
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat",
- "sum")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat", "sum")}
}
\examples{
\donttest{
@@ -52,7 +50,7 @@ d + stat_sum()
# by overall proportion
d + stat_sum(aes(group = 1))
d + stat_sum(aes(group = 1)) + scale_size(range = c(3, 10))
-d + stat_sum(aes(group = 1)) + scale_area(range = c(3, 10))
+d + stat_sum(aes(group = 1)) + scale_size_area(max_size = 10)
# by cut
d + stat_sum(aes(group = cut))
@@ -75,6 +73,6 @@ qplot(cut, clarity, data = diamonds, stat = "sum", group = 1)
}
}
\seealso{
- \code{\link{ggfluctuation}} for a fluctuation diagram,
+\code{\link{ggfluctuation}} for a fluctuation diagram,
}
diff --git a/man/stat_summary.Rd b/man/stat_summary.Rd
index 72df119..e249e6f 100644
--- a/man/stat_summary.Rd
+++ b/man/stat_summary.Rd
@@ -1,56 +1,56 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{stat_summary}
\alias{stat_summary}
\title{Summarise y values at every unique x.}
\usage{
- stat_summary(mapping = NULL, data = NULL,
- geom = "pointrange", position = "identity", ...)
+stat_summary(mapping = NULL, data = NULL, geom = "pointrange",
+ position = "identity", ...)
}
\arguments{
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{geom}{The geometric object to use display the data}
+\item{geom}{The geometric object to use display the data}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlappling points
+on this layer}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\value{
- a data.frame with additional columns:
- \item{fun.data}{Complete summary function. Should take
- data frame as input and return data frame as output}
- \item{fun.ymin}{ymin summary function (should take
- numeric vector and return single number)} \item{fun.y}{y
- summary function (should take numeric vector and return
- single number)} \item{fun.ymax}{ymax summary function
- (should take numeric vector and return single number)}
+a data.frame with additional columns:
+ \item{fun.data}{Complete summary function. Should take data frame as
+ input and return data frame as output}
+ \item{fun.ymin}{ymin summary function (should take numeric vector and
+ return single number)}
+ \item{fun.y}{y summary function (should take numeric vector and return
+ single number)}
+ \item{fun.ymax}{ymax summary function (should take numeric vector and
+ return single number)}
}
\description{
- \code{stat_summary} allows for tremendous flexibilty in
- the specification of summary functions. The summary
- function can either operate on a data frame (with
- argument name \code{fun.data}) or on a vector
- (\code{fun.y}, \code{fun.ymax}, \code{fun.ymin}).
+\code{stat_summary} allows for tremendous flexibilty in the specification
+of summary functions. The summary function can either supply individual
+summary functions for each of y, ymin and ymax (with \code{fun.y},
+\code{fun.ymax}, \code{fun.ymin}), or return a data frame containing any
+number of aesthetiics with with \code{fun.data}. All summary functions
+are called with a single vector of values, \code{x}.
}
\details{
- A simple vector function is easiest to work with as you
- can return a single number, but is somewhat less
- flexible. If your summary function operates on a
- data.frame it should return a data frame with variables
- that the geom can use.
+A simple vector function is easiest to work with as you can return a single
+number, but is somewhat less flexible. If your summary function operates
+on a data.frame it should return a data frame with variables that the geom
+can use.
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat",
- "summary")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat", "summary")}
}
\examples{
\donttest{
@@ -90,14 +90,16 @@ stat_sum_df <- function(fun, geom="crossbar", ...) {
stat_summary(fun.data=fun, colour="red", geom=geom, width=0.2, ...)
}
-d + stat_sum_df("mean_cl_boot")
-d + stat_sum_df("mean_sdl")
-d + stat_sum_df("mean_sdl", mult=1)
-d + stat_sum_df("median_hilow")
+# The crossbar geom needs grouping to be specified when used with
+# a continuous x axis.
+d + stat_sum_df("mean_cl_boot", mapping = aes(group = cyl))
+d + stat_sum_df("mean_sdl", mapping = aes(group = cyl))
+d + stat_sum_df("mean_sdl", mult = 1, mapping = aes(group = cyl))
+d + stat_sum_df("median_hilow", mapping = aes(group = cyl))
# There are lots of different geoms you can use to display the summaries
-d + stat_sum_df("mean_cl_normal")
+d + stat_sum_df("mean_cl_normal", mapping = aes(group = cyl))
d + stat_sum_df("mean_cl_normal", geom = "errorbar")
d + stat_sum_df("mean_cl_normal", geom = "pointrange")
d + stat_sum_df("mean_cl_normal", geom = "smooth")
@@ -133,9 +135,8 @@ m2 + coord_trans(y="log10")
}
}
\seealso{
- \code{\link{geom_errorbar}},
- \code{\link{geom_pointrange}},
- \code{\link{geom_linerange}}, \code{\link{geom_crossbar}}
- for geoms to display summarised data
+\code{\link{geom_errorbar}}, \code{\link{geom_pointrange}},
+ \code{\link{geom_linerange}}, \code{\link{geom_crossbar}} for geoms to
+ display summarised data
}
diff --git a/man/stat_summary2d.Rd b/man/stat_summary2d.Rd
index d0a2fdb..bbd6440 100644
--- a/man/stat_summary2d.Rd
+++ b/man/stat_summary2d.Rd
@@ -1,51 +1,49 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{stat_summary2d}
\alias{stat_summary2d}
\title{Apply funciton for 2D rectangular bins.}
\usage{
- stat_summary2d(mapping = NULL, data = NULL, geom = NULL,
- position = "identity", bins = 30, drop = TRUE,
- fun = mean, ...)
+stat_summary2d(mapping = NULL, data = NULL, geom = NULL,
+ position = "identity", bins = 30, drop = TRUE, fun = mean, ...)
}
\arguments{
- \item{bins}{see \code{\link{stat_bin2d}}}
+\item{bins}{see \code{\link{stat_bin2d}}}
- \item{drop}{drop if the output of \code{fun} is
- \code{NA}.}
+\item{drop}{drop if the output of \code{fun} is \code{NA}.}
- \item{fun}{function for summary.}
+\item{fun}{function for summary.}
- \item{...}{parameters passed to \code{fun}}
+\item{...}{parameters passed to \code{fun}}
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{geom}{The geometric object to use display the data}
+\item{geom}{The geometric object to use display the data}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlappling points
+on this layer}
}
\description{
- Apply function for 2D rectangular bins.
+Apply function for 2D rectangular bins.
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat",
- "summary2d")}
- \code{stat_summary2d} is 2D version of
- \code{\link{stat_summary}}. The data are devided by
- \code{x} and \code{y}. \code{z} in each cell is passed to
- arbitral summary function.
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat", "summary2d")}
- \code{stat_summary2d} requires the following aesthetics:
+\code{stat_summary2d} is 2D version of \code{\link{stat_summary}}. The data are devided by \code{x} and \code{y}.
+\code{z} in each cell is passed to arbitral summary function.
- \itemize{ \item \code{x}: horizontal position \item
- \code{y}: vertical position \item \code{z}: value passed
- to the summary function }
+\code{stat_summary2d} requires the following aesthetics:
+
+\itemize{
+ \item \code{x}: horizontal position
+ \item \code{y}: vertical position
+ \item \code{z}: value passed to the summary function
+}
}
\examples{
\donttest{
@@ -58,8 +56,6 @@ d + stat_summary2d(fun = var)
}
}
\seealso{
- \code{\link{stat_summary_hex}} for hexagonal
- summarization. \code{\link{stat_bin2d}} for the binning
- options.
+\code{\link{stat_summary_hex}} for hexagonal summarization. \code{\link{stat_bin2d}} for the binning options.
}
diff --git a/man/stat_summary_hex.Rd b/man/stat_summary_hex.Rd
index 73b2d18..21b7673 100644
--- a/man/stat_summary_hex.Rd
+++ b/man/stat_summary_hex.Rd
@@ -1,52 +1,49 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{stat_summary_hex}
\alias{stat_summary_hex}
\title{Apply funciton for 2D hexagonal bins.}
\usage{
- stat_summary_hex(mapping = NULL, data = NULL,
- geom = "hex", position = "identity", bins = 30,
- drop = TRUE, fun = mean, ...)
+stat_summary_hex(mapping = NULL, data = NULL, geom = "hex",
+ position = "identity", bins = 30, drop = TRUE, fun = mean, ...)
}
\arguments{
- \item{bins}{see \code{\link{stat_binhex}}}
+\item{bins}{see \code{\link{stat_binhex}}}
- \item{drop}{drop if the output of \code{fun} is
- \code{NA}.}
+\item{drop}{drop if the output of \code{fun} is \code{NA}.}
- \item{fun}{function for summary.}
+\item{fun}{function for summary.}
- \item{...}{parameters passed to \code{fun}}
+\item{...}{parameters passed to \code{fun}}
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{geom}{The geometric object to use display the data}
+\item{geom}{The geometric object to use display the data}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlappling points
+on this layer}
}
\description{
- Apply function for 2D hexagonal bins.
+Apply function for 2D hexagonal bins.
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat",
- "summaryhex")}
- \code{stat_summary2d} is hexagonal version of
- \code{\link{stat_summary}}. The data are devided by
- \code{x} and \code{y}. \code{z} in each cell is passed to
- arbitral summary function.
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat", "summaryhex")}
- \code{stat_summary-hex} requires the following
- aesthetics:
+\code{stat_summary2d} is hexagonal version of \code{\link{stat_summary}}. The data are devided by \code{x} and \code{y}.
+\code{z} in each cell is passed to arbitral summary function.
- \itemize{ \item \code{x}: horizontal position \item
- \code{y}: vertical position \item \code{z}: value passed
- to the summary function }
+\code{stat_summary-hex} requires the following aesthetics:
+
+\itemize{
+ \item \code{x}: horizontal position
+ \item \code{y}: vertical position
+ \item \code{z}: value passed to the summary function
+}
}
\examples{
d <- ggplot(diamonds, aes(carat, depth, z = price))
@@ -57,8 +54,6 @@ d + stat_summary_hex(fun = function(x) sum(x^2))
d + stat_summary_hex(fun = var, na.rm = TRUE)
}
\seealso{
- \code{\link{stat_summary2d}} for rectangular
- summarization. \code{\link{stat_bin2d}} for the
- hexagon-ing options.
+\code{\link{stat_summary2d}} for rectangular summarization. \code{\link{stat_bin2d}} for the hexagon-ing options.
}
diff --git a/man/stat_unique.Rd b/man/stat_unique.Rd
index 674ab72..a106dd7 100644
--- a/man/stat_unique.Rd
+++ b/man/stat_unique.Rd
@@ -1,35 +1,34 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{stat_unique}
\alias{stat_unique}
\title{Remove duplicates.}
\usage{
- stat_unique(mapping = NULL, data = NULL, geom = "point",
- position = "identity", ...)
+stat_unique(mapping = NULL, data = NULL, geom = "point",
+ position = "identity", ...)
}
\arguments{
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{geom}{The geometric object to use display the data}
+\item{geom}{The geometric object to use display the data}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlappling points
+on this layer}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\description{
- Remove duplicates.
+Remove duplicates.
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat",
- "unique")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat", "unique")}
}
\examples{
ggplot(mtcars, aes(vs, am)) + geom_point(alpha = 0.1)
diff --git a/man/stat_vline.Rd b/man/stat_vline.Rd
index 9abf8fe..af8185a 100644
--- a/man/stat_vline.Rd
+++ b/man/stat_vline.Rd
@@ -1,37 +1,36 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{stat_vline}
\alias{stat_vline}
\title{Add a vertical line}
\usage{
- stat_vline(mapping = NULL, data = NULL, geom = "vline",
- position = "identity", xintercept, ...)
+stat_vline(mapping = NULL, data = NULL, geom = "vline",
+ position = "identity", xintercept, ...)
}
\arguments{
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{geom}{The geometric object to use display the data}
+\item{geom}{The geometric object to use display the data}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlappling points
+on this layer}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\description{
- Add a vertical line
+Add a vertical line
}
\examples{
# see geom_vline
}
\seealso{
- \code{\link{geom_vline}} for code examples.
+\code{\link{geom_vline}} for code examples.
}
\keyword{internal}
diff --git a/man/stat_ydensity.Rd b/man/stat_ydensity.Rd
index 2e3fce1..ee05741 100644
--- a/man/stat_ydensity.Rd
+++ b/man/stat_ydensity.Rd
@@ -1,73 +1,67 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{stat_ydensity}
\alias{stat_ydensity}
\title{1d kernel density estimate along y axis, for violin plot.}
\usage{
- stat_ydensity(mapping = NULL, data = NULL,
- geom = "violin", position = "dodge", adjust = 1,
- kernel = "gaussian", trim = TRUE, scale = "area",
- na.rm = FALSE, ...)
+stat_ydensity(mapping = NULL, data = NULL, geom = "violin",
+ position = "dodge", adjust = 1, kernel = "gaussian", trim = TRUE,
+ scale = "area", na.rm = FALSE, ...)
}
\arguments{
- \item{trim}{If \code{TRUE} (default), trim the tails of
- the violins to the range of the data. If \code{FALSE},
- don't trim the tails.}
+\item{trim}{If \code{TRUE} (default), trim the tails of the violins
+to the range of the data. If \code{FALSE}, don't trim the tails.}
- \item{scale}{if "area" (default), all violins have the
- same area (before trimming the tails). If "count", areas
- are scaled proportionally to the number of observations.
- If "width", all violins have the same maximum width.}
+\item{scale}{if "area" (default), all violins have the same area (before trimming
+the tails). If "count", areas are scaled proportionally to the number of
+observations. If "width", all violins have the same maximum width.}
- \item{na.rm}{If \code{FALSE} (the default), removes
- missing values with a warning. If \code{TRUE} silently
- removes missing values.}
+\item{na.rm}{If \code{FALSE} (the default), removes missing values with
+ a warning. If \code{TRUE} silently removes missing values.}
- \item{mapping}{The aesthetic mapping, usually constructed
- with \code{\link{aes}} or \code{\link{aes_string}}. Only
- needs to be set at the layer level if you are overriding
- the plot defaults.}
+\item{mapping}{The aesthetic mapping, usually constructed with
+\code{\link{aes}} or \code{\link{aes_string}}. Only needs to be set
+at the layer level if you are overriding the plot defaults.}
- \item{data}{A layer specific dataset - only needed if you
- want to override the plot defaults.}
+\item{data}{A layer specific dataset - only needed if you want to override
+the plot defaults.}
- \item{geom}{The geometric object to use display the data}
+\item{geom}{The geometric object to use display the data}
- \item{position}{The position adjustment to use for
- overlappling points on this layer}
+\item{position}{The position adjustment to use for overlappling points
+on this layer}
- \item{adjust}{see \code{\link{density}} for details}
+\item{adjust}{see \code{\link{density}} for details}
- \item{kernel}{kernel used for density estimation, see
- \code{\link{density}} for details}
+\item{kernel}{kernel used for density estimation, see
+\code{\link{density}} for details}
- \item{...}{other arguments passed on to
- \code{\link{layer}}. This can include aesthetics whose
- values you want to set, not map. See \code{\link{layer}}
- for more details.}
+\item{...}{other arguments passed on to \code{\link{layer}}. This can
+include aesthetics whose values you want to set, not map. See
+\code{\link{layer}} for more details.}
}
\value{
- A data frame with additional columns:
- \item{density}{density estimate} \item{scaled}{density
- estimate, scaled to maximum of 1} \item{count}{density *
- number of points - probably useless for violin plots}
- \item{violinwidth}{density scaled for the violin plot,
- according to area, counts or to a constant maximum width}
- \item{n}{number of points} \item{width}{width of violin
- bounding box}
+A data frame with additional columns:
+ \item{density}{density estimate}
+ \item{scaled}{density estimate, scaled to maximum of 1}
+ \item{count}{density * number of points - probably useless for violin plots}
+ \item{violinwidth}{density scaled for the violin plot, according to area, counts
+ or to a constant maximum width}
+ \item{n}{number of points}
+ \item{width}{width of violin bounding box}
}
\description{
- 1d kernel density estimate along y axis, for violin plot.
+1d kernel density estimate along y axis, for violin plot.
}
\section{Aesthetics}{
- \Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat",
- "ydensity")}
+
+\Sexpr[results=rd,stage=build]{ggplot2:::rd_aesthetics("stat", "ydensity")}
}
\examples{
# See geom_violin for examples
# Also see stat_density for similar examples with data along x axis
}
\seealso{
- \code{\link{geom_violin}} for examples, and
- \code{\link{stat_density}} for examples with data along
- the x axis.
+\code{\link{geom_violin}} for examples, and \code{\link{stat_density}}
+ for examples with data along the x axis.
}
diff --git a/man/summary.ggplot.Rd b/man/summary.ggplot.Rd
index 698122a..6635d5c 100644
--- a/man/summary.ggplot.Rd
+++ b/man/summary.ggplot.Rd
@@ -1,17 +1,17 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{summary.ggplot}
\alias{summary.ggplot}
\title{Displays a useful description of a ggplot object}
\usage{
- \method{summary}{ggplot} (object, ...)
+\method{summary}{ggplot}(object, ...)
}
\arguments{
- \item{object}{ggplot2 object to summarise}
+\item{object}{ggplot2 object to summarise}
- \item{...}{other arguments ignored (for compatibility
- with generic)}
+\item{...}{other arguments ignored (for compatibility with generic)}
}
\description{
- Displays a useful description of a ggplot object
+Displays a useful description of a ggplot object
}
\examples{
summary(qplot(mpg, wt, data=mtcars))
diff --git a/man/theme.Rd b/man/theme.Rd
index fa86ebc..e30cdf7 100644
--- a/man/theme.Rd
+++ b/man/theme.Rd
@@ -1,141 +1,154 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{theme}
\alias{theme}
\title{Set theme elements}
\usage{
- theme(..., complete = FALSE)
+theme(..., complete = FALSE)
}
\arguments{
- \item{...}{a list of element name, element pairings that
- modify the existing theme.}
+\item{...}{a list of element name, element pairings that modify the
+existing theme.}
- \item{complete}{set this to TRUE if this is a complete
- theme, such as the one returned \code{by theme_grey()}.
- Complete themes behave differently when added to a ggplot
- object.}
+\item{complete}{set this to TRUE if this is a complete theme, such as
+ the one returned \code{by theme_grey()}. Complete themes behave
+ differently when added to a ggplot object.}
}
\description{
- Use this function to modify theme settings.
+Use this function to modify theme settings.
}
\details{
- Theme elements can inherit properties from other theme
- elements. For example, \code{axis.title.x} inherits from
- \code{axis.title}, which in turn inherits from
- \code{text}. All text elements inherit directly or
- indirectly from \code{text}; all lines inherit from
- \code{line}, and all rectangular objects inherit from
- \code{rect}.
-
- For more examples of modifying properties using
- inheritance, see \code{\link{+.gg}} and
- \code{\link{\%+replace\%}}.
-
- To see a graphical representation of the inheritance
- tree, see the last example below.
+Theme elements can inherit properties from other theme elements.
+For example, \code{axis.title.x} inherits from \code{axis.title},
+which in turn inherits from \code{text}. All text elements inherit
+directly or indirectly from \code{text}; all lines inherit from
+\code{line}, and all rectangular objects inherit from \code{rect}.
+
+For more examples of modifying properties using inheritance, see
+\code{\link{+.gg}} and \code{\link{\%+replace\%}}.
+
+To see a graphical representation of the inheritance tree, see the
+last example below.
}
\section{Theme elements}{
- The individual theme elements are:
-
- \tabular{ll}{ line \tab all line elements
- (\code{element_line}) \cr rect \tab all rectangluar
- elements (\code{element_rect}) \cr text \tab all text
- elements (\code{element_text}) \cr title \tab all title
- elements: plot, axes, legends (\code{element_text};
- inherits from \code{text}) \cr
-
- axis.title \tab label of axes (\code{element_text};
- inherits from \code{text}) \cr axis.title.x \tab x axis
- label (\code{element_text}; inherits from
- \code{axis.title}) \cr axis.title.y \tab y axis label
- (\code{element_text}; inherits from \code{axis.title})
- \cr axis.text \tab tick labels along axes
- (\code{element_text}; inherits from \code{text}) \cr
- axis.text.x \tab x axis tick labels (\code{element_text};
- inherits from \code{axis.text}) \cr axis.text.y \tab y
- axis tick labels (\code{element_text}; inherits from
- \code{axis.text}) \cr axis.ticks \tab tick marks along
- axes (\code{element_line}; inherits from \code{line}) \cr
- axis.ticks.x \tab x axis tick marks (\code{element_line};
- inherits from \code{axis.ticks}) \cr axis.ticks.y \tab y
- axis tick marks (\code{element_line}; inherits from
- \code{axis.ticks}) \cr axis.ticks.length \tab length of
- tick marks (\code{unit}) \cr axis.ticks.margin \tab space
- between tick mark and tick label (\code{unit}) \cr
- axis.line \tab lines along axes (\code{element_line};
- inherits from \code{line}) \cr axis.line.x \tab line
- along x axis (\code{element_line}; inherits from
- \code{axis.line}) \cr axis.line.y \tab line along y axis
- (\code{element_line}; inherits from \code{axis.line}) \cr
-
- legend.background \tab background of legend
- (\code{element_rect}; inherits from \code{rect}) \cr
- legend.margin \tab extra space added around legend
- (\code{unit}) \cr legend.key \tab background underneath
- legend keys (\code{element_rect}; inherits from
- \code{rect}) \cr legend.key.size \tab size of legend keys
- (\code{unit}; inherits from \code{legend.key.size}) \cr
- legend.key.height \tab key background height
- (\code{unit}; inherits from \code{legend.key.size}) \cr
- legend.key.width \tab key background width (\code{unit};
- inherits from \code{legend.key.size}) \cr legend.text
- \tab legend item labels (\code{element_text}; inherits
- from \code{text}) \cr legend.text.align \tab alignment of
- legend labels (number from 0 (left) to 1 (right)) \cr
- legend.title \tab title of legend (\code{element_text};
- inherits from \code{title}) \cr legend.title.align \tab
- alignment of legend title (number from 0 (left) to 1
- (right)) \cr legend.position \tab the position of
- legends. ("left", "right", "bottom", "top", or
- two-element numeric vector) \cr legend.direction \tab
- layout of items in legends ("horizontal" or "vertical")
- \cr legend.justification \tab anchor point for
- positioning legend inside plot ("center" or two-element
- numeric vector) \cr legend.box \tab arrangement of
- multiple legends ("horizontal" or "vertical") \cr
- legend.box.just \tab justification of each legend within
- the overall bounding box, when there are multiple legends
- ("top", "bottom", "left", or "right")\cr
-
- panel.background \tab background of plotting area, drawn
- underneath plot (\code{element_rect}; inherits from
- \code{rect}) \cr panel.border \tab border around plotting
- area, drawn on top of plot so that it covers tick marks
- and grid lines. This should be used with \code{fill=NA}
- (\code{element_rect}; inherits from \code{rect}) \cr
- panel.margin \tab margin around facet panels
- (\code{unit}) \cr panel.grid \tab grid lines
- (\code{element_line}; inherits from \code{line}) \cr
+
+The individual theme elements are:
+
+\tabular{ll}{
+ line \tab all line elements
+ (\code{element_line}) \cr
+ rect \tab all rectangluar elements
+ (\code{element_rect}) \cr
+ text \tab all text elements
+ (\code{element_text}) \cr
+ title \tab all title elements: plot, axes, legends
+ (\code{element_text}; inherits from \code{text}) \cr
+
+ axis.title \tab label of axes
+ (\code{element_text}; inherits from \code{text}) \cr
+ axis.title.x \tab x axis label
+ (\code{element_text}; inherits from \code{axis.title}) \cr
+ axis.title.y \tab y axis label
+ (\code{element_text}; inherits from \code{axis.title}) \cr
+ axis.text \tab tick labels along axes
+ (\code{element_text}; inherits from \code{text}) \cr
+ axis.text.x \tab x axis tick labels
+ (\code{element_text}; inherits from \code{axis.text}) \cr
+ axis.text.y \tab y axis tick labels
+ (\code{element_text}; inherits from \code{axis.text}) \cr
+ axis.ticks \tab tick marks along axes
+ (\code{element_line}; inherits from \code{line}) \cr
+ axis.ticks.x \tab x axis tick marks
+ (\code{element_line}; inherits from \code{axis.ticks}) \cr
+ axis.ticks.y \tab y axis tick marks
+ (\code{element_line}; inherits from \code{axis.ticks}) \cr
+ axis.ticks.length \tab length of tick marks
+ (\code{unit}) \cr
+ axis.ticks.margin \tab space between tick mark and tick label
+ (\code{unit}) \cr
+ axis.line \tab lines along axes
+ (\code{element_line}; inherits from \code{line}) \cr
+ axis.line.x \tab line along x axis
+ (\code{element_line}; inherits from \code{axis.line}) \cr
+ axis.line.y \tab line along y axis
+ (\code{element_line}; inherits from \code{axis.line}) \cr
+
+ legend.background \tab background of legend
+ (\code{element_rect}; inherits from \code{rect}) \cr
+ legend.margin \tab extra space added around legend
+ (\code{unit}) \cr
+ legend.key \tab background underneath legend keys
+ (\code{element_rect}; inherits from \code{rect}) \cr
+ legend.key.size \tab size of legend keys
+ (\code{unit}; inherits from \code{legend.key.size}) \cr
+ legend.key.height \tab key background height
+ (\code{unit}; inherits from \code{legend.key.size}) \cr
+ legend.key.width \tab key background width
+ (\code{unit}; inherits from \code{legend.key.size}) \cr
+ legend.text \tab legend item labels
+ (\code{element_text}; inherits from \code{text}) \cr
+ legend.text.align \tab alignment of legend labels
+ (number from 0 (left) to 1 (right)) \cr
+ legend.title \tab title of legend
+ (\code{element_text}; inherits from \code{title}) \cr
+ legend.title.align \tab alignment of legend title
+ (number from 0 (left) to 1 (right)) \cr
+ legend.position \tab the position of legends
+ ("none", "left", "right", "bottom", "top", or two-element
+ numeric vector) \cr
+ legend.direction \tab layout of items in legends
+ ("horizontal" or "vertical") \cr
+ legend.justification \tab anchor point for positioning legend inside plot
+ ("center" or two-element numeric vector) \cr
+ legend.box \tab arrangement of multiple legends
+ ("horizontal" or "vertical") \cr
+ legend.box.just \tab justification of each legend within the overall
+ bounding box, when there are multiple legends
+ ("top", "bottom", "left", or "right")\cr
+
+ panel.background \tab background of plotting area, drawn underneath plot
+ (\code{element_rect}; inherits from \code{rect}) \cr
+ panel.border \tab border around plotting area, drawn on top of plot
+ so that it covers tick marks and grid lines. This should
+ be used with \code{fill=NA}
+ (\code{element_rect}; inherits from \code{rect}) \cr
+ panel.margin \tab margin around facet panels
+ (\code{unit}) \cr
+ panel.margin.x \tab horizontal margin around facet panels
+ (\code{unit}; inherits from \code{panel.margin}) \cr
+ panel.margin.y \tab vertical margin around facet panels
+ (\code{unit}; inherits from \code{panel.margin}) \cr
+ panel.grid \tab grid lines
+ (\code{element_line}; inherits from \code{line}) \cr
panel.grid.major \tab major grid lines
- (\code{element_line}; inherits from \code{panel.grid})
- \cr panel.grid.minor \tab minor grid lines
- (\code{element_line}; inherits from \code{panel.grid})
- \cr panel.grid.major.x \tab vertical major grid lines
- (\code{element_line}; inherits from
- \code{panel.grid.major}) \cr panel.grid.major.y \tab
- horizontal major grid lines (\code{element_line};
- inherits from \code{panel.grid.major}) \cr
+ (\code{element_line}; inherits from \code{panel.grid}) \cr
+ panel.grid.minor \tab minor grid lines
+ (\code{element_line}; inherits from \code{panel.grid}) \cr
+ panel.grid.major.x \tab vertical major grid lines
+ (\code{element_line}; inherits from \code{panel.grid.major}) \cr
+ panel.grid.major.y \tab horizontal major grid lines
+ (\code{element_line}; inherits from \code{panel.grid.major}) \cr
panel.grid.minor.x \tab vertical minor grid lines
- (\code{element_line}; inherits from
- \code{panel.grid.minor}) \cr panel.grid.minor.y \tab
- horizontal minor grid lines (\code{element_line};
- inherits from \code{panel.grid.minor}) \cr
-
- plot.background \tab background of the entire plot
- (\code{element_rect}; inherits from \code{rect}) \cr
- plot.title \tab plot title (text appearance)
- (\code{element_text}; inherits from \code{title}) \cr
- plot.margin \tab margin around entire plot (\code{unit}
- with the sizes of the top, right, bottom, and left
- margins) \cr
+ (\code{element_line}; inherits from \code{panel.grid.minor}) \cr
+ panel.grid.minor.y \tab horizontal minor grid lines
+ (\code{element_line}; inherits from \code{panel.grid.minor}) \cr
+
+ plot.background \tab background of the entire plot
+ (\code{element_rect}; inherits from \code{rect}) \cr
+ plot.title \tab plot title (text appearance)
+ (\code{element_text}; inherits from \code{title}) \cr
+ plot.margin \tab margin around entire plot
+ (\code{unit} with the sizes of the top, right, bottom, and
+ left margins) \cr
strip.background \tab background of facet labels
- (\code{element_rect}; inherits from \code{rect}) \cr
- strip.text \tab facet labels (\code{element_text};
- inherits from \code{text}) \cr strip.text.x \tab facet
- labels along horizontal direction (\code{element_text};
- inherits from \code{strip.text}) \cr strip.text.y \tab
- facet labels along vertical direction
- (\code{element_text}; inherits from \code{strip.text})
- \cr }
+ (\code{element_rect}; inherits from \code{rect}) \cr
+ strip.text \tab facet labels
+ (\code{element_text}; inherits from \code{text}) \cr
+ strip.text.x \tab facet labels along horizontal direction
+ (\code{element_text}; inherits from \code{strip.text}) \cr
+ strip.text.y \tab facet labels along vertical direction
+ (\code{element_text}; inherits from \code{strip.text}) \cr
+}
}
\examples{
\donttest{
@@ -229,7 +242,7 @@ k + theme(strip.background = element_rect(colour = "purple", fill = "pink",
k + theme(strip.text.x = element_text(colour = "red", angle = 45, size = 10,
hjust = 0.5, vjust = 0.5))
k + theme(panel.margin = unit(5, "lines"))
-k + theme(panel.margin = unit(0, "lines"))
+k + theme(panel.margin.y = unit(0, "lines"))
# Modify a theme and save it
@@ -266,10 +279,18 @@ plot(g, layout=layout.fruchterman.reingold, vertex.size=4, vertex.label.dist=.25
}
}
\seealso{
- \code{\link{+.gg}}
+\code{\link{+.gg}}
+
+\code{\link{\%+replace\%}}
+
+\code{\link{rel}}
+
+\code{\link{element_blank}}
+
+\code{\link{element_line}}
- \code{\link{\%+replace\%}}
+\code{\link{element_rect}}
- \code{\link{rel}}
+\code{\link{element_text}}
}
diff --git a/man/theme_blank.Rd b/man/theme_blank.Rd
index e282c0c..6e9497d 100644
--- a/man/theme_blank.Rd
+++ b/man/theme_blank.Rd
@@ -1,3 +1,4 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{theme_blank}
\alias{theme_blank}
\alias{theme_line}
@@ -6,22 +7,22 @@
\alias{theme_text}
\title{Deprecated theme_xx functions}
\usage{
- theme_blank(...)
+theme_blank(...)
- theme_rect(...)
+theme_rect(...)
- theme_line(...)
+theme_line(...)
- theme_segment(...)
+theme_segment(...)
- theme_text(...)
+theme_text(...)
}
\arguments{
- \item{...}{Arguments to be passed to the appropriate
- \code{element_xx} function.}
+\item{...}{Arguments to be passed to the appropriate \code{element_xx}
+ function.}
}
\description{
- The \code{theme_xx} functions have been deprecated. They
- are replaced with the \code{element_xx} functions.
+The \code{theme_xx} functions have been deprecated. They are replaced
+with the \code{element_xx} functions.
}
diff --git a/man/theme_bw.Rd b/man/theme_bw.Rd
deleted file mode 100644
index 06365af..0000000
--- a/man/theme_bw.Rd
+++ /dev/null
@@ -1,15 +0,0 @@
-\name{theme_bw}
-\alias{theme_bw}
-\title{A theme with white background and black gridlines.}
-\usage{
- theme_bw(base_size = 12, base_family = "")
-}
-\arguments{
- \item{base_size}{base font size}
-
- \item{base_family}{base font family}
-}
-\description{
- A theme with white background and black gridlines.
-}
-
diff --git a/man/theme_classic.Rd b/man/theme_classic.Rd
deleted file mode 100644
index 5c048db..0000000
--- a/man/theme_classic.Rd
+++ /dev/null
@@ -1,16 +0,0 @@
-\name{theme_classic}
-\alias{theme_classic}
-\title{A classic-looking theme, with x and y axis lines and no gridlines.}
-\usage{
- theme_classic(base_size = 12, base_family = "")
-}
-\arguments{
- \item{base_size}{base font size}
-
- \item{base_family}{base font family}
-}
-\description{
- A classic-looking theme, with x and y axis lines and no
- gridlines.
-}
-
diff --git a/man/theme_grey.Rd b/man/theme_grey.Rd
deleted file mode 100644
index be3fa2d..0000000
--- a/man/theme_grey.Rd
+++ /dev/null
@@ -1,16 +0,0 @@
-\name{theme_grey}
-\alias{theme_gray}
-\alias{theme_grey}
-\title{A theme with grey background and white gridlines.}
-\usage{
- theme_grey(base_size = 12, base_family = "")
-}
-\arguments{
- \item{base_size}{base font size}
-
- \item{base_family}{base font family}
-}
-\description{
- A theme with grey background and white gridlines.
-}
-
diff --git a/man/theme_minimal.Rd b/man/theme_minimal.Rd
deleted file mode 100644
index 9bc58d6..0000000
--- a/man/theme_minimal.Rd
+++ /dev/null
@@ -1,15 +0,0 @@
-\name{theme_minimal}
-\alias{theme_minimal}
-\title{A minimalistic theme with no background annotations.}
-\usage{
- theme_minimal(base_size = 12, base_family = "")
-}
-\arguments{
- \item{base_size}{base font size}
-
- \item{base_family}{base font family}
-}
-\description{
- A minimalistic theme with no background annotations.
-}
-
diff --git a/man/theme_update.Rd b/man/theme_update.Rd
index 01b5836..0b48e01 100644
--- a/man/theme_update.Rd
+++ b/man/theme_update.Rd
@@ -1,24 +1,24 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{theme_update}
\alias{theme_get}
\alias{theme_set}
\alias{theme_update}
\title{Get, set and update themes.}
\usage{
- theme_update(...)
+theme_update(...)
- theme_get()
+theme_get()
- theme_set(new)
+theme_set(new)
}
\arguments{
- \item{...}{named list of theme settings}
+\item{...}{named list of theme settings}
- \item{new}{new theme (a list of theme elements)}
+\item{new}{new theme (a list of theme elements)}
}
\description{
- Use \code{theme_update} to modify a small number of
- elements of the current theme or use \code{theme_set} to
- completely override it.
+Use \code{theme_update} to modify a small number of elements of the current
+theme or use \code{theme_set} to completely override it.
}
\examples{
qplot(mpg, wt, data = mtcars)
@@ -38,6 +38,6 @@ last_plot() +
theme(legend.background = element_rect(fill = "white", colour = "white", size = 3))
}
\seealso{
- \code{\link{\%+replace\%}} and \code{\link{+.gg}}
+\code{\link{\%+replace\%}} and \code{\link{+.gg}}
}
diff --git a/man/translate_qplot_base.Rd b/man/translate_qplot_base.Rd
index 7bd6c76..c81f5b8 100644
--- a/man/translate_qplot_base.Rd
+++ b/man/translate_qplot_base.Rd
@@ -1,16 +1,16 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{translate_qplot_base}
\alias{translate_qplot_base}
\title{Translating between qplot and base graphics}
\description{
- There are two types of graphics functions in base
- graphics, those that draw complete graphics and those
- that add to existing graphics.
+There are two types of graphics functions in base graphics, those that draw
+complete graphics and those that add to existing graphics.
}
\details{
- qplot() has been designed to mimic plot(), and can do the
- job of all other high-level plotting commands. There are
- only two graph types from base graphics that cannot be
- replicated with ggplot2: filled.contour() and persp()
+qplot() has been designed to mimic plot(), and can do the job of all other
+high-level plotting commands. There are only two graph types from base
+graphics that cannot be replicated with ggplot2: filled.contour() and
+persp()
}
\examples{
\donttest{
diff --git a/man/translate_qplot_ggplot.Rd b/man/translate_qplot_ggplot.Rd
index bc3fcbe..531f0b7 100644
--- a/man/translate_qplot_ggplot.Rd
+++ b/man/translate_qplot_ggplot.Rd
@@ -1,14 +1,14 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{translate_qplot_ggplot}
\alias{translate_qplot_ggplot}
\title{Translating between qplot and ggplot}
\description{
- Within ggplot2, there are two basic methods to create
- plots, with qplot() and ggplot(). qplot() is designed
- primarily for interactive use: it makes a number of
- assumptions that speed most cases, but when designing
- multilayered plots with different data sources it can get
- in the way. This section describes what those defaults
- are, and how they map to the fuller ggplot() syntax.
+Within ggplot2, there are two basic methods to create plots, with qplot()
+and ggplot(). qplot() is designed primarily for interactive use: it makes
+a number of assumptions that speed most cases, but when designing multilayered
+plots with different data sources it can get in the way. This section
+describes what those defaults are, and how they map to the fuller ggplot()
+syntax.
}
\examples{
# By default, qplot() assumes that you want a scatterplot,
diff --git a/man/translate_qplot_gpl.Rd b/man/translate_qplot_gpl.Rd
index 19bea0f..cc0c48f 100644
--- a/man/translate_qplot_gpl.Rd
+++ b/man/translate_qplot_gpl.Rd
@@ -1,10 +1,10 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{translate_qplot_gpl}
\alias{translate_qplot_gpl}
\title{Translating between qplot and Graphics Production Library (GPL)}
\description{
- The Grammar of Graphics uses two specifications. A
- concise format is used to caption figures, and a more
- detailed xml format stored on disk.
+The Grammar of Graphics uses two specifications. A concise format is used to
+caption figures, and a more detailed xml format stored on disk.
}
\examples{
# The following example of the concise format is adapted from Figure 1.5,
diff --git a/man/translate_qplot_lattice.Rd b/man/translate_qplot_lattice.Rd
index b923855..9561b2a 100644
--- a/man/translate_qplot_lattice.Rd
+++ b/man/translate_qplot_lattice.Rd
@@ -1,11 +1,11 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{translate_qplot_lattice}
\alias{translate_qplot_lattice}
\title{Translating between qplot and lattice}
\description{
- The major difference between lattice and ggplot2 is that
- lattice uses a formula based interface. ggplot2 does not
- because the formula does not generalise well to more
- complicated situations.
+The major difference between lattice and ggplot2 is that lattice uses a formula based
+interface. ggplot2 does not because the formula does not generalise well
+to more complicated situations.
}
\examples{
\donttest{
diff --git a/man/update_defaults.Rd b/man/update_defaults.Rd
index 6bf0187..c0a94b7 100644
--- a/man/update_defaults.Rd
+++ b/man/update_defaults.Rd
@@ -1,19 +1,20 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{update_geom_defaults}
\alias{update_geom_defaults}
\alias{update_stat_defaults}
\title{Modify geom/stat aesthetic defaults for future plots}
\usage{
- update_geom_defaults(geom, new)
+update_geom_defaults(geom, new)
- update_stat_defaults(stat, new)
+update_stat_defaults(stat, new)
}
\arguments{
- \item{stat,geom}{name of geom/stat to modify}
+\item{stat,geom}{name of geom/stat to modify}
- \item{new}{named list of aesthetics}
+\item{new}{named list of aesthetics}
}
\description{
- Modify geom/stat aesthetic defaults for future plots
+Modify geom/stat aesthetic defaults for future plots
}
\examples{
update_geom_defaults("point", list(colour = "darkblue"))
diff --git a/man/update_element.Rd b/man/update_element.Rd
index d0ccb4a..3699844 100644
--- a/man/update_element.Rd
+++ b/man/update_element.Rd
@@ -1,23 +1,24 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{update_element}
\alias{update_element}
\title{Update theme param}
\usage{
- update_element(name, ...)
+update_element(name, ...)
}
\arguments{
- \item{name}{name of a theme element}
+\item{name}{name of a theme element}
- \item{...}{Pairs of name and value of theme parameters.}
+\item{...}{Pairs of name and value of theme parameters.}
}
\value{
- Updated theme element
+Updated theme element
}
\description{
- Update contents of a theme. (Deprecated)
+Update contents of a theme. (Deprecated)
}
\details{
- This function is deprecated. Use
- \code{\link{\%+replace\%}} or \code{\link{+.gg}} instead.
+This function is deprecated. Use \code{\link{\%+replace\%}} or
+\code{\link{+.gg}} instead.
}
\examples{
\dontrun{
@@ -39,6 +40,6 @@ update_element("axis.text", colour = 20)
}
}
\seealso{
- \code{\link{\%+replace\%}} and \code{\link{+.gg}}
+\code{\link{\%+replace\%}} and \code{\link{+.gg}}
}
diff --git a/man/update_labels.Rd b/man/update_labels.Rd
index 724e12f..d7b7dc7 100644
--- a/man/update_labels.Rd
+++ b/man/update_labels.Rd
@@ -1,16 +1,17 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{update_labels}
\alias{update_labels}
\title{Update axis/legend labels}
\usage{
- update_labels(p, labels)
+update_labels(p, labels)
}
\arguments{
- \item{p}{plot to modify}
+\item{p}{plot to modify}
- \item{labels}{named list of new labels}
+\item{labels}{named list of new labels}
}
\description{
- Update axis/legend labels
+Update axis/legend labels
}
\examples{
p <- qplot(mpg, wt, data = mtcars)
diff --git a/man/waiver.Rd b/man/waiver.Rd
index 5b5b2d6..21b2c6b 100644
--- a/man/waiver.Rd
+++ b/man/waiver.Rd
@@ -1,16 +1,15 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{waiver}
\alias{waiver}
\title{A waiver object.}
\usage{
- waiver()
+waiver()
}
\description{
- A waiver is a "flag" object, similar to \code{NULL}, that
- indicates the calling function should just use the
- default value. It is used in certain functions to
- distinguish between displaying nothing (\code{NULL}) and
- displaying a default value calculated elsewhere
- (\code{waiver()})
+A waiver is a "flag" object, similar to \code{NULL}, that indicates the
+calling function should just use the default value. It is used in certain
+functions to distinguish between displaying nothing (\code{NULL}) and
+displaying a default value calculated elsewhere (\code{waiver()})
}
\keyword{internal}
diff --git a/man/xylim.Rd b/man/xylim.Rd
index 055f3b6..2c342fe 100644
--- a/man/xylim.Rd
+++ b/man/xylim.Rd
@@ -1,19 +1,21 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{xlim}
\alias{xlim}
\alias{ylim}
\title{Convenience functions to set the limits of the x and y axis.}
\usage{
- xlim(...)
+xlim(...)
- ylim(...)
+ylim(...)
}
\arguments{
- \item{...}{if numeric, will create a continuous scale, if
- factor or character, will create a discrete scale.}
+\item{...}{if numeric, will create a continuous scale, if factor or
+character, will create a discrete scale.}
}
\description{
- Observations not in this range will be dropped completely
- and not passed to any other layers.
+Observations not in this range will be dropped completely and
+not passed to any other layers. If a NA value is substituted for one of the
+limits that limit is automatically calculated.
}
\examples{
# xlim
@@ -22,15 +24,19 @@ xlim(20, 15)
xlim(c(10, 20))
xlim("a", "b", "c")
qplot(mpg, wt, data=mtcars) + xlim(15, 20)
+# with automatic lower limit
+qplot(mpg, wt, data=mtcars) + xlim(NA, 20)
# ylim
ylim(15, 20)
ylim(c(10, 20))
ylim("a", "b", "c")
-qplot(mpg, wt, data=mtcars) + ylim(15, 20)
+qplot(mpg, wt, data=mtcars) + ylim(0, 4)
+# with automatic upper limit
+qplot(mpg, wt, data=mtcars) + ylim(0, NA)
}
\seealso{
- For changing x or y axis limits \strong{without} dropping
- data observations, see \code{\link{coord_cartesian}}.
+For changing x or y axis limits \strong{without} dropping data
+ observations, see \code{\link{coord_cartesian}}.
}
diff --git a/man/zeroGrob.Rd b/man/zeroGrob.Rd
index f2ea078..e54bbe4 100644
--- a/man/zeroGrob.Rd
+++ b/man/zeroGrob.Rd
@@ -1,11 +1,12 @@
+% Generated by roxygen2 (4.0.1): do not edit by hand
\name{zeroGrob}
\alias{zeroGrob}
\title{The zero grob draws nothing and has zero size.}
\usage{
- zeroGrob()
+zeroGrob()
}
\description{
- The zero grob draws nothing and has zero size.
+The zero grob draws nothing and has zero size.
}
\keyword{internal}
diff --git a/vignettes/development.Rmd b/vignettes/development.Rmd
new file mode 100644
index 0000000..32ab363
--- /dev/null
+++ b/vignettes/development.Rmd
@@ -0,0 +1,263 @@
+<!--
+%\VignetteEngine{knitr::knitr}
+%\VignetteIndexEntry{Contributing to ggplot2 development}
+-->
+
+```{r, echo = FALSE, message = FALSE}
+knitr::opts_chunk$set(
+ comment = "#>",
+ error = FALSE,
+ tidy = FALSE
+)
+```
+
+# Contributing to ggplot2 development
+
+The goal of this guide is to help you get up and contributing to ggplot2 as quickly as possible. It's still a work in progress and very rough. Your feedback is much appreciated and so are pull requests :). Rather than emailing me directly about questions, please discuss ggplot2 development issues on the [ggplot2-dev](https://groups.google.com/forum/#!forum/ggplot2-dev) mailing list. That way multiple people can learn at the same time.
+
+To contribute a change to ggplot2, you follow these steps:
+
+1. Set up a local ggplot2 development environment.
+1. Create a branch in git and make your changes.
+1. Push branch to github and issue pull request (PR).
+1. Discuss the pull request.
+1. Iterate until either we accept the PR or decide that it's not
+ a good fit for ggplot2.
+
+Each of these steps are described in more detail below. This might feel overwhelming the first time you get set up, but it gets easier with practice. If you get stuck at any point, please reach out for help on the [ggplot2-dev](https://groups.google.com/forum/#!forum/ggplot2-dev) mailing list
+
+## Basic setup
+
+If you want to do development on ggplot2 and share the changes with other people, you'll have to set up an account on GitHub. You'll make a fork of Hadley's repository and store it on GitHub. You'll also make a copy of your repository on your local machine.
+
+1. [Join github](https://github.com/join).
+
+1. [Set up git and github](https://help.github.com/articles/set-up-git).
+
+1. Fork of the main repo by going to https://github.com/hadley/ggplot2/fork.
+ A fork is a copy of ggplot2 that you can work on independently.
+ See [fork a repo](https://help.github.com/articles/fork-a-repo) for
+ more details.
+
+1. Clone your fork to your local computer (change `myname` to your account
+ name):
+
+ ```
+ git clone git at github.com:myname/ggplot2.git
+ cd ggplot2
+ ```
+
+1. Once you've done that, add the main repository as a remote and set up
+ the master branch to track the main ggplot2 repo. This will make it
+ easier to keep up to date.
+
+ ```
+ git remote add hadley git://github.com/hadley/ggplot2.git
+ git branch --set-upstream master hadley/master
+ ```
+
+Now on your local machine you have the local repository and two remote repositories: `origin` (the default), which is your personal ggplot2 repo at GitHub, and `hadley` which is Hadley's. You'll be able to push changes to your own repository only.
+
+### Development environment
+
+You'll also need a copy of the packages I use for package development. Get them by running the following R code:
+
+```{r, eval = FALSE}
+install.packages(c("devtools", "testthat"))
+devtools::install_github("klutometis/roxygen")
+```
+
+Next, install all the suggested packages that ggplot2 needs. To do this either open the ggplot2 rstudio project, or set your working directory to the ggplot2 directory, then run:
+
+```{r, eval = FALSE}
+install_deps(dep = T)
+```
+
+The key functions you'll use when working on ggplot2:
+
+* `devtools::load_all()`: loads all code into your current environment
+* `devtools::document()`: updates the roxygen comments
+* `devtools::test()`: run all unit tests
+* `devtools::check()`: runs R CMD check on the package to check for errors.
+
+If you're using Rstudio, I highly recommend learning the keyboard shortcuts for these commands. You can find them in the `Build` menu.
+
+## Making changes
+
+When you want to make changes, you should work on a new branch. Otherwise things can get a bit confusing when it comes time to merge it into the main repo with a pull request. You probably want to start with the `master` branch.
+
+```
+# Fetch the latest version of hadley/ggplot2
+git fetch hadley
+git checkout hadley/master
+```
+
+At this point it'll give you a warning about being in "detached HEAD" state. Don't worry about it. Just start a new branch with the current state as the starting point:
+
+```
+git checkout -b myfix
+```
+
+To check what branch you're currently on, run `git branch`.
+
+Now you can make your changes and commit them to this branch on your local repository. If you decide you want to start over, you can just check out `hadley/master` again, make a new branch, and begin anew.
+
+When you feel like sharing your changes, push them to your GitHub repo:
+
+```
+git push
+```
+
+Then you can submit a pull request if you want it to be integrated in the main branch.
+
+If you've been working on your for a while, it's possible that it won't merge properly because something has changed in both the main repo and in your branch. You can test it out by checking out the main branch and merging yourself.
+
+First, make a new branch called `testmerge`, based off the main branch:
+
+```
+git fetch hadley
+git checkout hadley/master
+
+git checkout -b testmerge
+```
+
+Then try merging your branch into testmerge:
+
+```
+git merge myfix
+```
+
+If there are no errors, great. You can switch back to your `myfix` branch and delete `testmerge`:
+
+```
+git checkout myfix
+git branch -D testmerge
+```
+
+If there are any merge conflicts, you may want to rebase your changes on top of the current master version, or just resolve the conflicts and commit it to your branch. Rebasing may make for a somewhat cleaner commit history, but there is a possibility of messing things up. If you want to be safe, you can just make a new branch and rebase that on top of the current master.
+
+## What makes a good pull request?
+
+<!--
+* [ ] Motivate the change in one paragraph, and include it in NEWS.
+ In parentheses, reference your github user name and this issue:
+ `(@hadley, #1234)`
+* [ ] Check pull request only includes relevant changes.
+* [ ] Use the [official style](http://adv-r.had.co.nz/Style.html).
+* [ ] Update documentation and re-run roxygen2
+* [ ] Add test, if bug in non-graphical function
+* [ ] Add visual test, if bug in graphical function
+* [ ] Add minimal example, if new graphical feature
+
+See http://docs.ggplot2.org/dev/vignettes/development.html for more details.
+--->
+
+Pull requests will be evaluated against the a seven point checklist:
+
+1. __Motivation__. Your pull request must clearly and concisely motivates the
+ need for change. Unfortunately neither Winston nor I have much time to
+ work on ggplot2 these days, so you need to describe the problem and show
+ how your pull request solves it as concisely as possible.
+
+ Also include this motivation in `NEWS` so that when a new release of
+ ggplot2 comes out it's easy for users to see what's changed. Add your
+ item at the top of the file and use markdown for formatting. The
+ news item should end with `(@yourGithubUsername, #the_issue_number)`.
+
+1. __Only related changes__. Before you submit your pull request, please
+ check to make sure that you haven't accidentally included any unrelated
+ changes. These make it harder to see exactly what's changed, and to
+ evaluate any unexpected side effects.
+
+ Each PR corresponds to a git branch, so if you expect to submit
+ multiple changes make sure to create multiple branches. If you have
+ multiple changes that depend on each other, start with the first one
+ and don't submit any others until the first one has been processed.
+
+1. __Use ggplot2 coding style__. Please follow the
+ [official ggplot2 style](http://adv-r.had.co.nz/Style.html). Maintaing
+ a consistent style across the whole code base makes it much easier to
+ jump into the code.
+
+1. If you're adding new parameters or a new function, you'll also need
+ to document them with [roxygen](https://github.com/klutometis/roxygen).
+ Make sure to re-run `devtools::document()` on the code before submitting.
+
+ Currently, ggplot2 uses the development version of roxygen2, which you
+ can get with `install_github("klutometis/roxygen")`. This will be
+ available on CRAN in the near future.
+
+1. If fixing a bug or adding a new feature to a non-graphical function,
+ please add a [testthat](https://github.com/hadley/testthat) unit test.
+
+1. If fixing a bug in the visual output, please add a visual test.
+ (Instructions to follow soon)
+
+1. If you're adding a new graphical feature, please add a short example
+ to the appropriate function.
+
+This seems like a lot of work but don't worry if your pull request isn't perfect. It's a learning process and Winston and I will be on hand to help you out. A pull request is a process, and unless you've submitted a few in the past it's unlikely that your pull request will be accepted as is.
+
+Finally, remember that ggplot2 is a mature package used by thousands of people. This means that it's extremely difficult (i.e. impossible) to change any existing functionality without breaking someone's code (or another package on CRAN). Please don't submit pull requests that change existing behaviour. Instead, think about how you can add a new feature in a minimally invasive way.
+
+## Advanced techniques
+
+### Fetching a branch from someone else's repository
+
+Sometimes you will want to fetch a branch from someone's repository, but without going to the trouble of seting it up as a remote. This is handy if you just want to quickly try out a someone's work.
+
+This will fetch a branch from someone's remote repository and check it out (replace `username` and `somebranch`):
+
+```
+git fetch https://github.com/username/ggplot2.git somebranch
+git checkout FETCH_HEAD
+```
+
+Just doing the above won't create a local branch -- you'll be in "detached HEAD" state. If you'd like to create a local branch to work on, run (you can replace `somebranch` with whatever name you like):
+
+```
+git checkout -b somebranch
+```
+
+### Adding other repositories as remotes
+
+If you often work off of someone else's repository, it can be useful to add their repo as a *remote*. This makes it easier to fetch changes in their repository. If the person's GitHub account is `otherdevel`, you would do the following:
+
+```
+git remote add otherdevel git://github.com/otherdevel/ggplot2.git
+git fetch otherdevel
+
+git checkout otherdevel/somebranch
+```
+
+If you don't want to follow them any more, run:
+
+```
+git remote rm otherdevel
+```
+
+### Delete a branch from GitHub
+
+If you pushed a branch to your GitHub repo but it's no longer needed there, you can remove it with:
+
+```
+git push origin :mybranch
+```
+
+### Visualizing the development tree
+
+GitHub has a very nice [development tree view](https://github.com/hadley/ggplot2/), but it of course only shows commits that have been pushed to GitHub. You may also want to view the tree on your local machine, to see how your local changes relate to the main tree. There are a number of programs out there that will do this.
+
+Mac:
+
+* gitk: Pretty basic, included with git. Run `gitk -a` to view all branches (by default it just shows you the current branch).
+
+* [gitx](http://gitx.laullon.com/): This is a bit nicer than gitk.
+
+* [SourceTree](http://www.sourcetreeapp.com/): This is also a nice program. Normally it costs money, but it is temporarily free from the web page or the [Mac App store](http://itunes.apple.com/us/app/sourcetree/id411678673?mt=12&ls=1).
+
+Linux:
+
+* gitk: (See gitk in Mac section)
+
+* gitg: This is nicer than gitk. By default it only shows the current branch; select "Local Branches" or "All Branches" to view others.
diff --git a/vignettes/release.Rmd b/vignettes/release.Rmd
new file mode 100644
index 0000000..2efe4bf
--- /dev/null
+++ b/vignettes/release.Rmd
@@ -0,0 +1,107 @@
+<!--
+%\VignetteEngine{knitr::knitr}
+%\VignetteIndexEntry{ggplot2 release process}
+-->
+
+```{r, echo = FALSE, message = FALSE}
+knitr::opts_chunk$set(
+ comment = "#>",
+ error = FALSE,
+ tidy = FALSE
+)
+library(ggplot2)
+```
+
+# Releasing a new version of ggplot2
+
+## Release candidate phase
+
+After issues resolved for a given release:
+
+1. Pass R CMD check.
+
+1. In DESCRIPTION and NEWS, remove the .99 version suffix and increment the
+ version number. For example, 0.9.2.99 becomes 0.9.3.
+
+1. Do the same for any packages that ggplot2 depends on, such as scales and
+ gtable.
+
+1. Update ggplot2's Import dependency versions to use the final release numbers
+ of scales and gtable.
+
+1. Commit these changes to a branch with `ggplot2-<version>-rc`, and push the
+ branch.
+
+1. Check packages that depend on ggplot2 with `devtools::revdep_check()` and
+ run visual tests.
+
+1. Email ggplot2, ggplot2-dev, and bcc the maintainers of packages that depend
+ on ggplot2 (`revdep_maintainers("ggplot2")`).
+
+ ```
+ Hi all,
+
+ We're very please to announce a release candidate for ggplot2 1.0.0! This
+ release celebrates the ggplot2 community: all improvements have been
+ contributed via pull requests.
+
+ We've made every effort to make sure that your existing ggplot2 graphics
+ continue to work. ggplot2 1.0.0 has passed R CMD check, all our existing
+ visual tests, and R CMD check on all dependencies. But it's still possible
+ that some bugs may have crept in, so we'd really appreciate it if you'd
+ try it out. It's easy to install the development version: first install
+ devtools, then run `devtools::install_github("hadley/ggplot2 at ggplot2-1.0.0-rc")`.
+
+ We plan to submit ggplot2 to cran in two weeks, May 9. Please let us know if
+ you have any problems - your feedback is much appreciated. (If you're pretty
+ sure you've discovered a new bug, please start a new thread or file
+ an issue on github, otherwise it's a bit hard to track what's going on).
+
+ Hadley & Winston
+ ```
+
+1. Notify cran:
+
+ ```
+ Dear CRAN maintainers,
+
+ ggplot2 1.0.0 has entered the release candidate phase and will be
+ submitted to CRAN in two weeks.
+
+ Included below is the email that I sent to the ggplot2 mailing and all
+ maintainers of packages that depend on ggplot2.
+
+ Regards,
+
+ Hadley
+ ```
+
+If problems arise during the RC period, make fixes on the branch. Those fixes
+later get merged back into master.
+
+## Release
+
+When the package is accepted on CRAN:
+
+1. Create a new release at https://github.com/hadley/ggplot2/releases.
+ The tag name should be of the form `v1.0.0`.
+
+1. If any Check out the new branch, or merge it into master. (Need to get off the
+ rc branch so it can be deleted):
+
+ ```
+ VERSION=1.0.0
+ git checkout v$VERSION
+ # Or
+ git checkout master
+ git merge v$VERSION
+ ```
+
+1. Delete the `-rc` branch, with:
+
+ ```
+ git branch -d v$VERSION-rc
+ git push origin :v$VERSION-rc
+ ```
+
+1. Once you push the tag github, travis will automatically build the website.
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/r-cran-ggplot2.git
More information about the debian-med-commit
mailing list