easyGgplot2 icon indicating copy to clipboard operation
easyGgplot2 copied to clipboard

ggplot2 boxplot dotSize

Open ghost opened this issue 9 years ago • 1 comments

It would be nice if dotSize could accept a variable name (aesthetic mapping).

Is there a way to get the generated ggplot command that your functions create?

ghost avatar Jul 03 '15 10:07 ghost

Thank you for this suggestion. The easyGgplot2 package is under intensive modifications in order to simplify the package and to add many other options.

Pending new verision of easyGgplot2 , I suggest the following quick-start-guides to customize your boxplot and/or your dotplot with ggplot2:

  • ggplot2 dot plot - Quick start guide : http://www.sthda.com/english/wiki/ggplot2-dot-plot-quick-start-guide-r-software-and-data-visualization
  • ggplot2 box plot - Quick start guide: http://www.sthda.com/english/wiki/ggplot2-box-plot-quick-start-guide-r-software-and-data-visualization
  • ggplot2 stripchart (jitter) : Quick start guide: http://www.sthda.com/english/wiki/ggplot2-stripchart-jitter-quick-start-guide-r-software-and-data-visualization

Load ggplot2

library("ggplot2")

Prepare the data

# Load data
data(ToothGrowth)
# Convert the variable dose from a numeric to a factor variable
ToothGrowth$dose <- as.factor(ToothGrowth$dose)

Combine box plot and dot plot

# Default plot
ggplot(ToothGrowth, aes(x=dose, y=len)) + 
  geom_boxplot(notch = TRUE)+
  geom_dotplot(binaxis='y', stackdir='center')

# Change dot size using numeric value
ggplot(ToothGrowth, aes(x=dose, y=len)) + 
  geom_boxplot(notch = TRUE)+
  geom_dotplot(binaxis='y', stackdir='center', dotsize = 1.5)

rplot

kassambara avatar Jul 05 '15 08:07 kassambara