You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add an gallery example/tutorial for interactive data visualization using Panel? #2455
I just tried it and found it sometimes useful to explore the effects of different GMT parameters (especially before we implement the movie method #1347).
importnumpyasnpimportpanelaspnimportxarrayasxrimportpygmtpn.extension()
# Make a panel widget for controlling the depth plottedaz_slider=pn.widgets.DiscreteSlider(name='Azimuth', options=list(np.arange(0, 360, 15)), value=0)
grid=pygmt.datasets.load_earth_relief(resolution="03m", region=[35, 50, 35, 45])
@pn.depends(az=az_slider)defview(az):
fig=pygmt.Figure()
pygmt.makecpt(cmap="terra", series=[-7000, 7000])
shade=pygmt.grdgradient(grid=grid, azimuth=az, normalize="e2")
fig.grdimage(
grid=grid,
shading=shade,
projection="M15c",
frame=["a4f2", f"+tazimuth={az}"],
cmap=True,
)
fig.colorbar(frame="af")
returnfigpn.Column(az_slider, view)
Here is a screencast showing how it works locally:
Screencast.from.2023-03-23.16-55-53.webm
Although the interactive widget doesn't work on our static HTML documentation, users can still copy-and-paste the codes to try it on their own Jupyter notebooks. So I think such a tutorial is still very useful.
I just tried it and found it sometimes useful to explore the effects of different GMT parameters (especially before we implement the movie method #1347).
Yep, this is a quite nice way to show or test the variation of one parameter or quantity, while the rest of the map / plot remains the same. Also tried this already based on this EGU ShortCourse example 🙂.
I would be happy to give this a try. @GenericMappingTools/pygmt-maintainers is there a parameter of a plotting method you have in mind to highlight in this example? Currently, I am wondering whether pygmt.meca is suitable (looking at dip, strike, or rake). Or should we better show a quantity which is not directly related to a PyGMT parameter, like in the EGU Short Course example?
Currently, I am wondering whether pygmt.meca is suitable (looking at dip, strike, or rake).
I'm afraid this is not a good example, because (1) three variables (strike, dip and rake) may make the example slightly more complicated (2) non-seismologists may find it hard to understand the example.
Or should we better show a quantity which is not directly related to a PyGMT parameter, like in the EGU Short Course example?
Currently, I am wondering whether pygmt.meca is suitable (looking at dip, strike, or rake).
I'm afraid this is not a good example, because (1) three variables (strike, dip and rake) may make the example slightly more complicated (2) non-seismologists may find it hard to understand the example.
Or should we better show a quantity which is not directly related to a PyGMT parameter, like in the EGU Short Course example?
Activity
yvonnefroehlich commentedon Mar 26, 2023
Yep, this is a quite nice way to show or test the variation of one parameter or quantity, while the rest of the map / plot remains the same. Also tried this already based on this EGU ShortCourse example 🙂.
seisman commentedon Apr 10, 2023
Ping @maxrjones for thoughts/comments on the potential gallery example using "Panel" before someone takes the time to work on it.
maxrjones commentedon Apr 10, 2023
Yes, I think this is a good idea. I'll be happy to provide a review.
yvonnefroehlich commentedon Apr 11, 2023
I would be happy to give this a try. @GenericMappingTools/pygmt-maintainers is there a parameter of a plotting method you have in mind to highlight in this example? Currently, I am wondering whether
pygmt.mecais suitable (looking at dip, strike, or rake). Or should we better show a quantity which is not directly related to a PyGMT parameter, like in the EGU Short Course example?seisman commentedon Apr 11, 2023
I'm afraid this is not a good example, because (1) three variables (strike, dip and rake) may make the example slightly more complicated (2) non-seismologists may find it hard to understand the example.
Some simpler examples in my mind:
yvonnefroehlich commentedon Apr 12, 2023
We probably have to add
panelas a dependency, or? Should this be done in a seperate PR?seisman commentedon Apr 12, 2023
You can add it in the same PR as the gallery example and we will see how it works.
yvonnefroehlich commentedon Apr 16, 2023
I started working on a tutorial in PR #2498 and used the first suggestion by @seisman.