Skip to content

axis limits come out reversed a lot #334

Closed

Description

@beckermr

Description

Right now in many cases, the plot limits come out reverse (e.g., the x-axis goes from 1 to -4 instead of -4 to 1).

Steps to reproduce

A "Minimal, Complete and Verifiable Example" will make it much easier for maintainers to help you.

import proplot as pplt
import numpy as np

rng = np.random.RandomState(seed=10)
x = rng.uniform(size=1000)*4 - 6
y = rng.uniform(size=1000)*2 + 6

fig, axs = pplt.subplots()
axs.hexbin(x, y)

Expected behavior: axis limits numerically ordered (should be -6 to -2)

Actual behavior: came out reversed (-2 to -6)

Equivalent steps in matplotlib

Please try to make sure this bug is related to a proplot-specific feature. If you're not sure, try to replicate it with the native matplotlib API. Matplotlib bugs belong on the matplotlib github page.

import matplotlib.pyplot as plt
import numpy as np

rng = np.random.RandomState(seed=10)
x = rng.uniform(size=1000)*4 - 6
y = rng.uniform(size=1000)*2 + 6

fig, axs = plt.subplots(nrows=1, ncols=1)
axs.hexbin(x, y)

Proplot version

Paste the results of import matplotlib; print(matplotlib.__version__); import proplot; print(proplot.version)here.

3.5.0
0.9.5

Activity

  1. lukelbd commented on Feb 3, 2022

    @lukelbd
    Collaborator

    This is related to #300 (also documented on this page). Proplot automatically reverses the axis when it detect "dependent" variable coordinates and the axes were not previously fixed -- however this behavior should definitely be disabled for hexbin and hist2d, and it looks like this used to be disabled for hist and histh but the #191 fix is now obsolete. Sorry for the annoying behavior! I'll fix this later today.

    Note also that the #300 fix make this feature more conservative; for example when passing stuff to ax.plot(x, y) an axis will only be reversed if 1) the x limits were not previously fixed with e.g. set_xlim and 2) the x coordinates are monotonically decreasing rather than simply having a negative initial step size.

  2. beckermr commented on Feb 3, 2022

    @beckermr
    Author

    Thank you!

  3. added a commit that references this issue on Feb 3, 2022
    275bf30
  4. lukelbd commented on Feb 3, 2022

    @lukelbd
    Collaborator

    Fixed by 275bf30. Here's an example:

    fig, axs = pplt.subplots(ncols=2, share=False)
    x = np.sort(np.random.rand(100) * 100)
    x = x[::-1]
    axs[0].hist(x)
    axs[1].hexbin(x, x)
    print(pplt.internals.inputs._is_descending(x))

    Result is True but axes are not reversed:

    iTerm2 dtQmy4

  5. beckermr commented on Feb 3, 2022

    @beckermr
    Author

    Thank you! Looking forward to a release with the patch!

  6. esheldon commented on Mar 15, 2024

    @esheldon

    I'm still seeing this for the quiver command, even in new releases, does that need to be addressed separately?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions