Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 如何使用指南步骤仅标记某些级别?_R_Ggplot2_Legend - Fatal编程技术网

R 如何使用指南步骤仅标记某些级别?

R 如何使用指南步骤仅标记某些级别?,r,ggplot2,legend,R,Ggplot2,Legend,这是我在Stackoverflow的第一个问题,所以我希望样式是正确的 我有一个等高线图,如本例所示: ggplot(faithfuld, aes(x = waiting, y = eruptions, z = 100 * density)) + geom_contour_filled(breaks = seq(-4, 4, length.out = 25)) + scale_fill_viridis_d(guide = guide_coloursteps(barwidth = uni

这是我在Stackoverflow的第一个问题,所以我希望样式是正确的

我有一个等高线图,如本例所示:

ggplot(faithfuld, aes(x = waiting, y = eruptions, z = 100 * density)) +
  geom_contour_filled(breaks = seq(-4, 4, length.out = 25)) + 
  scale_fill_viridis_d(guide = guide_coloursteps(barwidth = unit(7,"cm"), show.limits = T)) +
  theme( legend.position = "bottom")
不幸的是,只能标记整个轴或删除所有标签(
label=FALSE
)。我想为极端价值,也许在中间和中间和边界之间的标签。< /P>
有什么解决方案吗?

有两种解决方法,我们可以使用

主题(legend.position=“bottom”,
legend.text=元素\文本(角度=90))
或者,我们可以手动提供标签

scale_fill_u viridis_d(guide=guide_colorSteps(条形宽度=单位(7,“cm”),show.limits=F),
标签=c('0'、''、''、''、''、'2'、''、''、''、''、''、'4'))+

这并不优雅,但是
标签
参数要求每个
类别
都有
标签

非常感谢。这真的解决了我的问题!