I'm having a bit of difficulty figuring out how to recreate the following graphic of a spider (or radar) chart, using plotly. Actually, I can't even recreate it in the most recent versions of ggplot2 because there have been breaking changes since 1.0.1.
Here's an example graphic:
Here's the original function that built it:
http://pcwww.liv.ac.uk/~william/Geodemographic%20Classifiability/func%20CreateRadialPlot.r
Here's an example of how the original function worked:
http://rstudio-pubs-static.s3.amazonaws.com/5795_e6e6411731bb4f1b9cc7eb49499c2082.html
Here's some not so dummy data:
d <- structure(list(Year = rep(c("2015","2016"),each=24),
Response = structure(rep(1L:24L,2),
.Label = c("Trustworthy", "Supportive", "Leading",
"Strong", "Dependable", "Consultative",
"Knowledgeable", "Sensible",
"Intelligent", "Consistent", "Stable",
"Innovative", "Aggressive",
"Conservative", "Visionary",
"Arrogant", "Professional",
"Responsive", "Confident", "Accessible",
"Timely", "Focused", "Niche", "None"),
class = "factor"),
Proportion = c(0.54, 0.48, 0.33, 0.35, 0.47, 0.3, 0.43, 0.29, 0.36,
0.38, 0.45, 0.32, 0.27, 0.22, 0.26,0.95, 0.57, 0.42,
0.38, 0.5, 0.31, 0.31, 0.12, 0.88, 0.55, 0.55, 0.31,
0.4, 0.5, 0.34, 0.53, 0.3, 0.41, 0.41, 0.46, 0.34,
0.22, 0.17, 0.28, 0.94, 0.62, 0.46, 0.41, 0.53, 0.34,
0.36, 0.1, 0.84), n = rep(c(240L,258L),each=24)),
.Names = c("Year", "Response", "Proportion", "n"),
row.names = c(NA, -48L), class = c("tbl_df", "tbl", "data.frame"))
Here's my attempt (not very good)
plot_ly(d, r = Proportion, t = Response, x = Response,
color = factor(Year), mode = "markers") %>%
layout(margin = list(l=50,r=0,b=0,t=0,pad = 4), showlegend = TRUE)
Any thoughts on how I might be able to recreate this using plotly?
ggplot2
version broke your existing code. Or, to put it the other way around, why are you asking for aplotly
solution and not for a fix of your existingggplot2
code? – Uweggplot2
plots intoplotly
usingggplotly(yourplot)
plot.ly/ggplot2/getting-started . However, I couldn't make it work with this sort of plot. Here is a staticggplot2
plot of your dataggplot(d, aes(y = Proportion, x = Response, group = factor(Year), colour = factor(Year))) + coord_polar() + geom_point() + geom_path()
– rafa.pereira