在r中使用scale_fill_manual在ggplot中的特定层
我很难将我的栅格绘制和某些点为SF对象。我使用aes(color = ...)
将颜色分配给我的观点的不同类型。但是我想将这些颜色更改为红色,蓝色和黄色等特定的颜色。另外,我不能使用scale_fill_manual
,因为我的栅格层的颜色是第一层的,因此不应更改。有解决这个问题的解决方案吗? 提前致谢
geom_raster(data=dem2,aes(x=x,y=y,fill=elevation))+
geom_sf(data=mypoint,aes(shape=Type,colour=ranges))
I have trouble for plotting my raster and some points as sf object over that. I use aes(color=...)
to assign color to different types of my points. But I want to change the colours to specific ones like red and blue and yellow. also I can't use scale_fill_manual
because my raster layer's colours which is in first layer, shouldn't be changed. Is there any solution for this problem?
thanks in advance
geom_raster(data=dem2,aes(x=x,y=y,fill=elevation))+
geom_sf(data=mypoint,aes(shape=Type,colour=ranges))
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
填充
参数aes
您可以使用scale_fill_manual
手动操作,可与多边形或栅格数据完美搭配。但是,当您需要着色时或简单的行,
color
参数aes
是。说,如果您想将不同的颜色掩盖到要点,使用Scale_color_manual
,这不应干扰您的栅格颜色。The
fill
parameter insideaes
wich you can manipulate manually usingscale_fill_manual
works perfectly with polygons or raster data. But, when you need to color pointsor simple lines, the
color
parameter insideaes
is prefered. Said that, if you want to assing different colors to your points,use scale_color_manual
, this shouldnt interfer in your raster color.软件包“ ggnewscale”将在此问题中起作用。它允许在一个图中使用不同的尺度。
package "ggnewscale" will work in this problem. It allows to use different scale for color in one plot.