Examples for 'ggplot2::geom_dotplot'


Dot plot

Aliases: geom_dotplot

Keywords:

### ** Examples

ggplot(mtcars, aes(x = mpg)) +
  geom_dotplot()
Bin width defaults to 1/30 of the range of the data. Pick better value with `binwidth`.
plot of chunk example-ggplot2-geom_dotplot-1
ggplot(mtcars, aes(x = mpg)) +
  geom_dotplot(binwidth = 1.5)
plot of chunk example-ggplot2-geom_dotplot-1
# Use fixed-width bins
ggplot(mtcars, aes(x = mpg)) +
  geom_dotplot(method="histodot", binwidth = 1.5)
plot of chunk example-ggplot2-geom_dotplot-1
# Some other stacking methods
ggplot(mtcars, aes(x = mpg)) +
  geom_dotplot(binwidth = 1.5, stackdir = "center")
plot of chunk example-ggplot2-geom_dotplot-1
ggplot(mtcars, aes(x = mpg)) +
  geom_dotplot(binwidth = 1.5, stackdir = "centerwhole")
plot of chunk example-ggplot2-geom_dotplot-1
# y axis isn't really meaningful, so hide it
ggplot(mtcars, aes(x = mpg)) + geom_dotplot(binwidth = 1.5) +
  scale_y_continuous(NULL, breaks = NULL)
plot of chunk example-ggplot2-geom_dotplot-1
# Overlap dots vertically
ggplot(mtcars, aes(x = mpg)) +
  geom_dotplot(binwidth = 1.5, stackratio = .7)
plot of chunk example-ggplot2-geom_dotplot-1
# Expand dot diameter
ggplot(mtcars, aes(x = mpg)) +
  geom_dotplot(binwidth = 1.5, dotsize = 1.25)
plot of chunk example-ggplot2-geom_dotplot-1
# Change dot fill colour, stroke width
ggplot(mtcars, aes(x = mpg)) +
  geom_dotplot(binwidth = 1.5, fill = "white", stroke = 2)
plot of chunk example-ggplot2-geom_dotplot-1
## No test: 
# Examples with stacking along y axis instead of x
ggplot(mtcars, aes(x = 1, y = mpg)) +
  geom_dotplot(binaxis = "y", stackdir = "center")
Bin width defaults to 1/30 of the range of the data. Pick better value with `binwidth`.
plot of chunk example-ggplot2-geom_dotplot-1
ggplot(mtcars, aes(x = factor(cyl), y = mpg)) +
  geom_dotplot(binaxis = "y", stackdir = "center")
Bin width defaults to 1/30 of the range of the data. Pick better value with `binwidth`.
plot of chunk example-ggplot2-geom_dotplot-1
ggplot(mtcars, aes(x = factor(cyl), y = mpg)) +
  geom_dotplot(binaxis = "y", stackdir = "centerwhole")
Bin width defaults to 1/30 of the range of the data. Pick better value with `binwidth`.
plot of chunk example-ggplot2-geom_dotplot-1
ggplot(mtcars, aes(x = factor(vs), fill = factor(cyl), y = mpg)) +
  geom_dotplot(binaxis = "y", stackdir = "center", position = "dodge")
Bin width defaults to 1/30 of the range of the data. Pick better value with `binwidth`.
plot of chunk example-ggplot2-geom_dotplot-1
# binpositions="all" ensures that the bins are aligned between groups
ggplot(mtcars, aes(x = factor(am), y = mpg)) +
  geom_dotplot(binaxis = "y", stackdir = "center", binpositions="all")
Bin width defaults to 1/30 of the range of the data. Pick better value with `binwidth`.
plot of chunk example-ggplot2-geom_dotplot-1
# Stacking multiple groups, with different fill
ggplot(mtcars, aes(x = mpg, fill = factor(cyl))) +
  geom_dotplot(stackgroups = TRUE, binwidth = 1, binpositions = "all")
plot of chunk example-ggplot2-geom_dotplot-1
ggplot(mtcars, aes(x = mpg, fill = factor(cyl))) +
  geom_dotplot(stackgroups = TRUE, binwidth = 1, method = "histodot")
plot of chunk example-ggplot2-geom_dotplot-1
ggplot(mtcars, aes(x = 1, y = mpg, fill = factor(cyl))) +
  geom_dotplot(binaxis = "y", stackgroups = TRUE, binwidth = 1, method = "histodot")
plot of chunk example-ggplot2-geom_dotplot-1
## End(No test)

[Package ggplot2 version 3.3.6 Index]