@@ -86,13 +86,13 @@ distributed, and plot a simple ggplot2 scatterplot.
86
86
df1 <- data.frame(x = rnorm(500, 50, 10), y = runif(500, 0, 50))
87
87
(p1 <- ggplot(df1, aes(x, y)) + geom_point() + theme_bw())
88
88
89
- <img src =" vignettes/overview_files /figure-markdown_strict/init-plot-1.png " style =" display : block ; margin : auto ;" />
89
+ <img src =" vignettes/ggExtra_files /figure-markdown_strict/init-plot-1.png " style =" display : block ; margin : auto ;" />
90
90
91
91
Ok, now let's add marginal density plots.
92
92
93
93
ggMarginal(p1)
94
94
95
- <img src =" vignettes/overview_files /figure-markdown_strict/ggmarginal-basic-1.png " style =" display : block ; margin : auto ;" />
95
+ <img src =" vignettes/ggExtra_files /figure-markdown_strict/ggmarginal-basic-1.png " style =" display : block ; margin : auto ;" />
96
96
97
97
That was easy. Notice how the syntax is not following the standard
98
98
ggplot2 syntax - you don't "add" a ggMarginal layer with
@@ -104,7 +104,7 @@ Let's make the text a bit larger to make it easier to see.
104
104
105
105
ggMarginal(p1 + theme_bw(30) + ylab("Two\nlines"))
106
106
107
- <img src =" vignettes/overview_files /figure-markdown_strict/ggmarginal-large-1.png " style =" display : block ; margin : auto ;" />
107
+ <img src =" vignettes/ggExtra_files /figure-markdown_strict/ggmarginal-large-1.png " style =" display : block ; margin : auto ;" />
108
108
109
109
Notice how the marginal plots occupy the correct space, and even when
110
110
the main plot's points are pushed to the right because of larger text or
@@ -114,7 +114,7 @@ You can also show histograms instead.
114
114
115
115
ggMarginal(p1, type = "histogram")
116
116
117
- <img src =" vignettes/overview_files /figure-markdown_strict/ggmarginal-hist-1.png " style =" display : block ; margin : auto ;" />
117
+ <img src =" vignettes/ggExtra_files /figure-markdown_strict/ggmarginal-hist-1.png " style =" display : block ; margin : auto ;" />
118
118
119
119
There are several more parameters, here is an example with a few more
120
120
being used. Note that you can use any parameters that the ` geom_XXX `
@@ -124,7 +124,7 @@ and `fill` in the following example.
124
124
ggMarginal(p1, margins = "x", size = 2, type = "histogram",
125
125
col = "blue", fill = "orange")
126
126
127
- <img src =" vignettes/overview_files /figure-markdown_strict/ggmarginal-params-1.png " style =" display : block ; margin : auto ;" />
127
+ <img src =" vignettes/ggExtra_files /figure-markdown_strict/ggmarginal-params-1.png " style =" display : block ; margin : auto ;" />
128
128
129
129
In the above example, ` size = 2 ` means that the main scatterplot should
130
130
occupy twice as much height/width as the margin plots (default is 5).
@@ -136,7 +136,7 @@ plots, you can use the `xparams` or `yparams` parameters, like this:
136
136
137
137
ggMarginal(p1, type = "histogram", xparams = list(binwidth = 1, fill = "orange"))
138
138
139
- <img src =" vignettes/overview_files /figure-markdown_strict/ggmarginal-extraparams-1.png " style =" display : block ; margin : auto ;" />
139
+ <img src =" vignettes/ggExtra_files /figure-markdown_strict/ggmarginal-extraparams-1.png " style =" display : block ; margin : auto ;" />
140
140
141
141
You don't have to supply a ggplot2 scatterplot, you can also just tell
142
142
ggMarginal what dataset and variables to use, but of course this way you
@@ -145,7 +145,7 @@ text/font/theme/etc).
145
145
146
146
ggMarginal(data = mtcars, x = "wt", y = "mpg")
147
147
148
- <img src =" vignettes/overview_files /figure-markdown_strict/ggmarginal-manual-1.png " style =" display : block ; margin : auto ;" />
148
+ <img src =" vignettes/ggExtra_files /figure-markdown_strict/ggmarginal-manual-1.png " style =" display : block ; margin : auto ;" />
149
149
150
150
Last but not least - you can also save the output from ` ggMarginal ` and
151
151
display it later. (This may sound trivial, but it was not an easy
@@ -155,7 +155,7 @@ discussion](http://stackoverflow.com/questions/29062766/store-output-from-gridex
155
155
p <- ggMarginal(p1)
156
156
p
157
157
158
- <img src =" vignettes/overview_files /figure-markdown_strict/ggmarginal-save-1.png " style =" display : block ; margin : auto ;" />
158
+ <img src =" vignettes/ggExtra_files /figure-markdown_strict/ggmarginal-save-1.png " style =" display : block ; margin : auto ;" />
159
159
160
160
For more information, see ` ?ggExtra::ggMarginal ` .
161
161
@@ -174,7 +174,7 @@ grid lines can be removed as well (default is to remove both).
174
174
p2 <- ggplot2::ggplot(df2, ggplot2::aes(x, y)) + ggplot2::geom_point()
175
175
p2 + removeGrid()
176
176
177
- <img src =" vignettes/overview_files /figure-markdown_strict/removeGrid-1.png " style =" display : block ; margin : auto ;" />
177
+ <img src =" vignettes/ggExtra_files /figure-markdown_strict/removeGrid-1.png " style =" display : block ; margin : auto ;" />
178
178
179
179
For more information, see ` ?ggExtra::removeGrid ` .
180
180
@@ -191,7 +191,7 @@ tick line.
191
191
p3 <- ggplot2::ggplot(df3, ggplot2::aes(x, y)) + ggplot2::geom_point()
192
192
p3 + rotateTextX()
193
193
194
- <img src =" vignettes/overview_files /figure-markdown_strict/rotateTextX-1.png " style =" display : block ; margin : auto ;" />
194
+ <img src =" vignettes/ggExtra_files /figure-markdown_strict/rotateTextX-1.png " style =" display : block ; margin : auto ;" />
195
195
196
196
For more information, see ` ?ggExtra::rotateTextX ` .
197
197
@@ -207,14 +207,14 @@ An example using a table:
207
207
208
208
plotCount(table(infert$education))
209
209
210
- <img src =" vignettes/overview_files /figure-markdown_strict/plotCount-table-1.png " style =" display : block ; margin : auto ;" />
210
+ <img src =" vignettes/ggExtra_files /figure-markdown_strict/plotCount-table-1.png " style =" display : block ; margin : auto ;" />
211
211
212
212
An example using a data.frame:
213
213
214
214
df4 <- data.frame("vehicle" = c("bicycle", "car", "unicycle", "Boeing747"),
215
215
"NumWheels" = c(2, 4, 1, 16))
216
216
plotCount(df4) + removeGridX()
217
217
218
- <img src =" vignettes/overview_files /figure-markdown_strict/plotCount-df-1.png " style =" display : block ; margin : auto ;" />
218
+ <img src =" vignettes/ggExtra_files /figure-markdown_strict/plotCount-df-1.png " style =" display : block ; margin : auto ;" />
219
219
220
220
For more information, see ` ?ggExtra::plotCount ` .
0 commit comments