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
Running this shows two issues.
1- In first panel -R is auto computed but that same -R is applied to second panel
2- minor issue, the -R estimate is an exact computation, tight in Matlab parlance but that is not very nice. Compare with what is obtained with the Julia wrapper
gmt begin tales png
gmt subplot begin 2x1 -Fs8c/4c
gmt plot ds1.dat -W0.4 -Ba -c0,0
gmt plot ds2.dat -W0.5 -Ba -c1,0
gmt subplot end
gmt end show
So what should our rule be here: Clearly, in panels a data-derived -R should only apply to that panel. So I guess the same should be true for figures? If you start off with a plot call with no -R you get a -R from the data. Subsequent overlays must inherit that one of course. But a new figure should not. So I think that is a clear rule, yes?
We have both exact (your tight) and approx options for this. Not sure what the default is (your example suggests exact), but we could reconsider that.
Hi @joa-quim and @seisman: To fix this problem I am implementing the same hierarchy of gmt.history files as we do for cpts. So a panel will create its own gmt.history file, etc. but will read from a higher hierarchical level if not found. When subplot end is called I wipe all the subplot/panel histories. Nice and clean.
Then I ran the tests and had a a dozen or so failures. Have not looked at them all but looks like they are similar to this one (panels.sh) that fails:
gmt begin panels ps
gmt subplot begin 2x2 -Fs3i -M5p -A -SCb -SRl -Bwstr
gmt basemap -R0/80/0/10
gmt basemap -c
gmt basemap -c
gmt basemap -c
gmt subplot end
gmt end show
The problem, of course, is that the first panel sets its own -R and there is nothing set for the other panels. So we get no -R messages. The correct way is this:
gmt begin panels ps
gmt subplot begin 2x2 -Fs3i -M5p -A -SCb -SRl -Bwstr -R0/80/0/10
gmt basemap
gmt basemap -c
gmt basemap -c
gmt basemap -c
gmt subplot end
gmt end show
I think we must declare a bug in the first version of this since otherwise we have no recourse. Given the example above (which works fine now) we must insist on a hierarchy of region settings. So the answer is to fix the scripts. Agree?
Apart from some issue with insets (which I did not test or debug yet), the rest are like the one above, including GMT gallery examples 14 16 18. While this is annoying, I think it would be a mistake to try to maintain that broken syntax going forward, as we would effectively have to competing systems:
A panel must set its own -R if not is provided by the subplot call
A panel will inherit the previous -R from the previous panel if not set
I don't think we can have both. The only scheme I can see would be this:
If no subplot common region is set, then the region of a panel is determined by decisions in this order
A specific -R given to that panel
Determine it automatically from given data sets or grids
If none, then get the most recent panel setting if available
Failure
I am not sure how this would be implemented but perhaps there is a way.
I think if we could do this then we solve both the data-rpoblem above as well as avoid the failures I reported. THoughs?
Note this would violate the scheme we use for CPTs since we never fish a panel cpt from another panel. I think fixing the 12 failing scripts is better.
I'd like to see the same scheme for CPT, history, and even gmt.conf. A uniform scheme is easier to document, and users don't have to remember how CPT and history work differently.
It's not exactly like the cpt. For data we have the auto -R, which we do not do for cpts. But now I'm a bit confused, you say
If no subplot common region is set, then the region of a panel is determined by decisions in this order
1. A specific -R given to that panel
2. Determine it automatically from given data sets or grids
but what when a common -R is set? Will (2) automatic -R not be set? I would say it should but then what good a common -R is for?
Well, in a way yes but it's only for grids whilst the -R is for grids and data.
We also never fished cpts between figures but we always did that for -R between figures in classic mode.
I'm not saying that we should not go to the strict rule but the situation has nuances. I'm trying to imagine a situation where one would want to inherit the exact -R of a previous panel and not being allowed to do so. Accept a plain -R here (case (3))?
Cannot accept a plain -R as that is classic syntax and immediately triggers an error. We are talking about scope here for history, cpt, settings. I agree with @seisman they need to have uniform rules. In MATLAB, subplot panel 2 does not inherit the region in panel 1. It auto-scales immediately and you have to set axis if you want to have a special region. I don't know how it works in matplotlib but you guys know. Is there inheritance across panels?
I should say it will behave like a MATLAB provided you plot some data. But we have lots of places where we call basemap and then there is not data. I think if you want a common region for a bunch of panels then you set it on the subplot begin command and it stays. I am not sure if matplotlib has that feature - I dont think MATLAB does since there is no master-subplot command.
I like the idea of doing this for gmt.conf as well. So a gmt set for a subplot panel only applies to that panel, while one set before subplot applies to all of them.
The way a gmt.conf hierarchy would work is similar to the cpt: If, at a particular hierarchical level, there is a gmt.conf (e.g., gmt.conf.0.panel.0-1 then we read that, else we read the one higher up, all the way up to the session. When gmt.conf is written (due to a gmt set command) it shall write at its hierarchical level. So inside subplots, gmt set calls should not contaminate the whole figure. This would make the conf, history, and cpt consistent and follow the same rules, even if we have to claim we have "buts" and hence not implementing backwards compatible solutions for these mistakes. I think this is your view as well, @seisman?
Also need to point out that there would no longer be a gmt.history file since you cannot create a history without it being for a particular figure, so gmt.history.0 is the highest practical level of actual files. But there can be session-level gmt.conf and gmt.cpt since the commands that create them do not start a figure.
Activity
PaulWessel commentedon Jun 22, 2020
So what should our rule be here: Clearly, in panels a data-derived -R should only apply to that panel. So I guess the same should be true for figures? If you start off with a plot call with no -R you get a -R from the data. Subsequent overlays must inherit that one of course. But a new figure should not. So I think that is a clear rule, yes?
We have both exact (your tight) and approx options for this. Not sure what the default is (your example suggests exact), but we could reconsider that.
joa-quim commentedon Jun 22, 2020
Yes, each figure should get its own -R.
Approx -R looks nicer then tight.
And that title font also looks too heavy
PaulWessel commentedon Jun 22, 2020
Seems like the approx R should go with datasets and the exact R goes with grids , unless the user uses -R
joa-quim commentedon Jun 22, 2020
Agreed.
PaulWessel commentedon Jun 23, 2020
Hi @joa-quim and @seisman: To fix this problem I am implementing the same hierarchy of gmt.history files as we do for cpts. So a panel will create its own gmt.history file, etc. but will read from a higher hierarchical level if not found. When
subplot endis called I wipe all the subplot/panel histories. Nice and clean.Then I ran the tests and had a a dozen or so failures. Have not looked at them all but looks like they are similar to this one (panels.sh) that fails:
The problem, of course, is that the first panel sets its own -R and there is nothing set for the other panels. So we get no -R messages. The correct way is this:
I think we must declare a bug in the first version of this since otherwise we have no recourse. Given the example above (which works fine now) we must insist on a hierarchy of region settings. So the answer is to fix the scripts. Agree?
joa-quim commentedon Jun 23, 2020
Yes, seems right to apply the same logic.
seisman commentedon Jun 23, 2020
Yes, it makes more sense to me. I think we need to add a section in the cookbook explain how the history, cpt and gmt.conf work in modern mode.
PaulWessel commentedon Jun 23, 2020
Apart from some issue with insets (which I did not test or debug yet), the rest are like the one above, including GMT gallery examples 14 16 18. While this is annoying, I think it would be a mistake to try to maintain that broken syntax going forward, as we would effectively have to competing systems:
I don't think we can have both. The only scheme I can see would be this:
If no subplot common region is set, then the region of a panel is determined by decisions in this order
I am not sure how this would be implemented but perhaps there is a way.
I think if we could do this then we solve both the data-rpoblem above as well as avoid the failures I reported. THoughs?
PaulWessel commentedon Jun 23, 2020
Note this would violate the scheme we use for CPTs since we never fish a panel cpt from another panel. I think fixing the 12 failing scripts is better.
seisman commentedon Jun 23, 2020
I'd like to see the same scheme for CPT, history, and even gmt.conf. A uniform scheme is easier to document, and users don't have to remember how CPT and history work differently.
joa-quim commentedon Jun 23, 2020
It's not exactly like the cpt. For data we have the auto -R, which we do not do for cpts. But now I'm a bit confused, you say
but what when a common -R is set? Will (2) automatic -R not be set? I would say it should but then what good a common -R is for?
seisman commentedon Jun 23, 2020
We have default cpt, geo for earth relief and turbo for all other grids, just like the auto -R, right?
joa-quim commentedon Jun 23, 2020
Well, in a way yes but it's only for grids whilst the -R is for grids and data.
We also never fished cpts between figures but we always did that for -R between figures in classic mode.
I'm not saying that we should not go to the strict rule but the situation has nuances. I'm trying to imagine a situation where one would want to inherit the exact -R of a previous panel and not being allowed to do so. Accept a plain -R here (case (3))?
PaulWessel commentedon Jun 23, 2020
Cannot accept a plain -R as that is classic syntax and immediately triggers an error. We are talking about scope here for history, cpt, settings. I agree with @seisman they need to have uniform rules. In MATLAB, subplot panel 2 does not inherit the region in panel 1. It auto-scales immediately and you have to set axis if you want to have a special region. I don't know how it works in matplotlib but you guys know. Is there inheritance across panels?
PaulWessel commentedon Jun 23, 2020
I should say it will behave like a MATLAB provided you plot some data. But we have lots of places where we call basemap and then there is not data. I think if you want a common region for a bunch of panels then you set it on the subplot begin command and it stays. I am not sure if matplotlib has that feature - I dont think MATLAB does since there is no master-subplot command.
joa-quim commentedon Jun 23, 2020
I know almost nothing of mapplotlib but one thing I know is that in one of its modes it imitates closely the Matlab syntax.
PaulWessel commentedon Jun 23, 2020
And MATLAB expects to plot something (there is no basemap) except axis. So when you say subplot (r,c,p) you get a basemap from 0/1/0/1 and then you must change that by plotting or using axis. I know of no way to set up an axis call to make all the subplot have the same range. From MATLAB central it is painful to see: https://www.mathworks.com/matlabcentral/answers/412592-set-same-xlim-for-all-subplots
PaulWessel commentedon Jun 23, 2020
I like the idea of doing this for gmt.conf as well. So a gmt set for a subplot panel only applies to that panel, while one set before subplot applies to all of them.
PaulWessel commentedon Jun 23, 2020
The way a gmt.conf hierarchy would work is similar to the cpt: If, at a particular hierarchical level, there is a gmt.conf (e.g., gmt.conf.0.panel.0-1 then we read that, else we read the one higher up, all the way up to the session. When gmt.conf is written (due to a gmt set command) it shall write at its hierarchical level. So inside subplots, gmt set calls should not contaminate the whole figure. This would make the conf, history, and cpt consistent and follow the same rules, even if we have to claim we have "buts" and hence not implementing backwards compatible solutions for these mistakes. I think this is your view as well, @seisman?
seisman commentedon Jun 23, 2020
Yes.
PaulWessel commentedon Jun 23, 2020
Also need to point out that there would no longer be a gmt.history file since you cannot create a history without it being for a particular figure, so gmt.history.0 is the highest practical level of actual files. But there can be session-level gmt.conf and gmt.cpt since the commands that create them do not start a figure.
seisman commentedon Jun 23, 2020
I thought some non-plotting commands also write to gmt.history. Does
grdcutwrites to history? Is it a session-level history?PaulWessel commentedon Jun 23, 2020
Yes, I think you are right. OK, that is fine. I will do all the levels anyway.
PaulWessel commentedon Jun 27, 2020
The script below works, showing that the grdcut command sets a (grid) region that is picked up by the plot command:
So we can close this issue I think? Can move the grdcut inside the figure, no difference.
seisman commentedon Jun 27, 2020
Yes to me.