Black Lives Matter. Please consider donating to Black Girls Code today.
Learn how to use COVID-19 data in open source Dash apps. Register for the Sept 23rd webinar with IQT!

Recreate a polar chart

I’m trying to create the following plot with either ggplotly() or plot_ly. In both situations, I can’t seem to get it to match the original very well.

Full Disclosure: Cross posted here

Here’s the original:

Here’s the data:

d <- structure(list(Year = c(“2015”, “2015”, “2015”, “2015”, “2015”,
“2015”, “2015”, “2015”, “2015”, “2015”, “2015”, “2015”, “2015”,
“2015”, “2015”, “2015”, “2015”, “2015”, “2015”, “2015”, “2015”,
“2015”, “2015”, “2015”, “2016”, “2016”, “2016”, “2016”, “2016”,
“2016”, “2016”, “2016”, “2016”, “2016”, “2016”, “2016”, “2016”,
“2016”, “2016”, “2016”, “2016”, “2016”, “2016”, “2016”, “2016”,
“2016”, “2016”, “2016”), Response = structure(c(1L, 2L, 3L, 4L,
5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L,
19L, 20L, 21L, 22L, 23L, 24L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L,
9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L,
22L, 23L, 24L), .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 = c(240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L,
240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L, 240L,
240L, 240L, 240L, 240L, 258L, 258L, 258L, 258L, 258L, 258L, 258L,
258L, 258L, 258L, 258L, 258L, 258L, 258L, 258L, 258L, 258L, 258L,
258L, 258L, 258L, 258L, 258L, 258L)), .Names = c(“Year”, “Response”,
“Proportion”, “n”), row.names = c(NA, -48L), class = c(“tbl_df”,
“tbl”, “data.frame”))

Here’s what I’ve tried:

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)

p <- ggplot(d, aes(y = Proportion, x = Response, group = factor(Year), colour = factor(Year))) + coord_polar() + geom_point() + geom_path() ggploty(p)

Nothing seems to work.

If this is simply not possible I’d like to know, otherwise, let’s see if you can do it!

A very nice answer for this was posted on stackoverflow:

Yes, there are two great answers. dww used an interesting approach by putting it on a map projection. My approach was to recreate a circle using basic trig SOHCAHTOA. Both worked out very well.

Here’s a link to my version if you’re interested:

https://plot.ly/~1beb/3/_2015-vs-2016/