1

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))
Peter
  • 11,500
  • 5
  • 21
  • 31
Ali Abd
  • 11
  • 3
  • 2
    It's easier to help you if you provide a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick May 16 '22 at 21:05
  • https://github.com/eliocamp/ggnewscale – Jon Spring May 16 '22 at 21:07

2 Answers2

0

The fill parameter inside aes wich you can manipulate manually using scale_fill_manual works perfectly with polygons or raster data. But, when you need to color points or simple lines, the color parameter inside aes 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.

Lucca Nielsen
  • 1,497
  • 3
  • 16
-1

package "ggnewscale" will work in this problem. It allows to use different scale for color in one plot.

Ali Abd
  • 11
  • 3