Skip to content

Commit 39cbe15

Browse files
show off barpolar more (#129)
1 parent 9df3b81 commit 39cbe15

File tree

2 files changed

+18
-37
lines changed

2 files changed

+18
-37
lines changed

python/polar-chart.md

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -136,47 +136,28 @@ fig.update_layout(
136136
fig.show()
137137
```
138138

139-
#### Area Polar Chart
139+
#### Polar Bar Chart
140140

141141
a.k.a matplotlib logo in a few lines of code
142142

143143
```python
144144
import plotly.graph_objects as go
145145

146-
fig = go.Figure()
147-
148-
fig.add_trace(go.Scatterpolar(
149-
r = [0, 1.5, 1.5, 0, 2.5, 2.5, 0],
150-
theta = [0, 10, 25, 0, 205, 215, 0],
151-
fillcolor = '#709BFF',
152-
))
153-
fig.add_trace(go.Scatterpolar(
154-
r = [0, 3.5, 3.5, 0],
155-
theta = [0, 55, 75, 0],
156-
fillcolor = '#E4FF87',
157-
))
158-
fig.add_trace(go.Scatterpolar(
159-
r = [0, 4.5, 4.5, 0, 4.5, 4.5, 0],
160-
theta = [0, 100, 120, 0, 305, 320, 0],
161-
fillcolor = '#FFAA70',
162-
))
163-
fig.add_trace(go.Scatterpolar(
164-
r = [0, 4, 4, 0],
165-
theta = [0, 165, 195, 0],
166-
fillcolor = '#FFDF70',
167-
))
168-
fig.add_trace(go.Scatterpolar(
169-
r = [0, 3, 3, 0],
170-
theta = [0, 262.5, 277.5, 0],
171-
fillcolor = '#B6FFB4',
172-
))
146+
fig = go.Figure(go.Barpolar(
147+
r=[3.5, 1.5, 2.5, 4.5, 4.5, 4, 3],
148+
theta=[65, 15, 210, 110, 312.5, 180, 270],
149+
width=[20,15,10,20,15,30,15,],
150+
marker_color=["#E4FF87", '#709BFF', '#709BFF', '#FFAA70', '#FFAA70', '#FFDF70', '#B6FFB4'],
151+
marker_line_color="black",
152+
marker_line_width=2,
153+
))
173154

174-
fig.update_traces(mode='lines', fill='toself', line_color='black')
175155
fig.update_layout(
156+
template=None,
176157
polar = dict(
177-
radialaxis = dict(visible=True, range=[0, 5])
178-
),
179-
showlegend = False,
158+
radialaxis = dict(range=[0, 5], showticklabels=False, ticks=''),
159+
angularaxis = dict(showticklabels=False, ticks='')
160+
)
180161
)
181162

182163
fig.show()

python/wind-rose-charts.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jupyter:
2929
ipynb: ~notebook_demo/38
3030
language: python
3131
layout: user-guide
32-
name: Wind Rose Charts
32+
name: Wind Rose and Polar Bar Charts
3333
order: 8
3434
page_type: example_index
3535
permalink: python/wind-rose-charts/
@@ -40,12 +40,12 @@ jupyter:
4040

4141
### Wind Rose Chart with plotly express
4242

43-
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.
43+
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.
4444

4545
```python
4646
import plotly.express as px
4747
wind = px.data.wind()
48-
fig = px.bar_polar(wind, r="frequency", theta="direction",
48+
fig = px.bar_polar(wind, r="frequency", theta="direction",
4949
color="strength", template="plotly_dark",
5050
color_discrete_sequence= px.colors.sequential.Plasma[-2::-1])
5151
fig.show()
@@ -86,11 +86,11 @@ fig.update_layout(
8686
legend_font_size=16,
8787
polar_radialaxis_ticksuffix='%',
8888
polar_angularaxis_rotation=90,
89-
89+
9090
)
9191
fig.show()
9292
```
9393

9494
#### Reference
9595

96-
See https://plot.ly/python/reference/#barpolar for more information and chart attribute options!
96+
See https://plot.ly/python/reference/#barpolar for more information and chart attribute options!

0 commit comments

Comments
 (0)