FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[Bug]: ax.relim() ignores scatter artist · Issue #30859 · matplotlib/matplotlib · GitHub

Repository navigation

[Bug]: ax.relim() ignores scatter artist #30859

Description

Bug summary

ax.relim() completely ignores changes to scatterplots with .set_offsets().

Code for reproduction

import tkinter as tk
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2Tk
from matplotlib.figure import Figure
import numpy as np

class App:
    def __init__(self, root):
        self.root = root
        fig = Figure(figsize=(5, 5), dpi=100)
        self.ax = fig.add_subplot(111)

        self.canvas = FigureCanvasTkAgg(fig, root)
        self.canvas.get_tk_widget().pack(fill="both", expand=True)

        self.toolbar = NavigationToolbar2Tk(self.canvas, root)

        # Create artists once
        self.scatter = self.ax.scatter([], [])
        self.line, = self.ax.plot([], [])

        root.after(1000, self.update_plot)

    def update_plot(self):
        # New data every update
        xs = np.linspace(0, 10, 100)
        ys = np.sin(xs) + np.random.normal(scale=0.1, size=100)

        # Update artists
        self.scatter.set_offsets(np.column_stack((xs, ys)))
        #self.line.set_data(xs, ys) #Uncomment this to see the expected behaviour

        # Autoscale (not working)
        self.ax.relim()
        self.ax.autoscale_view()

        self.canvas.draw_idle()

        # Keep updating
        self.root.after(1000, self.update_plot)

root = tk.Tk()
App(root)
root.mainloop()

Actual outcome

Expected outcome

Additional information

No response

Operating system

Windows

Matplotlib Version

3.9.1

Matplotlib Backend

tkAgg

Python version

3.11.9

Jupyter version

None

Installation

pip

Activity

  1. timhoffm commented on Dec 15, 2025

    Member

    Limit handling has historically been quite a mess, unfortunately there is little consistency across artists. See #15595 (comment).

  2. mp-007 commented on Jan 26, 2026

    @CyfralCoot maybe it can help you, but I did an autoscale function to handle all kind of artist. You can have a look here: https://github.com/mp-007/kivy_matplotlib_widget/blob/main/kivy_matplotlib_widget/uix/graph_subplot_widget.py#L186

    It is a built-in function inside my kivy widget, but it can give you some guidelines.

  3. Archiljain commented on Feb 9, 2026

    Contributor

    Hi, I’d like to work on this issue.
    I’ll start by reproducing the bug locally and then look into how relim() handles scatter artists.

  4. QuLogic commented on Mar 7, 2026

    Member

    The PR that "fixed" this was only marked as merged because its commits were contained in a second PR that was merged, but that second PR reverted all the changes from the first PR, so this isn't actually fixed.

  5. reopened this on Mar 7, 2026
  6. added 4 commits that reference this issue on Apr 19, 2026
    1d1d33f
    cb8bce5
    07127b6
    3da28af
  7. added this to the v3.11.0 milestone on Apr 21, 2026
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

    API: consistencyConsistency of the matplotlib API, including naming, behavior, defaults, …status: confirmed bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL