Skip to content

Data Container core and Line2D - #32334

Draft
ksunden wants to merge 10 commits into
matplotlib:mainfrom
ksunden:data_container_core
Draft

ksunden wants to merge 10 commits into
matplotlib:mainfrom
ksunden:data_container_core

Conversation

@ksunden

@ksunden ksunden commented Sep 10, 2026 •

Copy link
Copy Markdown
Member

PR summary

This is the first PR towards the Data container project.

Reviewer Guide:

I would suggest starting with the architecture guide in users_explain. This provides an overview of each of the parts that are included and a sense of how they all fit together. (also please do tell me if there is a better place for it, this was alongside some of the other architectural descriptions I thought, but very willing to move it)

From there, I would suggest reviewing the code implementing the core pieces:

  • containers.py - the implementation of the Data Containers themselves
  • DataContainer as a Protocol
  • ArrayContainer - for relatively static array data
  • FuncContainer - which allows using functions... This is the most complex part of the file
  • description.py - Desc objects and validations/interactions thereof
  • conversion_edge.py - Implementation of Edges, and the execution graph
    • Note that the execution graph does touch on some utility that is underutilized in the initial roll out (weights on edges, default values, etc) These were left in to both ensure compatibility with the separately distributed PyPI package and because they are at least anticipated to be useful in internal usage
    • Look at the definition of an Edge
    • Subtypes of edge that provide specific functionality
      • SequenceEdge - chaining of edges to produce one logical "Edge"
      • CoordinateEdge - allows changing coordinates without changing values
      • DefaultEdge - providing default values
      • FuncEdge - arbitrary python functions
      • TransformEdge - represent Matplotlib Transforms
    • Review the Graph
      • __init__ does some precomputations which separate out subgraphs that are independant, this may be mildly confusing at first, but prevents a lot of looping through large lists of edges that have nothing to do with what you are computing
      • evaluator is the primary method of Graph, ultimately it is Djikstra's algorithm with a few tweaks on the input/output side

Finally, reviewing the implementation within Line2D, my rough outline for points to particularly focus on for review:

  • LineContainer - a simple container that allows for checking/backwards compatibility operations
  • Initialization to an empty container
  • Remapping of private caching properties (_x, _y, _xorig, _yorig_, _xy)
  • set_data and related functionality should work as existing users expect, but is not available if you provide your own container, as once you opt in to using a new container, that container becomes responsible for updating the data
  • draw functionality

I would include the functionality of _helpers.py as it comes up, there are only two things in there though:

  • _get_graph - Builds a minimal Graph from a given Axes, which consists of only TransformEdges
  • check_container - helper validation for backwards compatibility operations

AI Disclosure

None

PR quality check

  • Use an expressive title, e.g. "Fix title font property precedence"
  • New and changed code is tested
  • Plotting related features are demonstrated in an example
  • New features and API changes have release notes
  • Documentation complies with general and docstring guidelines

@timhoffm

Copy link
Copy Markdown
Member

Do we have an architecture description, ideally even Architecture Decision Records? That would help me a lot with evaluting the concept and design decisions compared to just looking at the implementation.

@github-actions github-actions Bot added the Documentation: user guide files in galleries/users_explain or doc/users label Sep 24, 2026
@jklymak

jklymak commented Sep 24, 2026

Copy link
Copy Markdown
Member

I only skimmed this. A couple of super high level comments:

  1. I'm not entirely following the need for "Execution Graph". Perhaps if you made another document that explained what existing Matplotlib concepts this subsumes, that would help? I assume this is encapsulating patterns we have throughout the codebase in an attempt to regularize them, which is probably great, but it is not 100% clear to me.
  2. Is there any reason this needs to be public on Line2D? Why not make all this private, and then we can muck about to our hearts' content?
  3. It would be nice to see some of the power of this abstraction, perhaps toggle-able: eg dynamic subsampling of a line with 10^7 points?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Documentation: user guide files in galleries/users_explain or doc/users topic: images

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants