0

I have tried changing the explode but still they have overlap on 'Shared room' and 'Hotel room' here is my code:

fig, ax = plt.subplots(figsize=(12, 8), subplot_kw=dict(aspect="equal"))
labels = available_rooms.room_type.tolist()
sizes = available_rooms['percent'].tolist()

explode = (0.1, 0, 0.1, 0.1)

wedges, texts, autotexts = ax.pie(sizes, autopct='%1.1f%%',explode=explode,
                                  textprops=dict(color="w"))

ax.legend(wedges, labels,
          title="RoomTypes",
          loc="center left",
          bbox_to_anchor=(1, 0, 0.5, 1))

plt.setp(autotexts, size=8, weight="bold")
ax.set_title("Type of rooms available in the Listing")
plt.show()

enter image description here

Sepid
  • 107
  • 1
  • 10
  • You could add this information to the legend. [Getting percentages in legend](https://stackoverflow.com/questions/44076203) or [Getting percentages in legend - bis](https://stackoverflow.com/questions/67496127) – JohanC Feb 16 '23 at 23:29
  • I recommend [this answer](https://stackoverflow.com/a/68779745/1186624) of the above question. – relent95 Feb 17 '23 at 01:29
  • Did you try augmenting figsize=(14,10) and augmenting the last two explode values? Also you can put the legend in the "lower left" corner so you have more space to explode. I can't replicate your error, I see the plot ok in my notebook. – Pedro Rocha Feb 17 '23 at 02:11
  • Thank you all for your help, I used this answer https://stackoverflow.com/questions/23577505/how-to-avoid-overlapping-of-labels-autopct-in-a-matplotlib-pie-chart – Sepid Feb 17 '23 at 18:08
  • @PedroRocha I also tried your answer and looks much better now! – Sepid Feb 17 '23 at 18:27

0 Answers0