Separate plotting logic from data logic#400
Merged
psomhorst merged 7 commits intofeat_pixel_mapfrom Aug 1, 2025
Merged
Conversation
JulietteFrancovich
approved these changes
Aug 1, 2025
Contributor
JulietteFrancovich
left a comment
There was a problem hiding this comment.
I think very clear to have the plotting logic separate from the data logic and renaming to plot config rather than plot parameters also improves clarity.
0807b23 to
5496ff9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR separates the plotting logic of PixelMap from the class itself. The way this was worked out might feel a bit clunky, but is scalable for other objects.
datahandling/pixelmap.py defines the classes that contain pixel map data.
plotting/pixelmap.py defines a PixelMapPlotting class, which contains all methods related to plotting.
plotting/pixelmap.py defines the configurations for the pixel maps, e.g. TIVMapPlotConfig.
plotting/__init__.py contains a registry of configurations.
PixelMapPlottingcontains all plotting related logics. You could access them with e.g.PixelMapPlotting(pixel_map).imshow(...). However,pixel_map.plotting.imshow(...)does the same thing, and should be used instead in most cases.The configuration for plotting is stored in
pixel_map._plot_config, but should be accessed throughpixel_map.plotting.config.The config registry contains the default configurations for each
PixelMapsubclass, e.g.TIVMapPlotConfig. The advantage of this registry is that it can be updated during runtime, which means someone can change the default values at the start of their script. When aTIVMapis initialized, it copies the associated values from the registry. Updating the config for an individualTIVMapinstance does not overwrite the defaults. Overwriting defaults does not influence existing objects.This approach is highly scalable. We can use the same code for e.g.
ContinuousDataand its plotting config. A defaultContinuousDataPlotConfigcould use theunitattribute ofContinuousDatato create an axis label. If someone has e.g. a lot of pressure data, they could create a subclass ofContinuousDatacalledPressureData, create aPressureDataPlotConfig, register it, and use it throughout the code.NB: this PR is aimed at feature/mask_class, since it depends on the Mask class.