scipp / scipp/plopp

Allow plotting multiple 2d images on the same figure?

Open
#449 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
12
Forks
6
PR merge metrics
No merged PRs in 30d

Description

The following

import plopp as pp

a = pp.data.data2d()
b = a.copy()
b.coords['x'] = b.coords['x'] + sc.scalar(100., unit='m')

pp.plot({'a': a, 'b': b})

to show two images side by side on the same axes was intentionally disabled because in many cases the images would overlap.

Say you have a signal and a background, and the user wants to plot both:
doing pp.plot({'sample': a, 'background': b}) where the two cover the same spatial range would result in a figure showing only the background, because it is drawn after the sample and the sample is hidden behind it.

The user's intention was probably to obtain two figures, instead of both images on the same axes.
This case is handled in 1d because you can often plot two curves on the same axes, with different color, and there isn't a curve hiding the other.

However, the first use case described at the start of this issue has come up more and more in real life examples, like plotting signal from multiple detector banks on the same axes.

Is the fear of having users confused by only seeing one image when sending two to the plot still outweighing the benefits of avoiding the workaround


to_plot = {'a': a, 'b': b}
as_nodes = {k: pp.Node(v) for k, v in to_plot.items()}
for k, v in as_nodes.items():
    v.name = k
pp.imagefigure(*as_nodes)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the disabled behavior in src/plopp/plotting/plot.py around line 122, then compare the direct pp.plot({'a': a, 'b': b}) example with the Node and pp.imagefigure workaround described here. Clarify the intended behavior for overlapping and spatially separate images, then identify tests that can demonstrate the chosen plotting result.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.