python - matplotlib subplots equal aspect ratio -
i know question has been asked before (here, here, , most comprehensive one) none of solutions worked me.
my code:
from matplotlib import pyplot plt import numpy np fig, ax = plt.subplots(ncols=3) c1 = plt.cm.blues(np.linspace(0.3,0.9,4)) c2 = plt.cm.greens(np.linspace(0.3,0.9,4)) c3 = plt.cm.reds(np.linspace(0.3,0.9,4)) marker = 4*('<',) + 4*('o',) + 4*('s',) line = 4*(':',) + 4*('--',) + 4*('-',) colors = np.vstack((c1,c2,c3)) val in range(11): if val < 4: c = 0 elif (val >=4) & (val>7): c = 1 else: c = 2 x = np.array([1,2,3,4,5]) y = x + x*val ax[c].plot(x,y,\ color=colors[val], marker = marker[val],\ linewidth=1,alpha=0.8) ax[c].set_xlim(0,10) ax[c].set_ylim(0,20) plt.setp(ax[c], aspect='equal', adjustable='box-forced') tick in ax[c].xaxis.get_major_ticks(): tick.label.set_rotation(45) generates:

how can set:
1) equal aspect ratio
and if desired
2) force figure remain original width (by adjusting height of axis)
i have mention figure size set in stylesheet.
Comments
Post a Comment