我正在尝试使用rpy2在ggplot2中自定义一个图例。我注意到ggplot2到rpy2没有scale_shape_discrete和其他在中显示为自定义图例所必需的方法。
from rpy2.robjects.lib import ggplot2
# not present
ggplot2.scale_shape_discrete
在ggplot2中通过rpy2重命名/自定义离散图例的正确方式是什么?这些方法是否可访问?
我有一个使用scale_fill_gradientn在ggplot2中创建的图。我想在最小和最大比例图例中添加文本。例如,在图例最小值显示" minimum“,在图例最大值显示" maximum”。有一些帖子使用离散填充,并添加带有数字而不是文本的标签(例如),但我不确定如何将labels功能与scale_fill_gradientn一起使用,以便仅在最小和最大处插入文本。目前,我倾向于得到错误:
Error in scale_labels.continuous(scale, breaks) :
Breaks and labels are different lengths
我使用的是Maps.R库中的worldmap函数。它在ggplot2中运行。
我想把图例做得更大一点。我正在使用
theme(legend.key.size = unit(measure, "units"))
我的R终端返回:
could not find function "unit"
有什么线索知道这里发生了什么吗?我相信这是ggplot2中调整图例大小的正确语法。
非常感谢,bfb
当使用黑色背景的ggplot2主题时,是否可以控制颜色参考线以外的参考线的图例颜色,以便不以黑色绘制?如果是这样的话,是怎么做的?
library(ggplot2) # needs to be 0.9.3 for this theme
data(iris) # included with ggplot2
theme_black<- function (base_size = 16, base_family = ""){
theme_minimal() %+replace%
theme(
line = el
我想把点放在地图上,但我想让图例只显示填充。下面的代码显示了我想要的plot1图例,但是在plot2图例的填充上覆盖了一个点。我怎样才能摆脱plot2传说中的这一点呢?我想要和plot1的传奇人物一起的plot2。
library(sp)
library(maptools)
library(rgeos)
library(ggplot2)
library(ggmap)
# prepare a map of USA and Canada
data(wrld_simpl)
canada.usa <- wrld_simpl[wrld_simpl$NAME %in% c("Canada