How to change border thickness in a violin plot in R?

3.8k Views Asked by At

I would like to increase border thickness of the violin plot in R. I tried to use lwd = x, but it makes it extremely thick no matter what number I replace x with. To be clear I want the border of the actual violins to be thicker.

Example df:

variable value
group1    26
group1    36
group1    26
group1    26
group1    27
group1    27
group2   100
group2   95
group2   120
group2   135
group2   88
group2   102

I am using the following code to plot the graph:

ggplot(df, aes(x = variable, y = value)) + 
  geom_violin(aes(fill = variable)) + 
  stat_summary(fun.y=median, geom="point") + 
  scale_fill_manual(values = c("blue", "green")) + 
  scale_y_continuous(trans = "log2") + 
  ylab("Quantity") + 
  scale_x_discrete(labels = c("group1", "group2")) + 
  theme(legend.position = "none")

I used lwd as follows: + geom_violin(aes(fill = variable, lwd = 1)) but any number I replace makes the border extremely thick. I just want it slightly thicker.

0

There are 0 best solutions below