How to make radar charts in Python with Plotly.
Plotly Studio: Transform any dataset into an interactive data application in minutes with AI. Sign up for early access now.
In [1]:
import plotly.express as px import pandas as pd df = pd.DataFrame(dict( r=[1, 5, 2, 2, 3], theta=['processing cost','mechanical properties','chemical stability', 'thermal stability', 'device integration'])) fig = px.line_polar(df, r='r', theta='theta', line_close=True) fig.show()
For a filled line in a Radar Chart, update the figure created with px.line_polar
with fig.update_traces
.
In [2]:
import plotly.express as px import pandas as pd df = pd.DataFrame(dict( r=[1, 5, 2, 2, 3], theta=['processing cost','mechanical properties','chemical stability', 'thermal stability', 'device integration'])) fig = px.line_polar(df, r='r', theta='theta', line_close=True) fig.update_traces(fill='toself') fig.show()Basic Radar Chart with go.Scatterpolar¶
In [3]:
import plotly.graph_objects as go fig = go.Figure(data=go.Scatterpolar( r=[1, 5, 2, 2, 3], theta=['processing cost','mechanical properties','chemical stability', 'thermal stability', 'device integration'], fill='toself' )) fig.update_layout( polar=dict( radialaxis=dict( visible=True ), ), showlegend=False ) fig.show()Multiple Trace Radar Chart¶
In [4]:
import plotly.graph_objects as go categories = ['processing cost','mechanical properties','chemical stability', 'thermal stability', 'device integration'] fig = go.Figure() fig.add_trace(go.Scatterpolar( r=[1, 5, 2, 2, 3], theta=categories, fill='toself', name='Product A' )) fig.add_trace(go.Scatterpolar( r=[4, 3, 2.5, 1, 2], theta=categories, fill='toself', name='Product B' )) fig.update_layout( polar=dict( radialaxis=dict( visible=True, range=[0, 5] )), showlegend=False ) fig.show()What About Dash?¶
Dash 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 at https://dash.plot.ly/installation.
Everywhere in this page that you see fig.show()
, you can display the same figure in a Dash application by passing it to the figure
argument of the Graph
component from the built-in dash_core_components
package like this:
import plotly.graph_objects as go # or plotly.express as px fig = go.Figure() # or any Plotly Express function e.g. px.bar(...) # fig.add_trace( ... ) # fig.update_layout( ... ) from dash import Dash, dcc, html app = Dash() app.layout = html.Div([ dcc.Graph(figure=fig) ]) app.run(debug=True, use_reloader=False) # Turn off reloader if inside Jupyter
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4