如何在ggplot中独立定位两个图例 [英] How do I position two legends independently in ggplot

查看:139
本文介绍了如何在ggplot中独立定位两个图例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有两个传说,涉及大小和颜色,并希望在上面有一个,图表。

这是可能的,如果是这样的话,怎么样

TIA

解决方案

从我的理解来看,基本上,对于 ggplot2 中的图例的控制非常有限。以下是哈德利书中的一段(第111页):ggplot2试图用尽可能少的传说来准确传达剧情中使用的美学。如果一个变量与多种审美一起使用,它通过组合传奇来实现。图6.14显示了点geom的一个例子:如果颜色和形状都映射到相同的变量,那么只需要一个图例。为了合并传说,它们必须具有相同的名称(相同的图例标题)。因此,如果您更改其中一个合并图例的名称,则需要对其中的所有图例进行更改。


Title pretty well covers it.

I have two legends, relating to size and colour, and wish to have one,say, on the top and one within the graph.

Is this possible and, if so, how

TIA

解决方案

From my understanding, basically there is very limited control over legends in ggplot2. Here is a paragraph from the Hadley's book (page 111):

ggplot2 tries to use the smallest possible number of legends that accurately conveys the aesthetics used in the plot. It does this by combining legends if a variable is used with more than one aesthetic. Figure 6.14 shows an example of this for the points geom: if both colour and shape are mapped to the same variable, then only a single legend is necessary. In order for legends to be merged, they must have the same name (the same legend title). For this reason, if you change the name of one of the merged legends, you’ll need to change it for all of them.

这篇关于如何在ggplot中独立定位两个图例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆