ggplot2 - geom_segment plot in R -
i trying make plot showing different types , magnitudes of change between several types of map categories on time.
i found thread helpful can't quite want: proportionally sized arrows in ggplot
i have dataframe looks this:
class1 class2 changetype changemagnitude 1 2 green 234 1 3 green 22 2 1 red 171 2 3 green 144 3 1 red 27 3 2 red 56
i want plot lines length of arrows or size of arrow heads proportional "changemagnitude" , want colour of arrows vary changetype (e.g., increase = green, decrease =red).
here code tried:
library(ggplot2) library(grid) ggplot(mydata, aes(x=class1, y=class2)) + geom_segment(aes(xend=type1, yend=type2),data=mydata, colour=mydata$changetype, arrow = arrow(length = unit(mydata$changemagnitude*1, "cm")))
the colour argument doesn't work @ , i'm not sure arrows giving me want. suggestions appreciated.
alternatively, may better use proportional point symbols rather arrows...
Comments
Post a Comment