Skip to content

Windrose example from plot.ly not working #1131

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

Closed
rr5577 opened this issue Aug 23, 2018 · 5 comments
Closed

Windrose example from plot.ly not working #1131

rr5577 opened this issue Aug 23, 2018 · 5 comments
Milestone

Comments

@rr5577
Copy link

rr5577 commented Aug 23, 2018

I just did a fresh install to try plotly.py and wanted to try the pandas windrose example from the plotly site ( https://plot.ly/pandas/wind-rose-charts/ ).

import pandas as pd
import colorlover as cl
import numpy as np
import plotly.plotly as py
import plotly.graph_objs as go


df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/wind_rose.csv')
df.head()

data = []
counter = 0
for col in df.columns:
    if col != 'r':
        data.append(
            go.Area(t=df['r'],
                    r=df[col],
                    marker=dict(color=cl.scales['9']['seq']['PuBu'][counter]),
                    name=col+' m/s' ) )
        counter+=1
layout = go.Layout(
    title='test wr',
    font=dict(
        size=16
    ),
    
    radialaxis=dict(
        ticksuffix='%'
    ),
    orientation=270,
    barmode="stack"
    
)
fig = go.FigureWidget(data=data, layout=layout)
fig

but i only get a blank output cell.

if i remove the barmode="stack" kwarg, the plot renders, but without data:
image

Plotly Version: 3.1.1
image

Update:
i managed to get the plot and data to display, it seems using the pandas columns for "r" and "t" values doesn´t work (as in #1116).

However, dynamically updating the plot (e.g. changing title color) doesn´t work.
image

@jonmmease
Copy link
Contributor

Hi @rr5577 , thanks for taking the time to report this.

Yeah, it looks like the Plotly.js JavaScript library is choking when plotly.py is passed a pandas series or numpy array. And I can also reproduce you're issue of not being able to update the title properties.

These issues should be addressed when this trace type is replaced with a new trace that uses the Polar 2.0 infrastructure. See plotly/plotly.js#2810 for some discussion.

I'll leave this issue open until the new trace is released and included with plotly.py.

@jonmmease jonmmease added bug something broken plotly.js labels Aug 24, 2018
@jonmmease jonmmease added this to the v3.3.0 milestone Sep 23, 2018
@jonmmease
Copy link
Contributor

plotly.py 3.3 is going to include plotly.js 1.41 which includes the new barpolar trace type (plotly/plotly.js#2954). This is the much more capable successor to the polar area traces used in this example.

@jonmmease jonmmease added enhancement and removed bug something broken labels Sep 23, 2018
@rr5577
Copy link
Author

rr5577 commented Sep 23, 2018

Thanks for the update, looking forward to trying it!

@jonmmease
Copy link
Contributor

barpolar trace included in upgrade to plotly.js 1.41.3 in #1202, will be released in plotly.py 3.3.0 soon.

import plotly.graph_objs as go
fig = go.FigureWidget()
fig.add_barpolar(r=[1, 3, 2], theta=[0, 45, 90])
fig.add_barpolar(r=[3, 5, 1], theta=[0, 45, 90])
fig.add_barpolar(r=[2, 1, 6], theta=[0, 45, 90])
fig

newplot 4

See plotly/documentation#1100 for progress on updating the windrose documentation to use barpolar. Thanks for reporting!

@rr5577
Copy link
Author

rr5577 commented Oct 19, 2018

This works great now (dynamically updating the plot as well). Only the code from the python example specifying the (layout) axis seems to be obsolete (it doesn´t do anything when changed).
After changing that it worked:

layout = go.Layout(
    title='test wd',
    font=dict(size=16), 
    polar=dict(
        radialaxis=dict(ticksuffix="%",angle=45,tickfont=dict(size=12)),
        angularaxis=dict(direction="clockwise",tickfont=dict(size=14)),
    ),

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants