0
import matplotlib.pyplot as plt

months = ['January', 'February', 'March']
months_sizes = [16.13, 26.64, 57.23]
weekdays = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun','Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun','Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
weekdays_sizes = [1.79, 2.23, 2.67, 3.26, 2.78, 1.50, 1.91, 2.21, 1.94, 1.98, 1.37, 2.58, 6.72, 9.83, 5.95, 6.69, 7.52, 5.42, 5.27, 7.28, 19.11]
months_colors = ['#081a28', '#2e1d0b', '#15210f']
weekdays_colors = ['#2986cc', '#2478b7', '#206ba3', '#1c5d8e', '#18507a', '#144366', '#103551',
                   '#e69138', '#cf8232', '#b8742c', '#a16527', '#8a5721', '#73481c', '#5c3a16',
                   '#6aa84f', '#5f9747', '#54863f', '#4a7537', '#3f642f', '#355427', '#2a431f']
outer_circle = plt.pie(months_sizes, labels=months, colors=months_colors, startangle=90, frame=True)
inner_circle = plt.pie(weekdays_sizes, labels=weekdays, colors=weekdays_colors, radius=0.7, startangle=90, labeldistance=0.7)
centre_circle = plt.Circle((0, 0), 0.35, color='white', linewidth=0)

fig = plt.gcf()
fig.gca().add_artist(centre_circle)
plt.plot(figsize=(19,8))
plt.show()

This is my code so far. It does what I want but I need it to be bigger. However I havent been able to do that, not with figsize nor with radius=. How can I achieve what I want with the code I already have?

[The pie chart I am getting]

1

eshirvana
  • 23,227
  • 3
  • 22
  • 38

2 Answers2

1
plt.figure(figsize = (24, 24))
outer_circle = plt.pie(months_sizes, labels=months, colors=months_colors, startangle=90, frame=True)
# ... the rest of the code ...

figsize works for me

Z Li
  • 4,133
  • 1
  • 4
  • 19
1

Create the figure with a larger size before plotting:

# your plot setup
import matplotlib.pyplot as plt

months = ['January', 'February', 'March']
months_sizes = [16.13, 26.64, 57.23]
weekdays = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun','Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun','Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
weekdays_sizes = [1.79, 2.23, 2.67, 3.26, 2.78, 1.50, 1.91, 2.21, 1.94, 1.98, 1.37, 2.58, 6.72, 9.83, 5.95, 6.69, 7.52, 5.42, 5.27, 7.28, 19.11]
months_colors = ['#081a28', '#2e1d0b', '#15210f']
weekdays_colors = ['#2986cc', '#2478b7', '#206ba3', '#1c5d8e', '#18507a', '#144366', '#103551',
                   '#e69138', '#cf8232', '#b8742c', '#a16527', '#8a5721', '#73481c', '#5c3a16',
                   '#6aa84f', '#5f9747', '#54863f', '#4a7537', '#3f642f', '#355427', '#2a431f']

# create figure
fig, ax = plt.subplots(figsize=(19, 8))

# plot using ax
outer_circle = ax.pie(months_sizes, labels=months, colors=months_colors, startangle=90, frame=True)
inner_circle = ax.pie(weekdays_sizes, labels=weekdays, colors=weekdays_colors, radius=0.7, startangle=90, labeldistance=0.7)
centre_circle = plt.Circle((0, 0), 0.35, color='white', linewidth=0)
ax.add_artist(centre_circle)

plt.show()
Michael Delgado
  • 13,789
  • 3
  • 29
  • 54