xxxxxxxxxx
import matplotlib.pyplot as plt
# Pie chart data
sizes = [30, 40, 20, 10] # Example values, can be customized
labels = ['A', 'B', 'C', 'D'] # Example labels, can be customized
# Plotting the pie chart
plt.pie(sizes, labels=labels, autopct='%1.1f%%', startangle=90)
# Equal aspect ratio ensures that pie is drawn as a circle
plt.axis('equal')
# Display the chart
plt.show()
xxxxxxxxxx
import matplotlib.pyplot as plt
labels = ['Python', 'C++', 'Ruby', 'Java']
sizes = [215, 130, 245, 210]
# Plot
plt.pie(sizes, labels=labels,
autopct='%1.1f%%', shadow=True, startangle=140)
plt.axis('equal')
plt.show()
xxxxxxxxxx
import matplotlib.pyplot as plt
import seaborn as sns
#define data
data = [value1, value2, value3, ]
labels = ['label1', 'label2', 'label3', ]
#define Seaborn color palette to use
colors = sns.color_palette('pastel')[0:5]
#create pie chart
plt.pie(data, labels = labels, colors = colors, autopct='%.0f%%')
plt.show()
xxxxxxxxxx
# Method 1
df["col"].plot(kind="pie")
# Method 2
data = np.array([40, 30, 20, 10])
mylabels = ["A", "B", "C", "D"]
plt.pie(data, labels = mylabels)