Program14

Author

Ashutosh

Write a r program to create multiple dot plots for grouped data comparing a distribution of variables across different categories,using ggplot2s position_.function tooth growth

library(ggplot2) #library in use

ToothGrowth$dose <- as.factor(ToothGrowth$dose) #making dose a factor

ggplot(ToothGrowth,aes(x=dose,y=len,color=supp))+
  geom_dotplot(
    binaxis="y", #plot dots in y axis
    stackdir = "center", #places dots in the center
    position = position_dodge(width=0.8),
    dotsize=0.6,
    binwidth=1.5 #vertical space dots
  )+
  labs(
    title = "Tooth Growth",
    x="doses",
    y="tooth len",
    color="Type"
    
  ) +
  theme_minimal() #used for better visual representation