Skip to content

ax.set_zorder not working #303

@kinyatoride

Description

@kinyatoride

Description

ax.set_zorder does not work in proplot.
This becomes an issue when we want to change the zorders of twinx axes.

Steps to reproduce

import numpy as np
import pandas as pd
import proplot as pplt

x = np.linspace(0, 2*np.pi, 100)

fig, ax1 = pplt.subplots()
ax1.plot(np.sin(x), lw=3, c='b')

ax2 = ax1.twinx()
ax2.plot(np.sin(2*x), lw=3, c='r')

ax1.set_zorder(ax2.get_zorder()+1)
ax1.patch.set_visible(False)

Expected behavior: [What you expected to happen]
Red line to be placed beneath the blue line

Actual behavior: [What actually happened]
Screen Shot 2021-11-29 at 17 59 30

Equivalent steps in matplotlib

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

x = np.linspace(0, 2*np.pi, 100)

fig, ax1 = plt.subplots()
ax1.plot(np.sin(x), lw=3, c='b')

ax2 = ax1.twinx()
ax2.plot(np.sin(2*x), lw=3, c='r')

ax1.set_zorder(ax2.get_zorder()+1)
ax1.patch.set_visible(False)

Screen Shot 2021-11-29 at 18 01 00

Proplot version

3.4.3
0.9.4

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions