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
I'm unsure if "stateful" is the appropriate word here. What I really mean is to let PyGMT keep track of its stats and some information, then later PyGMT calls can know what already happened.
I think the "stats" can be useful in many cases. Here are some quick ideas. Let's say we have a dict pygmt.__stats__ for PyGMT and a dict fig.__stats__ for each Figure instance, which can store anything we want. The variable names have double underscores so they are for internal use only, but it's also possible to make them public to users.
pygmt.__stats__.call_history can be a list of commands that are passed to the GMT API via call_module. The list can be used to generate the equivalent bash script, although we can't handle virtual files and any other Python data structures.
fig.__stats__.projection: the projection of the current figure
fig.__stats__.dimensions: width and height of the current figure/frame/subplot/inset. Users can access these values via public functions, and then can do some mathematic calculates (e.g., to have an inset map with a width of 0.25 * w or shift the plot origin by 1.2 * w (w is the width of current figure stored in fig.__stats__.dimensions)).
I believe there are more interesting ideas about a stateful PyGMT, so thoughts and comments are welcomed.
Activity
willschlitzer commentedon May 4, 2023
I think this is a good idea.