Radar charts in Python - Plotly
文章推薦指數: 80 %
A Radar Chart (also known as a spider plot or star plot) displays multivariate data in the form of a two-dimensional chart of quantitative variables represented ... Forum Pricing Dash QuickReference GettingStarted IsPlotlyFree? FigureReference APIReference Dash GitHub community.plotly.com OnThisPage ARadarChart(alsoknownasaspiderplotorstarplot)displaysmultivariatedataintheformofatwo-dimensionalchartofquantitativevariablesrepresentedonaxesoriginatingfromthecenter.Therelativepositionandangleoftheaxesistypicallyuninformative.Itisequivalenttoaparallelcoordinatesplotwiththeaxesarrangedradially. ForaRadarChart,useapolarchartwithcategoricalangularvariables,withpx.line_polar,orwithgo.Scatterpolar.Seemoreexamplesofpolarcharts. RadarChartwithPlotlyExpress¶PlotlyExpressistheeasy-to-use,high-levelinterfacetoPlotly,whichoperatesonavarietyoftypesofdataandproduceseasy-to-stylefigures. Useline_close=Trueforclosedlines. In [1]: importplotly.expressaspx importpandasaspd df=pd.DataFrame(dict( r=[1,5,2,2,3], theta=['processingcost','mechanicalproperties','chemicalstability', 'thermalstability','deviceintegration'])) fig=px.line_polar(df,r='r',theta='theta',line_close=True) fig.show() ForafilledlineinaRadarChart,updatethefigurecreatedwithpx.line_polarwithfig.update_traces. In [2]: importplotly.expressaspx importpandasaspd df=pd.DataFrame(dict( r=[1,5,2,2,3], theta=['processingcost','mechanicalproperties','chemicalstability', 'thermalstability','deviceintegration'])) fig=px.line_polar(df,r='r',theta='theta',line_close=True) fig.update_traces(fill='toself') fig.show() BasicRadarChartwithgo.Scatterpolar¶ In [3]: importplotly.graph_objectsasgo fig=go.Figure(data=go.Scatterpolar( r=[1,5,2,2,3], theta=['processingcost','mechanicalproperties','chemicalstability','thermalstability', 'deviceintegration'], fill='toself' )) fig.update_layout( polar=dict( radialaxis=dict( visible=True ), ), showlegend=False ) fig.show() MultipleTraceRadarChart¶ In [4]: importplotly.graph_objectsasgo categories=['processingcost','mechanicalproperties','chemicalstability', 'thermalstability','deviceintegration'] fig=go.Figure() fig.add_trace(go.Scatterpolar( r=[1,5,2,2,3], theta=categories, fill='toself', name='ProductA' )) fig.add_trace(go.Scatterpolar( r=[4,3,2.5,1,2], theta=categories, fill='toself', name='ProductB' )) fig.update_layout( polar=dict( radialaxis=dict( visible=True, range=[0,5] )), showlegend=False ) fig.show() Reference¶Seefunctionreferenceforpx.(line_polar)orhttps://plotly.com/python/reference/scatterpolar/formoreinformationandchartattributeoptions! WhatAboutDash?¶Dashisanopen-sourceframeworkforbuildinganalyticalapplications,withnoJavascriptrequired,anditistightlyintegratedwiththePlotlygraphinglibrary. LearnabouthowtoinstallDashathttps://dash.plot.ly/installation. Everywhereinthispagethatyouseefig.show(),youcandisplaythesamefigureinaDashapplicationbypassingittothefigureargumentoftheGraphcomponentfromthebuilt-indash_core_componentspackagelikethis: importplotly.graph_objectsasgo#orplotly.expressaspx fig=go.Figure()#oranyPlotlyExpressfunctione.g.px.bar(...) #fig.add_trace(...) #fig.update_layout(...) importdash importdash_core_componentsasdcc importdash_html_componentsashtml app=dash.Dash() app.layout=html.Div([ dcc.Graph(figure=fig) ]) app.run_server(debug=True,use_reloader=False)#TurnoffreloaderifinsideJupyter ×
延伸文章資訊
- 1The Radar chart and its caveats - From data to Viz
A radar or spider or web chart is a two-dimensional chart type designed to plot one or more serie...
- 2Radar Chart - amCharts
setThemes([ am5themes_Animated.new(root) ]); // Create chart // https://www.amcharts.com/docs/v5/...
- 3Radar chart - Wikipedia
A radar chart is a graphical method of displaying multivariate data in the form of a two-dimensio...
- 4Radar Chart | Chart.js
A radar chart is a way of showing multiple data points and the variation between them. They are o...
- 5Radar Charts - Learn about this chart and tools to create it
Radar Charts are a way of comparing multiple quantitative variables. This makes them useful for s...