parent
030092229a
commit
75c4f8f36b
|
@ -13,7 +13,7 @@ source("_common.R")
|
|||
This chapter will teach you how to visualize your data using ggplot2.
|
||||
R has several systems for making graphs, but ggplot2 is one of the most elegant and most versatile.
|
||||
ggplot2 implements the **grammar of graphics**, a coherent system for describing and building graphs.
|
||||
With ggplot2, you can do more faster by learning one system and applying it in many places.
|
||||
With ggplot2, you can do more and faster by learning one system and applying it in many places.
|
||||
|
||||
If you'd like to learn more about the theoretical underpinnings of ggplot2, you might enjoy reading "The Layered Grammar of Graphics", <http://vita.had.co.nz/papers/layered-grammar.pdf>, the scientific paper that discusses the theoretical underpinnings..
|
||||
|
||||
|
@ -95,7 +95,7 @@ So `ggplot(data = mpg)` creates an empty graph, but it's not very interesting so
|
|||
|
||||
You complete your graph by adding one or more layers to `ggplot()`.
|
||||
The function `geom_point()` adds a layer of points to your plot, which creates a scatterplot.
|
||||
ggplot2 comes with many geom functions that each add a different type of layer to a plot.
|
||||
ggplot2 comes with many geom functions that each adds a different type of layer to a plot.
|
||||
You'll learn a whole bunch of them throughout this chapter.
|
||||
|
||||
Each geom function in ggplot2 takes a `mapping` argument.
|
||||
|
@ -796,7 +796,7 @@ ggplot(data = mpg, mapping = aes(x = displ, y = hwy)) +
|
|||
|
||||
Next, let's take a look at a bar chart.
|
||||
Bar charts seem simple, but they are interesting because they reveal something subtle about plots.
|
||||
Consider a basic bar chart, as drawn with `geom_bar()`.
|
||||
Consider a basic bar chart, as drawn with `geom_bar()` or `geom_col()`.
|
||||
The following chart displays the total number of diamonds in the `diamonds` dataset, grouped by `cut`.
|
||||
The `diamonds` dataset is in the ggplot2 package and contains information on \~54,000 diamonds, including the `price`, `carat`, `color`, `clarity`, and `cut` of each diamond.
|
||||
The chart shows that more diamonds are available with high quality cuts than with low quality cuts.
|
||||
|
@ -1111,7 +1111,7 @@ To learn more about a position adjustment, look up the help page associated with
|
|||
|
||||
Coordinate systems are probably the most complicated part of ggplot2.
|
||||
The default coordinate system is the Cartesian coordinate system where the x and y positions act independently to determine the location of each point.
|
||||
There are a three other coordinate systems that are occasionally helpful.
|
||||
There are three other coordinate systems that are occasionally helpful.
|
||||
|
||||
- `coord_flip()` switches the x and y axes.
|
||||
This is useful (for example), if you want horizontal boxplots.
|
||||
|
|
Loading…
Reference in New Issue