GenericMappingTools / GenericMappingTools/pygmt

Allow export of panel size

Open
#4,204 3 comments 0 reactions 0 assignees View on GitHub
feature request
Dominant language
Python
Stars
874
Forks
255
Avg merge
1d 21h
Merged PRs (30d)
40

Description

If the projections that you are using are not initially defined by a given height and width, then it is difficult to extract the dimensions of the plot in cm. This is an issue, for example, if panel A is an oblique mercator projection (with a projection defined by a central point and a rotation, and a region given as a top left and bottom right coordinate) and you would like panel B to be the same height (where the projection is `f'X{width}c/{height}c'`).

As `fig.shift_origin()` has included an option to get the plot size in inches since v15.0.0 :
```
with Session() as lib:
lib.call_module(module="plot", args=build_arg_list(kwdict))
_xshift = lib.get_common("X") # False or xshift in inches
_yshift = lib.get_common("Y") # False or yshift in inches
```
it feels like it should be possible to include a function where `_xshift` and `_yshift` can be exported as variables.

Example use:
```
proj = f"Oa{center_lon}/{center_lat}/55/{width}c+v" ##### PANEL HEIGHT IN CM NOT DEFINED
region = f"{tl_lon}/{tl_lat}/{br_lon}/{br_lat}+r"
fig = pygmt.Figure()
fig.coast(region=region, projection=proj, land="gray80", water="steelblue", area_thresh=1000)
panelA_width, panelA_height = fig.panel_dimensions('c') ##### RETURN PANEL SIZE IN CM
fig.shift_origin(width='w')
fig.basemap(region=[0, xmax, 0, ymax], projection=f'X{panelb_width}c/{panelA_height}c', frame=['WSne', 'xafg2', 'yafg1.0']) ##### ENSURE HEIGHT OF NEW PANEL MATCHES PANEL A
```

**Are you willing to help implement and maintain this feature?** Yes

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.