问题
Following this question I want to add the exploded effect to the pie chart. Consider the below code:
import pandas as pd
df = pd.DataFrame(["man", "woman", "man", "other",
"other", "man", "woman"], columns=["gender"])
df['gender'].value_counts(normalize=True).plot(
kind='pie', shadow=True, autopct='%1.1f%%')
which result in
Now I want to add the explode=explode
feature to the plot but I can't (e.g., here). The commands
df['gender'].value_counts(normalize=True).plot(
kind='pie', shadow=True, autopct='%1.1f%%', explode=explode)
and
ax = df['gender'].value_counts(normalize=True).plot(
kind='pie', shadow=True, autopct='%1.1f%%')
ax.pie(explode=explode)
results in
NameError: name 'explode' is not defined
来源:https://stackoverflow.com/questions/60234927/adding-explode-affect-to-a-pandas-pie-chart