Skip to content

show off barpolar more #129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 13 additions & 32 deletions python/polar-chart.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
10 changes: 5 additions & 5 deletions python/wind-rose-charts.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand All @@ -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()
Expand Down Expand Up @@ -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!
See https://plot.ly/python/reference/#barpolar for more information and chart attribute options!