cats icon indicating copy to clipboard operation
cats copied to clipboard

Potential plotting enhancements

Open andreww opened this issue 6 months ago • 4 comments

This issue collects together ideas to improve the plotting functionality (enabled via --plotting on the command line and making use of matplotlib).

  1. We currently just write the carbon intensity units in the graph in the same way as we write the units on the command line (i.e. gCO2eq/kWh). We could write this out in LaTeX (i.e. gCO$_2$eq/kWh) but we should check that this works with pip install matplotlib on all supported platforms (do they all give LaTeX?).
  2. Related to 1, we don't have unit tests for the plotting. Getting this set up looks like a bit of a faff but there is some support in matplotlib's test harness if anybody is interested. This should tell us if pip install matplotlib works.
  3. Can we improve the way we show overlapping of "now" and "optimal" times. Currently the semi-transparent red and green give us a khaki. We could detect the overlap and do hatching or something. Or put the overlap in the caption (if we can work out the colour). See #112 for previous discussion.

Probably worth gathering any other ideas below before we jump into implementation.

andreww avatar Jun 24 '25 08:06 andreww

As for (2), happy to sort that (when I get time) since in another library I develop I have used matplotlib's image comparison framework (specifically matplotlib.testing.compare) to set up a decorator to compare generated plots to reference plots which are known to be correct (as far as one can verify by eyeball) by inspection stored in a named directory. So we can basically use that or something very similar: https://github.com/NCAS-CMS/cf-plot/blob/d275430ac667a532a6c105cdeecc14f469d6231a/cfplot/test/test_examples.py#L39-L72

sadielbartholomew avatar Jun 24 '25 10:06 sadielbartholomew

I'm going to tackle this (unless anyone jumps in to say they are already on it but assuming not given the empty assignees list on this Issue). I think I will do the simpler, visual-based, (1) and (3) first and then (2) as a separate PR given its different scope.

sadielbartholomew avatar Aug 11 '25 11:08 sadielbartholomew

I'm going to tackle this (unless anyone jumps in to say they are already on it but assuming not given the empty assignees list on this Issue). I think I will do the simpler, visual-based, (1) and (3) first and then (2) as a separate PR given its different scope.

I don't think anybody is working on this and I'm more than happy for you to go for it!

andreww avatar Aug 11 '25 11:08 andreww

Sorry for the delay in this - endlessly busy with one thing and then another. But I now have some time to spare in-between teaching sections of a training course, so I have started preparing the PR and expect to have it up within a few days.

sadielbartholomew avatar Nov 18 '25 16:11 sadielbartholomew

@sadielbartholomew - I think this is all done and we can close the issue?

andreww avatar Nov 28 '25 11:11 andreww

@andreww all done except (2), the unit testing. I wanted to do that after we had updated the plot output to our liking, which should be satisfied by #171, as explained there in my opening comment. So, we can now add image comparison testing (I can do it, but not for a few weeks given my bandwidth, so if someone else wants to get there first, that's all good).

Feel free to raise a new issue concerning only testing of the plots, but I will convert the 3 points here form your opening comment to sub-tasks which should make it clear enough what remains outstanding. Thanks.

sadielbartholomew avatar Nov 28 '25 15:11 sadielbartholomew