Closed zhen-dong-zhang closed 3 years ago
👋 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.
It's not included in PyGMT yet but your request sounds similar to GMT's wiggle module. Can you take a look at the documentation for wiggle and let us know if this suites your request? If so, we can convert this into a feature request for a wiggle method in PyGMT. Here's the output from an example in the GMT docs:
Hi Meghan, Thanks a lot for your reply. Yes, it is wiggle plotting, which is very popular in exploration geophysics. I have implemented it by using matplot. But it would be helpful if pygmt can have this function. Best Regards, Zhendong
Hi Zhendong, I am glad you found a way to make the plot and agree that this would be a nice function to have in PyGMT! We'll keep the issue open and I will add the GMT module name to the title of your GitHub issue so that developers can find it easier to work on. Best regards, Meghan
Hi Meghan, Thank you for taking the time and effort in adding the module. I'm looking forward to it. Best Regards, Zhendong
@zhen-dong-zhang you could still use wiggle in PyGMT even though we have wrapped it. See an example below modified from Examples
GMT command line:
gmt math -T-8/6/0.01 -N3/0 -C2 T 3 DIV 2 POW NEG EXP T PI 2 MUL MUL COS MUL 50 MUL = | gmt wiggle -R-10/10/-1/1 -JX15c -BWSne -Bxa2f1 -Bya0.5 -Z10c -DjRM+w100+lnT -T0.5p -Gred+p+n -W0.5p -pdf map
PyGMT call_module
method:
import pygmt
from pygmt.clib import Session
import numpy as np
# Create (x, y, z) which is equal to the gmt math above
x = np.arange(-8, 7, 0.1)
y = np.zeros(x.size)
z = 50 * np.exp(-(x/3)**2) * np.cos(2*np.pi*x)
fig = pygmt.Figure()
fig.basemap(region=[-10, 10, -1, 1], projection="X15c", frame=["WSne", "xa2f1", "ya0.5"])
with pygmt.helpers.GMTTempFile() as temp_file:
np.savetxt(temp_file.name, np.column_stack((x, y, z)))
with Session() as session:
session.call_module("wiggle", "{} -Z10c -DjRM+w100+lnT -T0.5p -Gred+p+n -W0.5p".format(temp_file.name))
fig.show()
BTW, I am going to wrap wiggle
next week if no other contributors try it during these 2-3 days.
Hi, I'm new to pygmt and wondering how to fill the positive areas in plotting? Please find the figure below for more information: Thanks for your attention. Best Regards, Zhendong