[英]change textposition of colourbar in scale_color_discrete
I generate the legend in my ggplot2 plot with 我在ggplot2图中生成图例
scale_colour_discrete(name=textCF)
I like that i can see which colour belongs to which value, but it consumes to much space in the plot. 我喜欢这样,我可以看到哪种颜色属于哪个值,但是它占用了绘图中的大量空间。
I tried also the scale_colour_gradientn
scheme, but this is so condensed, that i can not distiguish the values anymore. 我也尝试过scale_colour_gradientn
方案,但这太简明了,以至于我再也无法掩盖这些值了。 If i could only change the width of this colourbar. 如果我只能更改此色标的宽度。
scale_colour_gradientn(name=textCF,colours = rainbow(nrow(mydf), start=2/6), breaks=round(mydf$CF)) +
How can I improve the lookout? 如何改善监视效果?
The size of a colourbar can be controlled with the barwidth
and barheight
parameters. 色条的大小可以通过barwidth
和barheight
参数控制。
Start with a reproducible example to see the effects: 从一个可复制的示例开始,以查看效果:
ggplot(mtcars, aes(x=wt, y=mpg, colour=qsec)) +
geom_point() +
scale_colour_gradient() +
theme(legend.position = "bottom")
I'm using scale_colour_gradient
, but this works in general. 我正在使用scale_colour_gradient
,但这通常可以工作。
You control aspects of the guide with the guide
argument to a scale. 您可以使用带有比例尺的guide
参数控制该指南的各个方面。 See the help on guide_colourbar
for all the parameters that you can set. 有关可以设置的所有参数,请参见guide_colourbar
上的帮助。
ggplot(mtcars, aes(x=wt, y=mpg, colour=qsec)) +
geom_point() +
scale_colour_gradient(guide = guide_colourbar(barwidth=20, barheight=2)) +
theme(legend.position = "bottom")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.