You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A remark, perhaps useful. I got a request from a colleague of ISRIC to create in R a pedal chart, also called rose chart, like this (the data are fictional): .
As I couldn't find a function or package, I wrote something myself. It will probably need adjustments (for example, I made it static: it can only show six leaves), but for inspiration, this is the code:
## script for plotting six roses in polar plot - "Pedal chart" # Luc Steinbuch, 22/10/2016#You need to install this package one time:
install.packages('plotrix')
# and load it..
require(plotrix)
# mathematical background: # browseURL("http://www.shelovesmath.com/trigonometry/polar-graphs/#DrawingGraphs")# and then the "Rose" section## Note: script works only for 6 roses!## creating data frame# first column: value of rose (between 0 and 1)# second colum: corresponding color. See browseURL("http://www.stat.columbia.edu/~tzheng/files/Rcolor.pdf")# third column: corresponding label df_roses<-data.frame(c(0.8, 0.5, 0.95, 0.8, 0.75, 0.6),
c("lightgreen", "orange", "green", "lightgreen", "lightgreen", "grey90"),
c("Soil Organic Carbon", "Yield", "Earthworms", "Water holding capacity", "Aggregate stability", "pH" ) ,
stringsAsFactors=FALSE
)
names(df_roses) <- c("Value", "Color", "Label")
View(df_roses)
## For our convenience: data frame with angles corresponding to the roses, # because a polar plot is angle-baseddf_angles<-data.frame(2*pi/6*(0:5),
2*pi/6*(1:6),
2*pi/6*seq(from=0.5, to=5.5, by=1)
)
names(df_angles) <- c("Start", "End", "Center")
#View(df_angles)## first create empty plot, with labels# labels cannot be added later :-(
radial.plot( lengths=NA,
radial.pos=NA,
main="No-till versus conventional till",
radial.lim= c(0,1),
show.grid.labels=TRUE,
show.radial.grid=TRUE,
label.pos=df_angles$Center,
labels=df_roses$Label
)
## add roses one by one with for-loopfor (iin1:6)
{
vn_angle<- seq(from=df_angles$Start[i], to=df_angles$End[i], length=100)
vn_rose<- abs( sin(vn_angle*6/2)*df_roses$Value[i] )
radial.plot( lengths=vn_rose,
radial.pos=vn_angle,
rp.type="p",
line.col="black",
poly.col=df_roses$Color[i],
add=TRUE
)
}
# draw the "no change" circlen_no_change_value<-0.6vn_angle<- seq(0, to=2*pi, length=100)
vn_circle<- rep(x=n_no_change_value, times=100)
radial.plot( lengths=vn_circle,
radial.pos=vn_angle,
radial.lim= c(0,1),
rp.type="p",
line.col="blue",
add=TRUE
)
# add "no change" text
text(x=0,
y=n_no_change_value+0.05, # you can adjust thislabels="No change",
col="blue")
A remark, perhaps useful. I got a request from a colleague of ISRIC to create in R a pedal chart, also called rose chart, like this (the data are fictional):
.
As I couldn't find a function or package, I wrote something myself. It will probably need adjustments (for example, I made it static: it can only show six leaves), but for inspiration, this is the code:
created by @LucSteinbuch
The text was updated successfully, but these errors were encountered: