Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent subplots from overlapping in 6-panel plots; Prevent colorbar labels from overlapping #260

Merged
merged 2 commits into from
Sep 20, 2023

Conversation

yantosca
Copy link
Contributor

This is the companion PR to #259, in which we have implemented several fixes for the 6-panel plots (as are used to display GEOS-Chem benchmark output):

  1. Add a new style sheet gcpy/gcpy_plot_style with global settings for plot titles and labels. These settings are applied with the plt.style.use() function.

  2. Remove hardwired fontsize attributes in compare_single_level and compare_zonal_mean. We now get these values from the settings in gcpy/gcpy_plot_style.

  3. Decrease the amount of padding space (from 0.10 to 0.02) between the plot and colorbar for single_level plots. This will prevent the colorbar from overlapping with the plot titles in the next row.

  4. Increase the amount of padding between the plot and colorbar (from 0.10 to 0.15) between the plot and colorbar for zonal_mean plots. This will prevent the zonal mean plots from overlapping onto the next row.

  5. Make sure that the colorbar min and max values (vmin, vmax) are such that vmin is always smaller than vmax for dynamic-range ratio plots. This was causing an issue where colorbar plot labels were overlapping each other.

  6. For dynamic-range ratio plots, if the data lies in the range 0.999..1.001, then only create 3 colorbar ticklabels ([vmin, 1, vmax]). Using less ticklabels will prevent the ticklabels from overlapping.

  7. In routine compare_zonal_mean, add extra padding space around each subplot (and also define the left and right extents for the subplots on the page) with a call to plt.subplots_adjust().

gcpy/gcpy_plot_style
- Style sheet with several global plot parameter settings.  These
  will override the matplotlib.rcParams default settings.

gcpy/plot.py
- Use the gcpy_plot_style style sheet to override several
  Matplotlib default settings
- For zonal_mean plots, increase padding between the plot and colorbar
  from 0.10 to 0.15 (fractional height)
- For single_level plots, decrease padding between the plot and
  colorbar (from 0.10 to 0.02). This helps plots not to overflow into
  the titles of the next row.
- No longer hardwire the fontsize setting of the top-of-page title;
  this is now specified as "figure.titlesize" in the gcpy_plot_style
  customizable style sheet.
- Updated comments in the compare_zonal_mean Pydoc header.
- Use matplotlib.pyplot.subplots_adjust (aka plt.subplots_adjust) to
  add extra padding between subplots ("wspace" and "hspace").  Also
  specify how much of the page to occupy in the horizontal (between
  "left" and "right" settings), and in the vertical ("bottom" to "top";
  "top" uses the default value of 0.11).

Signed-off-by: Bob Yantosca <[email protected]>
gcpy/plot.py
- In routine "compute_vmin_vmax_for_plot":
  - Make sure vmin is less than vmax for dynamic-range ratio plots
- In routine "colorbar_ticks_and_format":
  - For dynamic-range ratio plots, if the data lies between 0.999
    and 1.001, then manually set tickmarks at [vmin, 1, vmax] (i.e.
    do not use intermediate tick labels).  This should prevent the
    tick labels from overlapping each other).
  - Update comments

CHANGELOG.md
- Updated accordingly

Signed-off-by: Bob Yantosca <[email protected]>
@yantosca yantosca added topic: Colors and Display Issues pertaining to color scales or other display issues topic: Benchmark Plots and Tables Issues pertaining to generating plots/tables from benchmark output category: Bug Fix Fixes a bug that was previously reported labels Sep 18, 2023
@yantosca yantosca added this to the 1.4.0 milestone Sep 18, 2023
@yantosca yantosca requested a review from msulprizio September 18, 2023 21:49
@yantosca yantosca self-assigned this Sep 18, 2023
@yantosca
Copy link
Contributor Author

With these fixes, the 6-panel single-level plots now look like this:
2023_09_18_17_34_00_Greenshot
and the 6-panel zonal-mean plots now look like this:
2023_09_18_17_35_21_Greenshot

@yantosca yantosca changed the title Prevent subplots from overlapping in 6-panel plots; Prevent colorbar labels from overlappinmg Prevent subplots from overlapping in 6-panel plots; Prevent colorbar labels from overlapping Sep 19, 2023
@yantosca yantosca merged commit 7de951b into dev Sep 20, 2023
@yantosca yantosca deleted the bugfix/prevent-subplots-from-overlapping branch September 20, 2023 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: Bug Fix Fixes a bug that was previously reported topic: Benchmark Plots and Tables Issues pertaining to generating plots/tables from benchmark output topic: Colors and Display Issues pertaining to color scales or other display issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG/ISSUE] Issue with colorbars and axis labels in latest benchmark plots
2 participants