python - Matplotlib adjust figure margin -
the following code gives me plot significant margins above , below figure. don't know how eliminate noticeable margins. subplots_adjust not work expected.
import matplotlib.pyplot plt import numpy np fig = plt.figure() ax = fig.add_subplot(111) ax.plot(range(10),range(10)) ax.set_aspect('equal') plt.tight_layout() tight_layout eliminates of margin, not of margins.
what wanted setting aspect ratio customized value , eliminating white space @ same time.
update: pierre h. puts it, key change size of figure container. question is: suggest way accommodate size of figure size of axes arbitrary aspect ratio?
in other words, first create figure , axes on it, , change size of axes (by changing aspect ratio example), in general leave portion of figure container empty. @ stage, need change size of figure accordingly eliminate blank space on figure container.
i discovered how eliminate margins figures. didn't use tight_layout(), instead used:
import matplotlib.pyplot plt fig = plt.figure(figsize=(20,20)) ax = plt.subplot(111,aspect = 'equal') plt.subplots_adjust(left=0, bottom=0, right=1, top=1, wspace=0, hspace=0) hope helps.
Comments
Post a Comment