kassambara / easyGgplot2

34 stars 10 forks source link

ggplot2 boxplot dotSize #1

Open ghost opened 9 years ago

ghost commented 9 years ago

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?

kassambara commented 9 years ago

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:

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