I am trying to get subplots of 5 rows and two columns working in matplotlib.
The variable X indicates a dictionary. [*X]
is giving keys available in the dictionary.
Each key should be present in a different row.
idx = 0
axes = []
for key, val in X.items():
axes.append(plt.subplot(len([*X]),1,idx+1))
axes[idx].scatter(X[key], Y[key], color='r')
axes[idx].set_title(key)
axes[idx].set_xlabel(title)
axes[idx].set_ylabel('QoS')#, color='g')
axes[idx].spines['right'].set_visible(False)
axes[idx].spines['top'].set_visible(False)
axes[idx].xaxis.set_ticks_position('bottom')
axes[idx].yaxis.set_ticks_position('left')
axes[idx].set_ylim([0,1])
axes.append(plt.subplot(len([*X]),2,idx+1))
tmp = idx+1
axes[tmp].scatter(X[key], Y1[key], color='r')
axes[tmp].set_title(key)
axes[tmp].set_xlabel(title)
axes[tmp].set_ylabel('Power', color='g')
axes[tmp].spines['right'].set_visible(False)
axes[tmp].spines['top'].set_visible(False)
axes[tmp].xaxis.set_ticks_position('bottom')
axes[tmp].yaxis.set_ticks_position('left')
#axes[idx].set_ylim([0,1])
idx+=1
Intuitively, I thought it should be this way, assuming len([*X])
is 5.
511, 521
512, 522
513, 523
513, 523
514, 525
With the current setup, I get it this way.
What am I missing?