Last curve plotted is NOT on top of all others

I am plotting up to 12 curves and plot one them last to have it on top of all others to emphasize visibility. 8 of the curves go on the left-Y axis, the other 4 on the right-Y axis. All works, except:

When only the left curves are plotted, the last does go on top. Likewise, when only right curves are plotted.

However, when both left and right curves are plotted, then the right curves cover all left curves, even if one of them is plotted last, and thus it is NOT visible on top!

I believe this had worked before. Is there anything I am missing?

I am using matplotlib 3.83 with backend Qt5Agg on Linux Mint 21.2

As an example, this ghosty line in the middle is plotted in bright-red and after the black curve is plotted, yet it is barely visible because it is covered by the black scatter.

It’s really hard to say anything without some sample code.

This is some reduced code:

def plotLine(x, y, vname="CPM", **plotstyle):
    # select Y-axis
    vc = ("CPM", "CPS", "CPM1st", "CPS1st", "CPM2nd", "CPS2nd", "CPM3rd", "CPS3rd")
    if vname in vc: yaxis  = ax1  # all CP*                  on left Y-axis
    else:           yaxis  = ax2  # Temp, Press, Humid, Xtra on right y-axis
    line,  = yaxis.plot      (x, y, **plotstyle)



tdata   = {}        # dict of numpy arrays
logdata = {}        # dict of numpy arrays

vnames = ("CPM", "CPS", "CPM1st", "CPS1st", "CPM2nd", "CPS2nd", "CPM3rd", "CPS3rd", "Temp", "Press", "Humid", "Xtra")

# note that "CPM3rd" is positioned last!
vnames_ordered = ("CPM", "CPS", "CPM1st", "CPS1st", "CPM2nd", "CPS2nd", "CPS3rd", "Temp", "Press", "Humid", "Xtra", "CPM3rd")

plotstyle = {'color': "blue", 'linestyle': 'solid', 'linewidth': 1}

varPlotStyle = {}
for vname in vnames:
    varPlotStyle[vname] = plotstyle.copy()

for vname in vnames_ordered:
    x = tdata(vname)
    y = logdata(vname)
    plotLine(x, y, vname, **varPlotStyle[vname])

The problem is that CPM3rd is plotted as the last line, yet its trace is covered by black curve Press plotted earlier.

Each Axes is drawn in order so everything in the first Axes is drawn and then everything in the second which means everything in the second will appear “above” everything in the first.

Yes, this is what it looks like, and it is ruining the intended presentation!

What can I do to have the last line of the left-Y axis plotted as the last line overall?