Skip to content

Patches cannot be picked when y-axis has logarithmic scaling #8979

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lejar opened this issue Aug 2, 2017 · 1 comment
Closed

Patches cannot be picked when y-axis has logarithmic scaling #8979

lejar opened this issue Aug 2, 2017 · 1 comment

Comments

@lejar
Copy link

lejar commented Aug 2, 2017

Bug report

Bug summary
When plotting with a logarithmic scale on the y-axis, patches have incorrect picking behaviour.

Text seems to work correctly, but FancyArrowPatch cannot be picked at all and the pick area for circles is very far off to the left.

Code for reproduction
Make sure to uncomment the scaling line if you want to see the bug!

from __future__ import print_function

from matplotlib import pyplot as plt
from matplotlib import patches
from matplotlib import text


def pick_event(event):
    print("PICK", event.artist)


def main():
    fig = plt.figure()
    axes = fig.add_subplot(111)

    # Uncommenting this makes picking break for the patches.
    # The circle will have a wierd selection box to the left side of the plot,
    # and the line will not be selectable at all.
    # axes.set_yscale('log')
    axes.set_xlim((0, 5))
    axes.set_ylim((1e-1, 10))

    # Add an arrow.
    arrow = patches.FancyArrowPatch(
        (3, 2),
        (4, 3),
    )
    arrow.set_picker(4)
    axes.add_patch(arrow)

    # Add a circle.
    circle = patches.Circle(xy=(1.90, 0.5), radius=0.1)
    circle.set_picker(4)
    axes.add_patch(circle)

    # Add some text.
    text_ = text.Text(1, 1, 'text')
    text_.set_picker(4)
    axes.add_artist(text_)

    # Connect the pick event and show the plot.
    fig.canvas.mpl_connect('pick_event', pick_event)
    plt.show()


if __name__ == '__main__':
    main()

Actual outcome
Only the text is properly pickable.

Expected outcome
Everything should be properly pickable.

Matplotlib version

  • Operating System:
$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 16.04.2 LTS
Release:	16.04
Codename:	xenial
  • Matplotlib Version:
$ python -c "import matplotlib; print matplotlib.__version__"
2.0.2
  • Python Version:
$ python --version
Python 2.7.12

Installed matplotlib via pip:

(virtenv) 13:49:32-user@computer:~/Desktop$ pip install matplotlib
Collecting matplotlib
  Downloading matplotlib-2.0.2-cp27-cp27mu-manylinux1_x86_64.whl (14.5MB)
    100% |████████████████████████████████| 14.5MB 98kB/s 
Collecting numpy>=1.7.1 (from matplotlib)
  Downloading numpy-1.13.1-cp27-cp27mu-manylinux1_x86_64.whl (16.6MB)
    100% |████████████████████████████████| 16.6MB 115kB/s 
Collecting cycler>=0.10 (from matplotlib)
  Using cached cycler-0.10.0-py2.py3-none-any.whl
Collecting python-dateutil (from matplotlib)
  Downloading python_dateutil-2.6.1-py2.py3-none-any.whl (194kB)
    100% |████████████████████████████████| 194kB 8.2MB/s 
Collecting functools32 (from matplotlib)
Collecting six>=1.10 (from matplotlib)
  Using cached six-1.10.0-py2.py3-none-any.whl
Collecting pytz (from matplotlib)
  Using cached pytz-2017.2-py2.py3-none-any.whl
Collecting pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=1.5.6 (from matplotlib)
  Using cached pyparsing-2.2.0-py2.py3-none-any.whl
Collecting subprocess32 (from matplotlib)
Installing collected packages: numpy, six, cycler, python-dateutil, functools32, pytz, pyparsing, subprocess32, matplotlib
Successfully installed cycler-0.10.0 functools32-3.2.3-2 matplotlib-2.0.2 numpy-1.13.1 pyparsing-2.2.0 python-dateutil-2.6.1 pytz-2017.2 six-1.10.0 subprocess32-3.2.7
@anntzer
Copy link
Contributor

anntzer commented Aug 2, 2017

Fixed as of master by #7844.

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

No branches or pull requests

3 participants