![]() ![]() Ypos = ypos = plot.build$panel$ranges]$y.range Xpos = xpos = plot.build$panel$ranges]$x.range First I create the graph with the points and the two lines, then I build it in order to get the range of the two axes, which I use in order to adjust the position of the texts. I assume that the problem has to do with the fact that the scaling of the axes is different (the range of values is about the same, but the width of my figure is about three times the height).Ĭurrently I proceed the following way. I've managed to put a text into the corner of each quadrant, but the positions are not perfect. I think the best way to do this would be a number in each of the four corners of the graph (alternative suggestions are welcome!). The code is much longer compared to the other plots, but the only line(s) to edit to adapt to your dataset is the aesthetics ( aes()).I've got a scatter plot with a horizontal and a vertical line, which depict thresholds values, and therefore they divide the plot into four quadrants. Justification = 1.1, # move points away from boxplot Side = "left", # place points on opposite side of density curve Sample_n(100) %>% # random sample of size 100 Now the same chart but with dotplots this time (more appropriate with small samples): # density plot: Seed = 1, # set seed for same random representation Position = position_jitter( # obtain shifted points ![]() ![]() Geom_point(aes(colour = drv), # add color on points width = 0, point_colour = NA # remove interval present by default Justification = -0.2, # move curves to the right Width = 0.5, # set the height of the curves Ggplot(aes(x = drv, y = hwy, fill = drv)) +Īdjust = 0.5, # set the smoothing parameter Let’s illustrate the raincloud plot, first with jittered points (more appropriate with large samples): 2 library(tidyverse) The advantage of this plot is that it illustrates, all at once, the distribution (with the density curve), the summary measures (first, second and third quartiles, and maximum/mininum without outliers thanks to the boxplot) and the number of observations (either via a dotplot or via jittered points).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |