Skip to content

megomars/GGPlot2IntheBatcave

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

# GGPlot2 in the Batcave

GGPlot2 is a data visualization library created by Hadley Wickham. It is based on the "grammar of graphics", an idea that a graph can be built and rebuilt using interchangable components. At its core it contains:

![The layers involved](layers.png)
* Data - dataset being plotted.
* Aesthetics - scales onto which we map our data.
* Geometries - The visual elements used for our data.
* Facets - Plotting small multiples.
* Statistics - Representations of our data to aid understanding.
* Coordinates - The space on which the data will be plotted.
* Themes - All non-data ink.

![The values](values.png)

## Getting started
```{r}
library(ggplot2)

ggplot(mpg, aes(x = displ)) + geom_bar() # The simplest chart you can make
qplot(data=mpg, x=cty, y=hwy, geom="point") #Qplot is just a shorthand for ggplot
ggplot(diamonds, aes(x = carat, y = price, col=clarity)) + geom_point(alpha=0.4)
milechart <- ggplot(mpg, aes(x=hwy)) + geom_bar()
ggsave("plot.png", width=10, height=10) #saves the previous chart as a png
```

## Recycle your plots
```{r}
p <- ggplot(iris, aes(x=Petal.Width, y=Petal.Length))
p+geom_point()
p+geom_jitter()
p+coord_polar()

p <- ggplot(dbase)

```

##Geoms

About

ggplot2 datacamp course

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages