Skip to content

Multiple canvas draws in loops #56

@gb119

Description

@gb119

Description:

In src/stonerplots/context/multiple_plot.py:369-410, multiple figure.canvas.draw() calls within loops could be expensive for complex figures.

Impact:

  • Slower rendering for complex multi-panel figures
  • Each draw triggers a full re-render
  • Noticeable with many subplots or complex visualizations

Recommendation:

Consider batching drawing operations - collect all changes then draw once:

# Instead of:
for ax in axes:
    modify(ax)
    figure.canvas.draw()  # Draw after each modification

# Consider:
for ax in axes:
    modify(ax)
figure.canvas.draw()  # Draw once at the end

Important: Verify this doesn't break intended behavior - some operations may require intermediate draws for measurements or layout calculations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions