Swapping the axes in a Q-Q plot created ggplot2


I refer to the video

[How to create a normal Q-Q plot in R using ggplot2](How to create a normal Q-Q plot in R using ggplot2? | StatswithR | Arnab Hazra - YouTube .)

Can you please kindly advise if there is a way of editing the recommended code to ensure that the theoretical and sample quantiles are represented on the vertical and horizontal axes, respectively (and therefore the axes are swapped)?

If you are creating the plot yourself, you can swap the order of the arguments to aes(), something like:

data %>%
  ggplot() +
  aes(theoretical, sample) +

If the plot is already created and you have the ggplot object in-hand, you can flip the axes with coord_flip():

ggplot_obj + coord_flip()

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.