
import pandas as pd
my_dict={
'NAME':['Ravi','Raju','Alex','Ronn'],
'MATH':[30,40,50,50]
}
df = pd.DataFrame(data=my_dict)
df.plot.pie(title="Std Mark",y='MATH')

df.plot.pie(title="Std Mark",y='MATH',figsize=(4,4))
df.plot.pie(title="Std Mark",
y='MATH',fontsize=20)
We can define our labels by using list.
my_labels=['Ravi','Raju','Alex','Ronn']
df.plot.pie(title="Std Mark",y='MATH',
fontsize=20,labels=my_labels)
legend=False

my_explode=(0,0,0.1,0)
df.plot.pie(title="Std Mark",y='MATH',
fontsize=20,explode=my_explode)

my_explode=(1.5,0.0,0.1,0)
df.plot.pie(title="Std Mark",
y='MATH',explode=my_explode)

df.plot.pie(title="Std Mark",y='MATH',
fontsize=20,startangle=40)
df.plot.pie(title="shadow=False",y='MATH',
figsize=(5,5),shadow=False)
We can use the option colors to give different colors to segments. We can use one tuple to define the colours.
my_colors=['lightblue','lightgreen',
'silver','green']
df.plot.pie(title="Colors",y='MATH',
figsize=(5,5),colors=my_colors)
To display the percentage of each segment we can define the format. Here is one sample to show one decimal place autopct='%1.1f%%' , for two decimal places it can be autopct='%1.2f%%'
df.plot.pie(title="Colors",y='MATH',
autopct='%1.1f%%')
plot=df.plot.pie(title="Colors",y='MATH',autopct='%1.1f%%')
fig = plot.get_figure()
fig.savefig("D:\\my_data\\output2.png")
Pandas plot
Line plot
Bar plot
Box plot
Density plot
Area plot
Scatter Plot
Hexbin plot
Author
🎥 Join me live on YouTubePassionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.