Change axis of plotly polar plot

2019-07-27 16:56发布

问题:

I am playing with Plotly tools using python and I have made a polar plot as seen below using some dummy data:

I would like to alter the axis so that the data I have (goes from around 20 to 50) is mapped to the entire 360° of the plot. Is there a way of doing this using a readymade command or do I need to write a function where you set the limits then map those numbers to degrees before changing axis labels. I have been looking through stack exchange but I can only find ways of changing it to radians.

import plotly.plotly as py
import plotly.graph_objs as go
import plotly.tools as tls
import pandas as pd
import numpy as np

df = pd.read_csv('ExampleOutput.csv')

trace1 = go.Scatter(
    r=df['TimeStamp'],
    t=df['AirTemperature'],
    mode='markers',
    name='Trial 1',
    marker=dict(
        color='rgb(27,158,119)',
        size=110,
        line=dict(
            color='white'
        ),
        opacity=0.7
    )
)




data = [trace1]
layout = go.Layout(
    title='Hobbs-Pearson Trials',
    font=dict(
        size=15
    ),
    plot_bgcolor='rgb(223, 223, 223)',
    angularaxis=dict(
        tickcolor='rgb(253,253,253)'
    )
)
fig = go.Figure(data=data, layout=layout)
plot_url = py.plot(fig, filename='polar-scatter')

回答1:

You can use the range attribute of angular axis to specify the range of your data. For your current example:

angularaxis=dict(
    tickcolor='rgb(253,253,253)',
    range=[20,50]
    )

Bonus Panel: range argument works for radialaxis as well. ;)