Show Sidebar Hide Sidebar

Pie Charts in Pandas

How to make interactive Pie charts in Cufflinks with Plotly. Two examples of Pie charts with Pandas and Cufflinks.

Pie Charts in Cufflinks

In [1]:
import cufflinks as cf
import pandas as pd


datagen can now generate a DataFrame with the structured required for a pie charts

In [2]:
labels values
0 ZDS.FY 70
1 RPF.JV 20
2 ACC.UM 17
3 NCY.LC 76
4 EIK.JE 99

iplot now accepts the paramter kind=pie to generate a pie chart

labels indicates the column that contains the category labels, and values indicates the column that contain the values to be charted

In [3]:

Extra parameters can also be passed

  • sort: If True it sorts the labels by value
  • pull: Pulls the slices from the centre
  • hole: Sets the size of the inner hole
  • textposition: Sets the position of the legends for each slice ('outside'|'inside')
  • textinfo: Sets the information to be displayed on the legends
In [4]:
Still need help?
Contact Us

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