I know this question has been asked before (here, here, and the most comprehensive one) but none of the solutions worked for me.
My code:
from matplotlib import pyplot as plt
import numpy as 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))
for 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')
for tick in ax[c].xaxis.get_major_ticks():
tick.label.set_rotation(45)
generates:
How can I set:
1) An equal aspect ratio
and if desired
2) Force the figure to remain its original width (by adjusting the height of the axis)
I have to mention that my figure size is set in a stylesheet.