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

Is that possible to fill the space between the contour lines using hachure patterns? Or use them in grdimage? #3259

Open
phalucy opened this issue May 18, 2024 · 5 comments
Labels
feature request New feature wanted

Comments

@phalucy
Copy link

phalucy commented May 18, 2024

Description of the desired feature

In many geo-related fields, we need to plot spatial distributions of composite values or trends together with their significant levels.
Many papers have those kinds of maps by showing the levels with dots/hatchure patterns.
However, I don't know there is a way to reproduce those figures with hatched significant fields in GMT.
Is there any way to plot some patterns/dots/lines over the significant values?

One potential way may be creating a grd file by replacing insignificant values with NaNs. Then, I could use grdimage to plot it using cmap, which contains hachure patterns instead of normal colors. But for now, I don't know how to do so, because hacure patterns only works when 'fill' or '-G' function is available.

By the way, the GMT example 16 (https://docs.generic-mapping-tools.org/dev/gallery/ex16.html) showed a way to use hatched cpt and grdview, but it is not 'elegent' way because we need to edit the cpt file manually. I think it could be possible to include such function inside the codes of GMT/PyGMT.

Are you willing to help implement and maintain this feature?

No

@phalucy phalucy added the feature request New feature wanted label May 18, 2024
Copy link

welcome bot commented May 18, 2024

👋 Thanks for opening your first issue here! Please make sure you filled out the template with as much detail as possible. You might also want to take a look at our contributing guidelines and code of conduct.

@phalucy phalucy changed the title Is that possible to fill hachure patterns between the contour lines? Or use them in grdimage? Is that possible to fill between the contour lines using hachure patterns? Or use them in grdimage? May 18, 2024
@phalucy phalucy changed the title Is that possible to fill between the contour lines using hachure patterns? Or use them in grdimage? Is that possible to fill the space between the contour lines using hachure patterns? Or use them in grdimage? May 18, 2024
@seisman
Copy link
Member

seisman commented May 19, 2024

Many papers have those kinds of maps by showing the levels with dots/hatchure patterns.

Can you please show some examples so that we can understand the feature request better?

@phalucy
Copy link
Author

phalucy commented May 19, 2024

Many papers have those kinds of maps by showing the levels with dots/hatchure patterns.

Can you please show some examples so that we can understand the feature request better?

Hi, thanks for reply.

Please find the example figures in the following paper: https://www.nature.com/articles/s41467-022-31676-8 (see Figs. 1-3)
I think the hatching patterns in those figures may be done by contourf function in matplotlib (https://matplotlib.org/stable/gallery/images_contours_and_fields/contourf_hatching.html) or contour effects in NCL (https://www.ncl.ucar.edu/Applications/coneff.shtml; see the example [coneff_13.ncl]).

@seisman
Copy link
Member

seisman commented May 20, 2024

It seems a nice feature but may be not easy to implement.

@yvonnefroehlich
Copy link
Member

Maybe a first step would be to allow patterns when setting up a custom colormap. Probably, this is something that has to be implemented directly in GMT.

import pygmt

# -----------------------------------------------------------------------------
# (I) cmap with colors - allowed
fig = pygmt.Figure()
fig.basemap(region=[-5, 5, -1, 1], projection="X10c/2c", frame=0)

pygmt.makecpt(cmap="lightorange,orange,red,darkred", series=[0, 4, 1])
fig.colorbar(cmap=True, position="jMC+h", frame=True)

fig.show()

# %%
# -----------------------------------------------------------------------------
# (II) cmap with pattern - not available
# GMTCLibError: Module 'makecpt' failed with status code 8:
# makecpt [ERROR]: Badly formatted color entry: +p8

fig = pygmt.Figure()
fig.basemap(region=[-5, 5, -1, 1], projection="X10c/2c", frame=0)

pygmt.makecpt(cmap="p8,p17,p15,p25", series=[0, 4, 1])
fig.colorbar(cmap=True, position="jMC+h", frame=True)

fig.show()

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

No branches or pull requests

3 participants