0

I am trying to visualize a track on a map using ggmap + geom_path. This works fine with my coordinate dataset. Now I just want to change the color of the path using another parameter's values, which vary from -0.4 to 1. I am using the following part of code:

 ggmap(m)+geom_path(data=ricky_df, aes(x=temp$GPS_x[1:850], y=temp$GPS_y[1:850]),colour=abs(soc_long)*100,size=1.5,lineend="round")

And the corresponding output is the following:

enter image description here

So, my problem is that there are many colors and I want to have for example one color which would be changed from dark to light. Does anybody have an idea how can I get this smoothing gradient? Thanks

ArmMiner
  • 215
  • 3
  • 5
  • 15
  • 1
    Include `colour` inside the `aes` call. You may need to add a `scale_colour_gradient()` too. – Simon O'Hanlon Nov 12 '13 at 14:00
  • when I include colour inside aes, I am getting an error telling object not found! – ArmMiner Nov 12 '13 at 14:06
  • So `soc_long` is not a column of your data.frame. I suggest you post a minimal reproducible example – Simon O'Hanlon Nov 12 '13 at 14:06
  • Thanks! I solved this with including the colour inside aes! The color is blue and the brightness varies according to the value. This is exactly what I wanted! :) For the future updates: is there a way to play wiht the colors? Like in my case to specify green and red, so that the color gradient would change it smoothly from green to red. – ArmMiner Nov 12 '13 at 14:21
  • 2
    add something like `last_plot()+ scale_solor_gradient(low='green',high='red')` and then put all this as an answer to your own question. – agstudy Nov 12 '13 at 14:33
  • If you want to 'play with colours', you may have a look at [the RColorBrewer package](http://cran.r-project.org/web/packages/RColorBrewer/RColorBrewer.pdf) and the [corresponding web site](http://colorbrewer2.org/). – Henrik Nov 12 '13 at 14:39
  • one more question! :) can I add arrows on the line? Just to show the direction. Also, how shall I put this all as an answer :D – ArmMiner Nov 12 '13 at 14:53

0 Answers0