I'm struggling to deal with my plot margins in matplotlib. I've used the code below to produce my chart:
plt.imshow(g)
c = plt.colorbar()
c.set_label("Number of Slabs")
plt.savefig("OutputToUse.png")
However, I get an output figure with lots of white space on either side of the plot. I've searched google and read the matplotlib documentation, but I can't seem to find how to reduce this.
Best Answer
One way to automatically do this is the
bbox_inches='tight'
kwarg toplt.savefig
.E.g.
Another way is to use
fig.tight_layout()