Polar Charts [legacy] in R
How to create a polar chart in R. Three examples of polar line, polar scatter, and polar area chart.
Plotly Studio: Transform any dataset into an interactive data application in minutes with AI. Try Plotly Studio now.
Legacy Plots
These polar charts are legacy and will likely be deprecated in Plotly 2.0. Please see the new scatterpolar
and scatterpolargl
trace types for latest and greatest in Plotly polar coordinates.
Polar Scatter Chart
library(plotly)
fig <- plot_ly(
plotly::mic, r = ~r, t = ~t, color = ~nms, alpha = 0.5, type = "scatter"
)
fig <- layout(fig, title = "Mic Patterns", orientation = -90)
fig
fig <- plot_ly(
plotly::hobbs, r = ~r, t = ~t, color = ~nms, alpha = 0.5, type = "scatter"
)
fig <- layout(fig, title = "Hobbs-Pearson Trials", plot_bgcolor = toRGB("grey90"))
fig
Polar Area Chart
```{r}
fig <- plotly(plotly::wind, r = ~r, t = ~t) %>% addarea(color = ~nms)
fig <- layout(fig, radialaxis = list(ticksuffix = "%"), orientation = 270)
fig
```
Reference
See https://plotly.com/python/reference/#area for more information and chart attribute options!
What About Dash?
Dash for R is an open-source framework for building analytical applications, with no Javascript required, and it is tightly integrated with the Plotly graphing library.
Learn about how to install Dash for R at https://dashr.plot.ly/installation.
Everywhere in this page that you see fig
, you can display the same figure in a Dash for R application by passing it to the figure
argument of the Graph
component from the built-in dashCoreComponents
package like this:
library(plotly)
fig <- plot_ly()
# fig <- fig %>% add_trace( ... )
# fig <- fig %>% layout( ... )
library(dash)
library(dashCoreComponents)
library(dashHtmlComponents)
app <- Dash$new()
app$layout(
htmlDiv(
list(
dccGraph(figure=fig)
)
)
)
app$run_server(debug=TRUE, dev_tools_hot_reload=FALSE)