0

I am working on a boxplot to display parameter estimates in RStudio, so far, so good, however, there seems to be a problem when I try to change the size of elements. I only want to make the line slightly bigger, but when I try, the lines are displayed in a much larger size, regardless of what size I put in: See an example below.

ggplot(ParameterEstimates, aes(x = Substance, y = Betas, color = Substance, size = 0.5))+ 

for the example I put in a value of 0.5 and 3, respectively

    stat_boxplot(geom='errorbar', width = 0.5, position=position_dodge())+
    geom_boxplot(outlier.shape=NA)+
    geom_point(position=position_jitterdodge())+
    coord_cartesian(ylim = c(-1.5, 1.25))+
    labs (x="Group", y="Beta-Weights", title = "Parameter Estimates")+
    theme(plot.title = element_text(color = "grey20", size = 20, hjust = 0.5),
                                 axis.text.x = element_text(color = "grey20", size = 13, angle = 0, hjust = .5, vjust = .5, face = "plain"),
                                 axis.text.y = element_text(color = "grey20", size = 13, angle = 0, hjust = 1, vjust = 0, face = "plain"),  
                                 axis.title.x = element_text(color = "grey20", size = 15, angle = 0, hjust = .5, vjust = 0, face = "plain"),
                                 axis.title.y = element_text(color = "grey20", size = 15, angle = 90, hjust = .5, vjust = .5, face = "plain"),
                                 panel.background = element_rect(colour = "black"),
                                 panel.grid.major = element_line(size = 0.25, linetype = 'solid', colour = "grey"),
                                 panel.grid.minor = element_line(size = 0.25, linetype = 'solid', colour = "grey"))+
    scale_colour_manual(values = c("#226C8C", "#DE8B2D" )) 

Size 0.5

Size 3

Can you tell me if I am doing something wrong? Thank you for your help!

Gregor Thomas
  • 136,190
  • 20
  • 167
  • 294

1 Answers1

1

The unit of size=1 in ggplot is 1pt = 0.35mm. Depending on your plot size, it might be 1 or 10 pixels. Draw your plot to look pretty at a fixed size (e.g. 15x15cm) and adjust size to that frame. Then, export the plot with the same dimensions for width and height and just increase the dpi to get more pixels while preserving proportions.

danlooo
  • 10,067
  • 2
  • 8
  • 22
  • Thank you for your reply, I tried your recommendation and used `ggsave` to save the plot to a fixed plot-size, however the size of the lines is still unchanged between different inputs (I tried 1 pt and 10pt, to _really_ see a difference), might there be another reason? – swassey Dec 08 '21 at 14:03
  • I need the code in order to understand what you did – danlooo Dec 08 '21 at 15:02