diff --git a/python/polar-chart.md b/python/polar-chart.md index 4df95d166..077fb6ea7 100644 --- a/python/polar-chart.md +++ b/python/polar-chart.md @@ -136,47 +136,28 @@ fig.update_layout( fig.show() ``` -#### Area Polar Chart +#### Polar Bar Chart a.k.a matplotlib logo in a few lines of code ```python import plotly.graph_objects as go -fig = go.Figure() - -fig.add_trace(go.Scatterpolar( - r = [0, 1.5, 1.5, 0, 2.5, 2.5, 0], - theta = [0, 10, 25, 0, 205, 215, 0], - fillcolor = '#709BFF', - )) -fig.add_trace(go.Scatterpolar( - r = [0, 3.5, 3.5, 0], - theta = [0, 55, 75, 0], - fillcolor = '#E4FF87', - )) -fig.add_trace(go.Scatterpolar( - r = [0, 4.5, 4.5, 0, 4.5, 4.5, 0], - theta = [0, 100, 120, 0, 305, 320, 0], - fillcolor = '#FFAA70', - )) -fig.add_trace(go.Scatterpolar( - r = [0, 4, 4, 0], - theta = [0, 165, 195, 0], - fillcolor = '#FFDF70', - )) -fig.add_trace(go.Scatterpolar( - r = [0, 3, 3, 0], - theta = [0, 262.5, 277.5, 0], - fillcolor = '#B6FFB4', - )) +fig = go.Figure(go.Barpolar( + r=[3.5, 1.5, 2.5, 4.5, 4.5, 4, 3], + theta=[65, 15, 210, 110, 312.5, 180, 270], + width=[20,15,10,20,15,30,15,], + marker_color=["#E4FF87", '#709BFF', '#709BFF', '#FFAA70', '#FFAA70', '#FFDF70', '#B6FFB4'], + marker_line_color="black", + marker_line_width=2, +)) -fig.update_traces(mode='lines', fill='toself', line_color='black') fig.update_layout( + template=None, polar = dict( - radialaxis = dict(visible=True, range=[0, 5]) - ), - showlegend = False, + radialaxis = dict(range=[0, 5], showticklabels=False, ticks=''), + angularaxis = dict(showticklabels=False, ticks='') + ) ) fig.show() diff --git a/python/wind-rose-charts.md b/python/wind-rose-charts.md index ca2f0b765..6edf7c320 100644 --- a/python/wind-rose-charts.md +++ b/python/wind-rose-charts.md @@ -29,7 +29,7 @@ jupyter: ipynb: ~notebook_demo/38 language: python layout: user-guide - name: Wind Rose Charts + name: Wind Rose and Polar Bar Charts order: 8 page_type: example_index permalink: python/wind-rose-charts/ @@ -40,12 +40,12 @@ jupyter: ### Wind Rose Chart with plotly express -A [wind rose chart](https://en.wikipedia.org/wiki/Wind_rose) is a graphical tool used to visualize how wind speed and direction are typically distributed at a given location. For data stored in a tidy pandas dataframe, use the `px.bar_polar` function from plotly express as below, otherwise use `go.Barpolar` as explained in the next section. +A [wind rose chart](https://en.wikipedia.org/wiki/Wind_rose) (also known as a polar bar chart) is a graphical tool used to visualize how wind speed and direction are typically distributed at a given location. For data stored in a tidy pandas dataframe, use the `px.bar_polar` function from plotly express as below, otherwise use `go.Barpolar` as explained in the next section. ```python import plotly.express as px wind = px.data.wind() -fig = px.bar_polar(wind, r="frequency", theta="direction", +fig = px.bar_polar(wind, r="frequency", theta="direction", color="strength", template="plotly_dark", color_discrete_sequence= px.colors.sequential.Plasma[-2::-1]) fig.show() @@ -86,11 +86,11 @@ fig.update_layout( legend_font_size=16, polar_radialaxis_ticksuffix='%', polar_angularaxis_rotation=90, - + ) fig.show() ``` #### Reference -See https://plot.ly/python/reference/#barpolar for more information and chart attribute options! \ No newline at end of file +See https://plot.ly/python/reference/#barpolar for more information and chart attribute options!