Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add geographic axes to panel plots #284

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

Closed
kinyatoride opened this issue Sep 17, 2021 · 2 comments
Closed

Add geographic axes to panel plots #284

kinyatoride opened this issue Sep 17, 2021 · 2 comments

Comments

@kinyatoride
Copy link

Description

Currently, panel does not accept the keyword proj to plot geographic plots.
I think it will be a useful feature when you want to show a small map on top of a hovmoller diagram. I can manually make a similar plot as follows, but it's a bit tedious and abclabels will be shown on all axes.

slon=0
elon=360
proj = pplt.Proj('cyl', lon_0=180)

fig, axs = pplt.subplots(nrows=2, hratios=[1,6], proj=[proj, None])

axs[0].format(coast=True, latlim=(25, 65), lonlim=(slon, elon),
              labels=True, lonlabels='t')

axs[1].format(xformatter='deglon', xlim=(slon, elon),
              xlocator=60)

Screen Shot 2021-09-17 at 14 43 59

@lukelbd
Copy link
Collaborator

lukelbd commented Jan 24, 2022

Unfortunately I don't think I should implement this because it would involve a lot of special handling that would only benefit some pretty unusual use cases. The panel_axes infrastructure is built around the assumption that panels represent some reduced dimensionality of the main subplot data, so it usually doesn't make sense to have a map projection panel.

I think what would make more sense in your case might be to make the Hovmoller plot the "panel" and make the projection the main subplot. You can make panels as large as you want -- nothing stopping you from having a narrow main subplot and a much larger panel. Here's an example (development version is needed to pass format keyword args to panel()):

import proplot as pplt
slon=0
elon=360
proj = pplt.Proj('cyl', lon_0=180)
fig = pplt.figure()
ax = fig.subplot(
    proj=proj, land=True, abc='A.', title='Title', titleloc='l',
    latlim=(25, 85), lonlim=(slon, elon), labels=True, lonlabels='t'
)
px = ax.panel(
    'bottom', width=2, xformatter='deglon', share=False,
    xlim=(slon, elon), xlocator=60, number=2
)
N = M = 100
x = np.linspace(0, 360, N)
y = np.linspace(0, 25, M)
z = np.sin(x[:, None] / N + 20 * y[None, :] / N)
px.contourf(x, y, z, cmap='viridis')

tmp

@lukelbd
Copy link
Collaborator

lukelbd commented Jan 27, 2022

Also I realize one limitation of this is that you can't put colorbars along (e.g.) the left or right side of the Hovmoller plot, since it's a "panel".... but I think the generalization proposed in #329 will add support for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants