0

I have several plots of the abundance of a particular species over my study area. I have been using image plot successfully. But now, I just want to plot presence/absence, so values from 0 to 1, and the plot stills shows me a continuous legend. Is there a way to modify this?

I have tried with image but the legend is not that cool. This is my code:

 colnames(zz)<-c("x","y","z")
 ras<-rasterFromXYZ(zz) 
 asc<-asc.from.raster(ras)
 image.plot(asc,
       xlim=c(-9.5,-1),ylim=c(43,48),zlim=c(min(asc,na.rm=T),max(asc,na.rm=T)),
       ylab="Latitude (ºN)",xlab="Longitude (ºW)",
       col = viridis(2, option = "D"))

And this is the plot

SecretAgentMan
  • 2,856
  • 7
  • 21
  • 41
Barruti
  • 1
  • 1
  • convert your discrete variable to factor with as.factor() function – Dimitrios Zacharatos Feb 24 '20 at 12:52
  • it would be a good idea as well to provide examples of your code and data so people can debug and find the problem in your code. this will help others help you. – Dimitrios Zacharatos Feb 24 '20 at 12:53
  • 3
    Please take a look at [How to make a great R reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example), to modify your question, with a smaller sample taken from your data (check `?dput()`). Posting images of your data or no data makes it difficult to impossible for us to help you! – massisenergy Feb 24 '20 at 12:53
  • 1
    Please share the code you used to create the plot too.. if you are referring to image function from graphics it should work – StupidWolf Feb 24 '20 at 13:29

0 Answers0