ggplot(heightweight, aes(x=ageYear, y=heightIn, size=weightLb, color=sex))+geom_point(alpha=0.3) +labs(title="Height and weight of school children",subtitle="Height vs Weight",caption="Source: heightweight",x="Age (year)",y="Height (inches)",size="Weight(Lb)",color="Gender")
ggplot(heightweight, aes(x=ageYear, y=heightIn, size=weightLb, color=sex))+geom_point(alpha=0.3) +labs(title="Height and weight of school children",subtitle="Height vs Weight",caption="Source: heightweight",x="Age (year)",y="Height (inches)",size="Weight(Lb)",color="Gender") +theme_classic()
ggplot(heightweight, aes(x=weightLb, fill=sex)) +geom_histogram(alpha=0.4) +scale_fill_manual(values=c("orange", "yellow")) +labs(title ="A histogram of the weight of school children",subtitle ="By gender",x="WeightLb",y="Count",fill="Gender") +theme_minimal()
3.3 Exercise 5-3
ggplot(mpg, aes(x=hwy, fill=drv)) +geom_histogram(alpha=0.5) +facet_grid(vars(drv)) +labs(title="Histogram using facet_grid()",subtitle="Histogram of Highway Mile Per Gallon",caption="Source: mpg") +theme_minimal()
3.4 Exercise 5-4
ggplot(midwest, aes(x = area, y = poptotal)) +geom_point(alpha=0.4, aes(size = popdensity, color = state)) +geom_smooth(se=FALSE) +xlim(c(0, 0.1)) +ylim(c(0, 500000)) +labs(title ="Scatterplot",subtitle ="Area Vs Population",x ="Area",y ="Population",caption ="midwest") +theme_classic()