Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Bug]: Polar plot wrong Y values when set_ylim is used #24790

Copy link
Copy link
Open
@afarcy

Description

@afarcy
Issue body actions

Bug summary

Plotting 2 trivial lines in a polar axes. Those lines are quarter-arcs with constant y values:

  • line1 is only y=5
  • line2 is only y=9
    The figure is plotted using a canvas.draw() call.

If line1 is deleted, set_ylim(8, 10) will make line2 disappear. In fact it can be found at y=13 for some reason.
Inspecting the object values (get_data) returns the correct values. It is as if the data was correct but the rendering off by just "4"

The issue is that set_ylim on a polar plot seems to apply an offset on the remaining lines after some workflow.

Code for reproduction

import numpy
import matplotlib.pyplot as plt


x = numpy.linspace(0, numpy.pi/2., num=90)
y1 = numpy.full(90, 5)
y2 = numpy.full(90, 9)

fig, ax = plt.subplots(subplot_kw={'projection': 'polar'})
ax.set_xlim(0, numpy.pi/2.)
ax.set_ylim(4, 10)
ax.plot(x, y1)
ax.plot(x, y2)
fig.canvas.draw()

ax.lines.pop(0) # If popping the 2nd line no issue encountered
if True:
    ax.set_ylim(8, 10) # This moves the 2nd line from y=9 to y=13

plt.show()

See simpler example at #24790 (comment)

Actual outcome

line2 rendering is done as if line2 had all its y values = 13

Expected outcome

line2 should be rendered as a if its values were y=9 (same as get_data return values)

Additional information

  • Deleting the other line instead gives no issue. Only deleting a line that contains data inferior to every other lines triggers the issue
  • Not calling canvas.draw before is not an option: My application is interactive the user is able to delete/add lines interactively
  • The issue seems to come from set_ylim on a polar plot

Operating system

Debian 11.6

Matplotlib Version

3.3.4; 3.4.2; 3.5.3; 3.6.2

Matplotlib Backend

tkAgg; Qt5Agg

Python version

3.7.10; 3.9.2

Jupyter version

No response

Installation

Linux package manager

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.