Skip to content
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

Scatter3D: depthshade=False causes IndexError for Tkinter when plotting more than one point. #18037

Closed
OkkeVanEck opened this issue Jul 23, 2020 · 7 comments
Labels
Difficulty: Medium https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues Good first issue Open a pull request against these issues if there are no active ones! status: confirmed bug topic: mplot3d
Milestone

Comments

@OkkeVanEck
Copy link

Bug report

Bug summary

Setting depthshade=False causes an IndexError for Tkinter when plotting more than one point. There are no errors when plotting one point.

Code for reproduction

    fig = plt.figure()
    ax = fig.gca(projection="3d")
    ax.scatter([0,1], [0,1], [0,1], c="royalblue", marker="o",
                depthshade=False, s=60, label="H")
    plt.show()

Actual outcome

I'll only post the first and last rows of the terminal, as the rest contains privacy sensitive information.

First rows:

Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/lib/python3.6/tkinter/__init__.py", line 1705, in __call__
    return self.func(*args)
  File "/usr/lib/python3.6/tkinter/__init__.py", line 749, in callit
    func(*args)
...: line 253, in idle_draw
    self.draw()

Last rows:

.../venv/lib/python3.6/site-packages/mpl_toolkits/mplot3d/art3d.py", line 507, in do_3d_projection
    fcs = fcs[z_markers_idx]
IndexError: index 1 is out of bounds for axis 0 with size 1

Expected outcome

It should just plot two points in a 3D space.

Matplotlib version

  • Operating system: Ubuntu 18.04
  • Matplotlib version: 3.3.0
  • Matplotlib backend TkAgg:
  • Python version: 3.6.9
  • Jupyter version (if applicable): -
  • Other libraries:

I recently upgraded Matplotlib via pip:

pip install --upgrade matplotlib

And originally installed it with pip as well within a virtual environment created with python-venv. I tested the code above in an older virtual environment and no errors occur when using matplotlib version 3.2.2.

@tacaswell tacaswell added this to the v3.3.1 milestone Jul 23, 2020
@tacaswell
Copy link
Member

The full trackback:

Traceback (most recent call last):
  File "/home/tcaswell/.virtualenvs/bleeding/lib/python3.10/site-packages/matplotlib/backends/backend_qt5.py", line 480, in _draw_idle
    self.draw()
  File "/home/tcaswell/.virtualenvs/bleeding/lib/python3.10/site-packages/matplotlib/backends/backend_agg.py", line 407, in draw
    self.figure.draw(self.renderer)
  File "/home/tcaswell/.virtualenvs/bleeding/lib/python3.10/site-packages/matplotlib/artist.py", line 41, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "/home/tcaswell/.virtualenvs/bleeding/lib/python3.10/site-packages/matplotlib/figure.py", line 1863, in draw
    mimage._draw_list_compositing_images(
  File "/home/tcaswell/.virtualenvs/bleeding/lib/python3.10/site-packages/matplotlib/image.py", line 132, in _draw_list_compositing_images
    a.draw(renderer)
  File "/home/tcaswell/.virtualenvs/bleeding/lib/python3.10/site-packages/matplotlib/artist.py", line 41, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "/home/tcaswell/.virtualenvs/bleeding/lib/python3.10/site-packages/mpl_toolkits/mplot3d/axes3d.py", line 445, in draw
    sorted(self.collections,
  File "/home/tcaswell/.virtualenvs/bleeding/lib/python3.10/site-packages/mpl_toolkits/mplot3d/axes3d.py", line 446, in <lambda>
    key=lambda col: col.do_3d_projection(renderer),
  File "/home/tcaswell/.virtualenvs/bleeding/lib/python3.10/site-packages/mpl_toolkits/mplot3d/art3d.py", line 507, in do_3d_projection
    fcs = fcs[z_markers_idx]

This is a regression from 3.2.

@tacaswell tacaswell added status: confirmed bug Good first issue Open a pull request against these issues if there are no active ones! Difficulty: Medium https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues labels Jul 23, 2020
@tacaswell
Copy link
Member

Labeling as a good first issue because there is an example that used to work and no longer does so no API design work, but medium difficulty because the mplot3d code is a bit complex to walk through.

Tasks:

  • track down bug (git bisect or read the code)
  • fix bug + add test

@neil-and-void
Copy link
Contributor

Hi, I'm new to open source, could I try my hand at this?

@QuLogic
Copy link
Member

QuLogic commented Jul 24, 2020

Have at it.

@neil-and-void
Copy link
Contributor

4428da6 is the first bad commit (cc @xenoryt)

Author: Tyrone Xiong ty.cx123@gmail.com
Date: Wed Mar 14 19:44:57 2018 -0400

I may have come up with some type of solution but I don't know why it works due to the complex names of the variables within this section

@neil-and-void
Copy link
Contributor

take

@QuLogic
Copy link
Member

QuLogic commented Aug 4, 2020

Fixed by #18156.

@QuLogic QuLogic closed this as completed Aug 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Difficulty: Medium https://matplotlib.org/devdocs/devel/contribute.html#good-first-issues Good first issue Open a pull request against these issues if there are no active ones! status: confirmed bug topic: mplot3d
Projects
None yet
Development

No branches or pull requests

4 participants