changing line width in stat_qq (with ggplot, in r)

2019-08-29 21:42发布

问题:

I am using ggplot with stat_qq to plot several samples.

I am trying to figure out how to change the width of the lines in the chart with no luck :-(

Here is (the relevant part of) my code:

ggplot(data=df,aes(sample=obser, colour = sample)) + 
stat_qq(dist=qunif) + 
scale_color_manual(values = c("samp_a" = "darkturquoise", "samp_b" = "hotpink", "samp_c" = "darkgrey")) + 
scale_x_continuous(breaks=x_ax) +
scale_y_continuous(breaks=y_ax) + 
theme(axis.text.x = element_text(angle = 90, hjust = 1,size = 10)) +
theme(panel.background = element_rect(fill='white', colour='grey')) +
theme(panel.grid.major = element_line(colour="lightgrey", size=0.5), panel.grid.minor = element_blank())

My current plot looks like this:

Any idea how to do it? I tried adding size to aes in ggplot with no luck and could not figure out the explanation about mapping for stat_qq:

http://docs.ggplot2.org/0.9.3/stat_qq.html

Thanks!!!

回答1:

You are mistaken in the belief that you are dealing with lines. You have many points and want to change the point size. Here is a simple example:

y <- rt(200, df = 5)
ggplot(data.frame(y), aes(sample=y)) +stat_qq(size=1)

There is a minimum possible point size.

If you want lines, you can use this:

ggplot(data.frame(y), aes(sample=y)) +stat_qq(geom="line", size=0.5)

The minimum line size is smaller than the minimum point size.