geom_bar: Bars, rectangles with bases on x-axisi

Description Usage Arguments Details Examples

Description

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.

Usage

1
2
3
geom_bar(mapping = NULL, data = NULL, stat = "count",
  position = "stack", width = NULL, binwidth = NULL, ..., na.rm = FALSE,
  show.legend = NA, inherit.aes = TRUE)

Arguments

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.

Details

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.

Examples

 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)

SKKU-SKT/ggplot2.SparkR documentation built on May 9, 2019, 11:13 a.m.