Description Usage Arguments Details Examples
There are two types of bar charts, determined by what is mapped to bar height. By default, geom_bar uses stat_count which makes the height of the bar proportion to the number of cases.
1 2 3 |
mapping |
Set of aesthetic mapping created by aes or aes_. |
data |
The data to be displayed in this layer. |
stat |
Override the default connection between geom_bar and stat_count |
position |
Position adjustment, either as a string, or the result of a call to a position adjustment function. |
width |
Bar width. |
binwidth |
geom_bar no longer has a binwidth argument |
... |
other arguments passed on to layer. |
na.rm |
If FALSE, removes missing values with a warning (not used in ggplot2.SparkR). |
show.legend |
logical. Should this layer be included in the legends? |
inherit.aes |
If FALSE, overrides the default aesthetics, rather ehan combining with them. |
A bar chart maps the height of the bar to a variable, and so the base of the bar must always be shown to produce a valid visual comparison. Naomi Robbins has a nice article on this topic. This is why it doesn't make sense to use a log-scaled y axis with a bar chart.
1 2 3 4 5 6 7 8 9 10 11 | ## Not run:
ggplot(faithful, aes(x = eruptions)) + geom_bar()
df <- createDataFrame(sqlContext, faithful)
ggplot(df, aes(x = eruptions)) + geom_bar()
df2 <- createDataFrame(sqlContext, diamonds)
ggplot(df2, aes(x = cut, fill = color)) + geom_bar(position = "dodge")
ggplot(df2, aes(cut)) + geom_bar() + facet_grid(. ~ clarity)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.