SciTools / iris

A powerful, format-agnostic, and community-driven Python package for analysing and visualising Earth science data
https://scitools-iris.readthedocs.io/en/stable/
BSD 3-Clause "New" or "Revised" License
625 stars 283 forks source link

Configurable colorbar in `iris.quickplot` #5970

Open trexfeathers opened 3 months ago

trexfeathers commented 3 months ago

✨ Feature Request

I would like to be able to configure colorbar creation via kwargs in iris.quickplot functions.

Motivation

If I want to customise a plot using iris.quickplot, I can modify every element after creating the plot EXCEPT the colorbar (due to how Matplotlib works).

rcomer commented 3 months ago

I think the work here is:

  1. Add a colorbar_kwargs keyword to the _label function, which is a dictionary of keywords to use in the colorbar call. If "orientation" or "drawedges" is in that dictionary, they should override the current choices. If "location" is in the dictionary, then "orientation" should not be passed. If "label" is in the dictionary, the set_label call should be skipped.

  2. Do the "plumbing" to expose colorbar_kwargs in every public plotting function that ultimately calls _label.

  3. Add tests.

pp-mo commented 3 months ago

I'm not quite sure of the exact scope or intention here, but I would probably oppose any additions to the quickplot api. IMHO iris.quickplot is a quick + simple one-stop shop. If you need more control, you should simply be using iris.plot instead. If there is still a need for additional controls there, to do things which can't be done otherwise, then I'd say that is appropriate.

trexfeathers commented 3 months ago

From @SciTools/peloton:

We prefer the simpler solution of 1 new parameter: colorbar, which defaults to True. If the user wants a customised colorbar then they should use False then add their own after creating the plot.

rcomer commented 3 months ago

I think the work here is:

  1. Add the boolean colorbar keyword to the _label function, which controls whether the colorbar is added.

  2. Do the "plumbing" to expose the colorbar keyword in every public plotting function that ultimately calls _label.

  3. Add tests.