I'm generating a pie chart and receiving additional space around it in the save figure, especially on the left side. You can see the attached figure.
Here is the code:
fig, ax = plt.subplots()
ax.axis("equal")
explode = tuple(np.ones(len(class_map)) * 0.05)
#target_count = float(target_count)
t_c = np.array(target_count)
porcent = 100.*t_c/t_c.sum()
labels = ['{0} - {1:1.2f} %'.format(i,j) for i,j in zip(class_map, porcent)]
patches, texts = ax.pie(
target_count,
explode=explode,
pctdistance=1.1,
labeldistance=0.6,
shadow=False,
radius = 0.3,
startangle=0,
colors=color_map,
wedgeprops={"linewidth": 1, "edgecolor": "k"},
)
box = ax.get_position()
ax.set_position([box.x0, box.y0, box.width, box.height])
plt.title("Goone", fontdict = {'fontsize' : 25})
plt.legend(patches, labels, loc="center left", bbox_to_anchor=(0.70, 0.5))
plt.tight_layout()
# plt.show()
save_name = os.path.join(path_save, prefix + ".png")
fig.savefig(save_name, bbox_inches="tight")
plt.close()
Note: I tried every possible option available on the internet but could not remove the white spaces.
