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

GeoAxes features request #397

Closed
Dearsomeone opened this issue Nov 11, 2022 · 1 comment
Closed

GeoAxes features request #397

Dearsomeone opened this issue Nov 11, 2022 · 1 comment

Comments

@Dearsomeone
Copy link

Dearsomeone commented Nov 11, 2022

Description

Hello, I am a regular user of proplot with which I can draw beautiful geoscience plots. CartesianAxes provides powerful contol on axes major and minor ticks. But for GeoAxes, it seems that proplot only provides control of lat and lon grid lines. If I want to show lat and lon ticks for NCL style geographic plots, I can only call the matplotlib method ax.tick_params(). As shown below, the code will become redundant and inconsistent with the proplot style. If the GeoAxes.format can control the lat and lon ticks, I think it will be a nice feature.

Steps to reproduce

# your code here
# we should be able to copy-paste this into python and exactly reproduce your bug
import proplot as pplt
import cartopy.crs as ccrs
import matplotlib.ticker as ticker
from cartopy.mpl.ticker import LongitudeFormatter, LatitudeFormatter

fig = pplt.figure(refwidth=5)

axs = fig.subplots(nrows=1, ncols=1, proj="cyl", proj_kw={"lon_0": 200}, right="3em")

axs.format(
    suptitle="Figure with NCL sytle by matplotlib",
    suptitlesize=12,
    suptitlepad=10,
    land=True,
    landcolor="k",
    coast=True,
    coastlinewidth=1,
    reso="lo",
    latlim=(-90, 90),
    lonlim=(0, 360),
    grid=False,
)


axs.set_xticks(np.arange(0, 381, 60), crs=ccrs.PlateCarree())
axs.set_yticks(np.arange(-90, 91, 30), crs=ccrs.PlateCarree())


lon_formatter = LongitudeFormatter(zero_direction_label=False)
lat_formatter = LatitudeFormatter()
axs.xaxis.set_major_formatter(lon_formatter)
axs.yaxis.set_major_formatter(lat_formatter)

axs.xaxis.set_tick_params(labelsize=10, pad=5)
axs.yaxis.set_tick_params(labelsize=10, pad=5)

axs.xaxis.set_minor_locator(ticker.IndexLocator(base=30, offset=10))
axs.yaxis.set_minor_locator(ticker.MultipleLocator(15))

axs.tick_params(
    which="major",
    direction="out",
    length=10,
    width=1.5,
    colors="k",
    top="on",
    bottom="on",
    left="on",
    right="on",
)

axs.tick_params(
    which="minor",
    direction="out",
    length=5,
    width=0.8,
    top="on",
    bottom="on",
    left="on",
    right="on",
)

axs.grid(False)

Expected behavior:
image

Proplot version

matplotlib.version = 3.2.2
proplot.version = 0.9.5

@lukelbd
Copy link
Collaborator

lukelbd commented Mar 29, 2023

Thanks for the demo / explanation. Agree this would be really useful. Looks like there's an older thread on this topic (#227), and an unmerged PR (#253) -- further discussion should go there.

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