Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

An implementation of the Grammar of Graphics in R

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md
NotificationsYou must be signed in to change notification settings

tidyverse/ggplot2

R-CMD-checkCRAN_Status_BadgeCodecov test coverage

Overview

ggplot2 is a system for declaratively creating graphics, based onTheGrammar ofGraphics. Youprovide the data, tell ggplot2 how to map variables to aesthetics, whatgraphical primitives to use, and it takes care of the details.

Installation

# The easiest way to get ggplot2 is to install the whole tidyverse:install.packages("tidyverse")# Alternatively, install just ggplot2:install.packages("ggplot2")# Or the development version from GitHub:# install.packages("pak")pak::pak("tidyverse/ggplot2")

Cheatsheet

ggplot2 cheatsheet

Usage

It’s hard to succinctly describe how ggplot2 works because it embodies adeep philosophy of visualisation. However, in most cases you start withggplot(), supply a dataset and aesthetic mapping (withaes()). Youthen add on layers (likegeom_point() orgeom_histogram()), scales(likescale_colour_brewer()), faceting specifications (likefacet_wrap()) and coordinate systems (likecoord_flip()).

library(ggplot2)ggplot(mpg, aes(displ,hwy,colour=class))+  geom_point()

Scatterplot of engine displacement versus highway miles per gallon, for 234 cars coloured by 7 'types' of car. The displacement and miles per gallon are inversely correlated.

Lifecycle

lifecycle

ggplot2 is now 18 years old and is used by hundreds of thousands ofpeople to make millions of plots. That means, by-and-large, ggplot2itself changes relatively little. When we do make changes, they will begenerally to add new functions or arguments rather than changing thebehaviour of existing functions, and if we do make changes to existingbehaviour we will do them for compelling reasons.

If you are looking for innovation, look to ggplot2’s rich ecosystem ofextensions. See a community maintained list athttps://exts.ggplot2.tidyverse.org/gallery/.

Learning ggplot2

If you are new to ggplot2 you are better off starting with a systematicintroduction, rather than trying to learn from reading individualdocumentation pages. Currently, there are several good places to start:

  1. TheData Visualization andCommunication chapters inRfor Data Science. R for Data Science isdesigned to give you a comprehensive introduction to thetidyverse, and these two chapters will getyou up to speed with the essentials of ggplot2 as quickly aspossible.

  2. If you’d like to take an online course, tryData Visualization in RWithggplot2by Kara Woo.

  3. If you’d like to follow a webinar, tryPlotting Anything withggplot2 by Thomas Lin Pedersen.

  4. If you want to dive into making common graphics as quickly aspossible, I recommendThe R GraphicsCookbook by Winston Chang. It provides aset of recipes to solve common graphics problems.

  5. If you’ve mastered the basics and want to learn more, readggplot2:Elegant Graphics for Data Analysis. Itdescribes the theoretical underpinnings of ggplot2 and shows you howall the pieces fit together. This book helps you understand thetheory that underpins ggplot2, and will help you create new types ofgraphics specifically tailored to your needs.

  6. For articles about announcements and deep-dives you can visit thetidyverse blog.

Getting help

There are two main places to get help with ggplot2:

  1. ThePosit Community (formerly RStudioCommunity) is a friendly place to ask any questions about ggplot2.

  2. StackOverflowis a great source of answers to common ggplot2 questions. It is alsoa great place to get help, once you have created a reproducibleexample that illustrates your problem.

About

An implementation of the Grammar of Graphics in R

Topics

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Code of conduct

Contributing

Stars

Watchers

Forks

Contributors346

Languages


[8]ページ先頭

©2009-2025 Movatter.jp