I am drawing charts with matplotlib. When i am drawing it at the same chart with this code:
def draw0(x, ys, labels):
plt.suptitle("big title")
i =0
for y in ys:
plt.plot(x, y, label=labels[i])
plt.scatter(x, y) # dots
plt.xticks(range(1, max(x) + 1))
plt.grid(True)
i+=1
plt.figlegend(loc="upper left")
plt.show()
return
x = [1,2,3,4,5]
y1 = [1,3,5,7,9]
y2 = [10,30,50,70,90]
y3 = [0.1,0.3,0.5,0.7,0.9]
draw0(x, [y1, y2, y3], ["chart1", "chart2", "chart3"])
everything works fine. charts in one window But i need each chart to be at the separate subplot.
I am trying to do it like this:
def draw11(x, ys, labels):
plt.figure()
plt.suptitle("big title")
i =0
for y in ys:
if i == 0:
ax = plt.subplot(len(ys),1, i+1)
else:
plt.subplot(len(ys), 1, i + 1, sharex=ax)
plt.plot(x, y, label=labels[i])
plt.scatter(x, y) # dots
plt.xticks(range(1, max(x) + 1))
plt.grid(True)
i+=1
plt.figlegend(loc="upper left")
plt.show()
return
I am getting this.
Issue is that all charts have the same color. And legend is useless. How i can add automatic color management for all sublots? I'd like to have not the same colors there. Like subplot1.chart1 = color1, subplo1.chart2 = color2, sublot2.chart1 = color3, not color1.
