Skip to content

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

Closed

Description

@okkevaneck

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.

Activity

  1. added this to the v3.3.1 milestone on Jul 23, 2020
  2. tacaswell commented on Jul 23, 2020

    @tacaswell
    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.

  3. tacaswell commented on Jul 23, 2020

    @tacaswell
    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
  4. neil-ptr commented on Jul 23, 2020

    @neil-ptr
    Contributor

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

  5. QuLogic commented on Jul 24, 2020

    @QuLogic
    Member

    Have at it.

  6. neil-ptr commented on Jul 28, 2020

    @neil-ptr
    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

  7. neil-ptr commented on Aug 2, 2020

    @neil-ptr
    Contributor

    take

  8. QuLogic commented on Aug 4, 2020

    @QuLogic
    Member

    Fixed by #18156.

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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions