Skip to content

Saving publication quality figures #1156

Closed

Description

@rosimarwx

Proposed new feature or change:

Hi! I have been using uxarray to plot unstructured MPAS-Atmosphere output with >29 million cells. So far, so good. I would like to save publication-quality figures from my uxarray plots, but I cannot find this feature anywhere in the documentation. When I plot using matplotlib, I would save the figure with something like plt.savefig('./figureName.jpeg',dpi=600,bbox_inches='tight'). Does a feature like this exist with uxarray? If not, would it be possible to be added?

Here is my minimal code example:

import uxarray as ux
import cartopy.crs as ccrs

expName = "plus4K"
dx = "TC_3km"
grid_path = "/glade/work/rberrios/MPAS/grid_files/x5.tropical_3km_10N.grid.nc"
data_path = "/glade/derecho/scratch/rberrios/te/tmp/%s/%s/sub_history.2000-06-19_12.00.00.nc"%(expName,dx)

uxds = ux.open_dataset(grid_path, data_path)

uxds["olrtoa"][0].plot.rasterize(
    method="point",
    projection=ccrs.Mollweide(),
    pixel_ratio=2.0,
    fig_size=400,
    xaxis=None,
    yaxis=None,
    backend="matplotlib"
    )

Many thanks!
Rosimar (from NSF NCAR/MMM)

Activity

  1. self-assigned this
    on Feb 7, 2025
  2. philipc2 commented on Feb 7, 2025

    @philipc2
    Member

    Hi @rosimarwx

    Here is a fantastic guide from the HoloViews documentation.

    The following should work:

    import uxarray as ux
    import cartopy.crs as ccrs
    
    expName = "plus4K"
    dx = "TC_3km"
    grid_path = "/glade/work/rberrios/MPAS/grid_files/x5.tropical_3km_10N.grid.nc"
    data_path = "/glade/derecho/scratch/rberrios/te/tmp/%s/%s/sub_history.2000-06-19_12.00.00.nc"%(expName,dx)
    
    uxds = ux.open_dataset(grid_path, data_path)
    
    olrtoa_plot = uxds["olrtoa"][0].plot.rasterize(
        method="point",
        projection=ccrs.Mollweide(),
        pixel_ratio=2.0,
        fig_size=400,
        xaxis=None,
        yaxis=None,
        backend="matplotlib"
        )
    
    hv.save(olrtoa_plot, "olrtoa_plot.png", fmt='png')
  3. locked and limited conversation to collaborators on Feb 7, 2025
  4. converted this issue into a discussion #1157 on Feb 7, 2025
  5. moved this from 📚 Backlog to ✅ Done in UXarray Developmenton Feb 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

new featureNew user-facing functionality

Type

No type

Fields

Priority

None yet

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions