<div dir="ltr">Andre,<div><br></div><div>Please subscribe to the mailing list <a href="https://mail.python.org/mailman/listinfo/matplotlib-users">https://mail.python.org/mailman/listinfo/matplotlib-users</a> to post un-moderated and to make sure you get responses.</div><div><br></div><div>Thank you for a copy-paste-runable example, it made it super easy to help you :)</div><div><br></div><div>The units that the positions are in is "axes fraction" which is the coordinate system on the Axes object where (0,0) is the lower left and (1, 1) is the upper right.  In this coordinate system 1.35 is a 0.35 * (axes width) to the right of the right edge of the Axes which happens to be out of the Figure.</div><div><br></div><div>If do </div><div><br></div><div>fig.subplots_adjust(right=0.5) </div><div><br></div><div>it will shrink the Axes enough that it will all fit.</div><div><br></div><div>If you have a mpl >=3.1 then you can do</div><div><br></div><div>fig, host = plt.subplots(constrained_layout=True) <br></div><div># fig.subplots_adjust(right=0.5)  # remove the call to subplots_adjust</div><div><br></div><div>It will automatically resize everything to fit and completely fill the available space!</div><div><br></div><div>Tom</div><div><br></div><div>------</div><div><br></div><div><font face="monospace">import matplotlib.pyplot as plt<br><br><br>def make_patch_spines_invisible(ax):<br>    ax.set_frame_on(True)<br>    ax.patch.set_visible(False)<br>    for sp in ax.spines.values():<br>        sp.set_visible(False)<br><br><br>fig, host = plt.subplots(constrained_layout=True)<br># fig.subplots_adjust(right=0.5)<br><br>par1 = host.twinx()<br>par2 = host.twinx()<br>par3 = host.twinx()<br><br># Offset the right spine of par2.  The ticks and label have already been<br># placed on the right by twinx above.<br>par2.spines["right"].set_position(("axes", 1.2))<br>par3.spines["right"].set_position(("axes", 1.35))<br># Having been created by twinx, par2 has its frame off, so the line of its<br># detached spine is invisible.  First, activate the frame but make the patch<br># and spines invisible.<br>#make_patch_spines_invisible(par2)<br>make_patch_spines_invisible(par3)<br># Second, show the right spine.<br>par2.spines["right"].set_visible(True)<br>par3.spines["right"].set_visible(True)<br><br>p1, = host.plot([0, 1, 2], [0, 1, 2], "b-", label="Density")<br>p2, = par1.plot([0, 1, 2], [0, 3, 2], "r-", label="Temperature")<br>p3, = par2.plot([0, 1, 2], [50, 30, 15], "g-", label="Velocity")<br>p4, = par3.plot([0, 1, 2], [12, 18, 20], "y-", label="Voltage")<br><br>host.set_xlim(0, 2)<br>host.set_ylim(0, 2)<br>par1.set_ylim(0, 4)<br>par2.set_ylim(1, 65)<br><br>host.set_xlabel("Distance")<br>host.set_ylabel("Density")<br>par1.set_ylabel("Temperature")<br>par2.set_ylabel("Velocity")<br>par3.set_ylabel("Voltage")<br><br>host.yaxis.label.set_color(p1.get_color())<br>par1.yaxis.label.set_color(p2.get_color())<br>par2.yaxis.label.set_color(p3.get_color())<br>par3.yaxis.label.set_color(p4.get_color())<br><br>tkw = dict(size=4, width=1.5)<br>host.tick_params(axis='y', colors=p1.get_color(), **tkw)<br>par1.tick_params(axis='y', colors=p2.get_color(), **tkw)<br>par2.tick_params(axis='y', colors=p3.get_color(), **tkw)<br>par3.tick_params(axis='y', colors=p4.get_color(), **tkw)<br>host.tick_params(axis='x', **tkw)<br><br>lines = [p1, p2, p3 , p4]<br><br>host.legend(lines, [l.get_label() for l in lines])<br><br>plt.show()</font><br></div><div><font face="monospace"><br></font></div><div><font face="monospace"><br></font></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jun 26, 2020 at 6:45 PM Andre <<a href="mailto:andre.kjellstrup@gmail.com">andre.kjellstrup@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I modified<br>
<a href="https://matplotlib.org/3.2.1/gallery/ticks_and_spines/multiple_yaxis_with_spines.html" rel="noreferrer" target="_blank">https://matplotlib.org/3.2.1/gallery/ticks_and_spines/multiple_yaxis_with_spines.html</a><br>
to have a fourth data-set: <br>
<a href="https://gist.github.com/AndKe/c0c999a22a8daebafb62171b671bf131" rel="noreferrer" target="_blank">https://gist.github.com/AndKe/c0c999a22a8daebafb62171b671bf131</a><br>
<br>
With the offset of "1.35"<br>
par3.spines["right"].set_position(("axes", 1.35))<br>
One can get a glimpse of that, any less, and it will overlap, and more it<br>
will be invisible.<br>
<br>
changing "right" to "left" does nothing.<br>
Also, the resulting spines placement does vary with the width of the window. <br>
- wasting more space the wider the window gets.<br>
<br>
<br>
<br>
--<br>
Sent from: <a href="http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html" rel="noreferrer" target="_blank">http://matplotlib.1069221.n5.nabble.com/matplotlib-users-f3.html</a><br>
_______________________________________________<br>
Matplotlib-users mailing list<br>
<a href="mailto:Matplotlib-users@python.org" target="_blank">Matplotlib-users@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/matplotlib-users" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/matplotlib-users</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature">Thomas Caswell<br><a href="mailto:tcaswell@gmail.com" target="_blank">tcaswell@gmail.com</a></div>