XY Plot with R

I have this data

X, Y, ag 4068961.415, 731027.852, 1.5000 4068962.701, 731027.829, 0.9500 4068963.986, 731027.807, 2.5000 4068965.271, 731027.784, 2.5000 4068875.402, 730996.864, 3.9000 4068875.402, 730996.864, 3.0796 4068875.402, 730996.864, 1.6060 4068910.645, 731067.069, 0.6400 

Want a reproducible example? copy this data and do d <- read.csv("clipboard")

How can I get a map view showing a column named ag , depending on its coordinate?

I want to

  • X column on the x axis
  • Y column of Y axis
  • depending on the value of ag , the color of the dialed point changes (from yellow to red).
+4
source share
3 answers

In the R database, you can use something like this:

 with(d, plot(X, Y, col=rainbow(n=length(ag),start=0, end=1/6)[order(ag)], pch=19)) 
+2
source

You can do this with the ggplot2 library. To change the color scale use scale_color_gradient()

 library(ggplot2) ggplot(d,aes(X,Y,color=ag))+geom_point()+ scale_color_gradient(low="yellow",high="red") 
+3
source

I assume you tried: with(d,plot(Y~X,col=ag)) ?

+1
source

Source: https://habr.com/ru/post/1496789/


All Articles