Discussion work on Data Visualisation - Thursday 19th January 2023

Discussion work 1 (10 mins)

Working on the msleep and mpg datasets in the ggplot2 package, using the plot command

  • ggplot(msleep%>%filter(!is.na(brainwt)),
  • mapping=aes(x=bodywt,
  • y=sleep_total,
  • shape=vore,
  • colour=order,
  • size=brainwt))+
  • geom_point(na.rm=FALSE)
  • or otherwise, tidy up the plot to more clearly show the data. Develop other plots that show the data. Compare using colours, shape, and facet_wraps to represent discrete data.

    Artificially modify the data to induce patterns to be detected. Try the following modifications:

  • y=sleep_total-3*(vore=="herbi"))
  • y=sleep_total+log(bodywt)*(vore=="herbi")
  • The first is a constant difference in sleep times based on diet. The second is an interaction between bodyweight and diet.

    Discussion work 2: (10 mins)

    For the mpg dataset, try to construct a misleading plot that gives the impression that Audi cars have better MPG than other cars.

    [Making misleading plots is unethical. This exercise is not to encourage unethical behaviour, but to understand ways in which plots can mislead, or can show particular conclusions.]