Closed
Description
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