swassey
swassey

Reputation: 1

Line width not displayed properly in RStudio

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!

Upvotes: 0

Views: 180

Answers (1)

danlooo
danlooo

Reputation: 10627

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.

Upvotes: 1

Related Questions