GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Figure.add_image slows down massively as more images are added · Issue #982 · fastplotlib/fastplotlib

Figure.add_image slows down massively as more images are added #982

New issue
Copy link
New issue
Copy link
Closed
Closed
Figure.add_image slows down massively as more images are added#982
Copy link

Description

@Archer6621
Archer6621
opened on Jan 26, 2026
Issue body actions

Perhaps I'm using the API wrongly, but what I am trying to do is to do some kind of object pooling, having many image graphics pre-initialized since I need to use them as some sort of dynamic thumbnails that show up as the user pans and zooms around, as it is much quicker to just set the data and position on the fly compared to adding a new image graphic, and I will have many of these responding to user interaction, so it needs to be responsive.

I noticed however that as I am initializing more images in the figure, the amount of time it takes to add a new image graphic increases a lot.

I've made a minimal example using imageio and tqdm to illustrate this:

import fastplotlib as fpl
import imageio.v3 as iio
from tqdm import tqdm

img = iio.imread("imageio:astronaut.png")

figure = fpl.Figure()

for x in tqdm(range(2000)):
	figure[0, 0].add_image(img)

figure.show()

fpl.loop.run()

Over time, the iterations per second eventually drops to low single digits. This makes the pooling take very long.

This is with fastplotlib 0.6.0, CPython 3.13.5, Windows 11.

Activity

  1. kushalkolar commented on Jan 26, 2026

    @kushalkolar
    kushalkolar
    on Jan 26, 2026
    Member
    More actions

    I think it's going to be slow with thousands of textures. What's your use case, you probably want to orchestrate your images so that you only display ones which are currently visible, and pre-load some around the edges?

  2. Archer6621 commented on Jan 27, 2026

    @Archer6621
    Archer6621
    on Jan 27, 2026
    Author
    More actions

    I have a relatively dense 2D point cloud, where each point represents an image, that the user can zoom in on, and when the user zooms in far enough, I want thumbnails of a fixed size to appear at all the points on the screen which I have pre-computed already. I built something custom to do this which works quite well, indeed only showing images on the points that are visible and around the edges to account for images whose points are outside of the view.

    I noticed that constantly removing and adding new graphics was slow, so I cache the graphics instead as they get added and then just set their position and data to what I need as the user zooms and pans around, only adding new ones on demand, which is much faster. The warm-up step that I described above simply pretends that a high number of images are demanded from the get-go, just to fill that cache, because this same slow-down appears at runtime whenever a new image graphic gets added when many are present already, hindering interactions.

    The rendering of all those images is actually quite alright, it's fast enough to be usable.

  3. kushalkolar commented on Jan 27, 2026

    @kushalkolar
    kushalkolar
    on Jan 27, 2026
    Member
    More actions

    Ah so you mean once they're added it's fast, but the adding itself is very slow? Maybe this is slowing things down as more graphics are added: https://github.com/fastplotlib/fastplotlib/blob/main/fastplotlib%2Flayouts%2F_plot_area.py#L583-L605

    Reacted by Shaad Alaka
  4. Archer6621 commented on Jan 29, 2026

    @Archer6621
    Archer6621
    on Jan 29, 2026
    Author
    More actions

    Ah so you mean once they're added it's fast, but the adding itself is very slow? Maybe this is slowing things down as more graphics are added: https://github.com/fastplotlib/fastplotlib/blob/main/fastplotlib%2Flayouts%2F_plot_area.py#L583-L605

    Yup that seems to be it, nice find! I commented this piece of code out, and ran the example above again, and it didn't slow down over time anymore. I also ran my original application, same there.

    It doesn't seem to impact my application either, as I manually make sure that the scatter points that I have are drawn at an offset that puts them behind the images - for the images themselves I don't care how they overlap.

    I suppose it would be nice to somehow make this sorting optional? Or maybe have a way to pre-instantiate many images quickly and then just sorting once.

  5. kushalkolar commented on Sep 1, 2026

    @kushalkolar
    kushalkolar
    on Sep 1, 2026
    Member
    More actions

    #1072 is a major refactor of GraphicCollection and will introduce ImageCollection which would be the way to add lots of images to a subplot.

  6. kushalkolar commented on Sep 11, 2026

    @kushalkolar
    kushalkolar
    on Sep 11, 2026
    Member
    More actions

    If you use the ndwidget branch it has an ImageCollection object which is the way to do this, similarly a collection subclass can created pretty easily for any Graphic type. Examples here: https://github.com/fastplotlib/fastplotlib/tree/7008c79c7513081a948262992e1f394b1cfccd5d/examples/image_collection

    That branch will be merged into main soon so I will close this. If you have questions about ImageCollection feel free to open a new issue!

  7. kushalkolar
    closed this as completedon Sep 11, 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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.