GenericMappingTools / gmt

The Generic Mapping Tools
https://www.generic-mapping-tools.org
Other
843 stars 352 forks source link

Unable to change the current CPT of a session #2006

Closed seisman closed 4 years ago

seisman commented 4 years ago

The issue was first reported in https://github.com/GenericMappingTools/pygmt/issues/372.

gmt begin 
gmt makecpt -Cetopo1 -T-8000/5000
gmt figure Fig1
gmt grdimage @earth_relief_20m -JH10c -Baf
gmt colorbar -Baf

gmt makecpt -Cearth -T-8000/5000
gmt figure Fig2
gmt grdimage @earth_relief_20m -JH10c -Baf
gmt colorbar -Baf
gmt end show

I thought makecpt will change the session CPT, and these two figures should use etopo1 and earth respectively. But the output figures are the same.

PaulWessel commented 4 years ago

The first makecpt sets a session CPT. The second makecpt is under Fig1 so it changes the Fig1 CPT. Then gmt figure switches to Fig 2 which has no specified CPT so it uses the session one.

Since there is no "figure end" command, once we start doing gmt figure we are never again in plain session mode. If you want figure-specific CPTs then they need to be given inside the figure environment.

I think the above is consistent, but I can understand it may be confusing which can be improved via better documentation. I dont think we want a "figure end" command. THe session is simply the fallback when you are making a single figure and it saves you from actually having to use the figure command (the gmt begin command does it for you).

seisman commented 4 years ago

You're right. We definitely don't want a "figure end" command. Closing as not a bug.

joa-quim commented 4 years ago

Not totally invalid as it exemplified an using case. But like with the Garbage man, can we warn when things were generated but not consumed?

I understand this is far from trivial to do, but live it here as an idea for cold Hawaiian winters.

PaulWessel commented 4 years ago

It is not a bad idea to warn if users create a cpt then dont use it - which probably means they screwed up. It would require us to maintain a counter somewhere (in a file).

PaulWessel commented 4 years ago

Cold Hawaiian winters?

joa-quim commented 4 years ago

Well, there is that (past) Snowball hypothesis. Who knows what future is preparing for us.

PaulWessel commented 4 years ago

Close since #2012 directly addresses the remedy.