Ich möchte ein Diagramm erstellen, das sowohl auf der linken als auch auf der rechten Seite mehrere y-Achsen hat.Mehrere Y-Achsen auf beiden Seiten erstellen
Der folgende Code erzeugt ein Diagramm mit mehreren Y-Achsen auf der rechten Seite. Ich habe versucht, die rspline Einstellung auf "links" zu ändern, aber es funktioniert nicht.
Wie füge ich y4 auf der linken Seite hinzu?
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from matplotlib import rcParams
%matplotlib inline
x = np.random.rand(20)
y1 = x*5
y2 = x*5 + 0.2
y3 = x*x*3.5 + 0.2*x
y4 = x*5 + 0.2*x
yLimMin = 0
yLimMax = 2.1
lineWidth = 1.0
fontSize = 24
subTitle = ""
plt.rcParams.update({'axes.labelsize': 'small'})
fig = plt.figure(figsize=(21,29.7))
ax11 = fig.add_subplot(411)
subplotAdjustRight = 0.90
mks = 19 # marker step
ax11.plot(x,y1, linestyle='-', linewidth=lineWidth, color = 'k',
marker='*', markevery=11*mks,
label="CO")
ax11.set_ylabel('CO [%]', color='k')
plt.ylim((0,5))
fig.suptitle(subTitle, fontsize = fontSize)
ax11.yaxis.grid()
plt.locator_params(axis='y', nbins=10)
ax12=ax11.twinx()
ax12.plot(x,y2,linestyle='-', linewidth=lineWidth, color='r',
marker='*', markevery=11*mks,
label="CO22")
ax12.set_ylabel('NO [%]', color='r')
plt.ylim((0,10))
plt.locator_params(axis='y', nbins=10)
ax13= ax11.twinx()
rspine = ax13.spines['right']
rspine.set_position(('axes', 1.05))
ax13.set_frame_on(True)
ax13.plot(x,y3,linestyle='-', linewidth=lineWidth, color='m',
marker='*', markevery=11*mks,
label="CO222")
ax13.set_ylabel('O [%] ', color='m')
plt.ylim((0,20))
plt.locator_params(axis='y', nbins=10)
Es funktioniert perfekt! – Silvia