Show Sidebar Hide Sidebar

Polar Charts in Pandas

How to graph polar charts in pandas. Seven examples of polar line, polar scatter and polar area charts.

# Learn about API authentication here: https://plot.ly/pandas/getting-started
# Find your api_key here: https://plot.ly/settings/api

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

N = 100.0
r = dict( r = [ np.random.poisson(N)*(np.cos((i/4)*np.pi/180)) for i in range(360) ] )
df = pd.DataFrame(r)
df_ma = pd.ewma(df,4.0)
df_ma.head()

data = []
data.append(
    go.Scatter(
        t=df.index,
        r=df['r'],
        name = 'Scatter',
        mode='markers',
        marker=dict(
            color='rgb(255,78,252)',
            size=8 )
    ) )
data.append(
    go.Scatter(
        t=df_ma.index,
        r=df_ma['r'],
        name = 'Moving average',
        mode='lines',
        line=dict(color='rgb(69,124,235)'),
        marker=dict(
            color='rgb(69,124,235)',
            line=Line(width=2,
            color='rgb(69,124,235)') ),
    ) )
layout = go.Layout(
    angularaxis=dict(
        tickcolor='#CCC',
        showline=False,
    ),
    orientation=270
)

fig = go.Figure(data=data, layout=layout)

# IPython notebook
# py.iplot(fig, filename='pandas-polar-chart')

url = py.plot(fig, filename='pandas-polar-chart')
How to make scatter plots in Pandas on the polar coordinate system.
Still need help?
Contact Us

For guaranteed 24 hour response turnarounds, upgrade to a Developer Support Plan.