I recently switched to modern mode, and I’d like to open a discussion on how to improve coding efficiency and readability.
For example, I found the way subplot handles figure’s dimension very confusing. The feature is nice but it is complicated to get it right.
First about the formalism. True it is flexible, but IMO the documentation is short on explanations and motivations behind all the possibilities :
### Single plot simple gmt [...] ### Single plot simple V2 : in gmt session gmt begin (name) (format) [...] gmt end ### Single plot V3 : can extend to multiple figures in same gmt-session gmt begin gmt figure (name) (format) [...] no "begin" / no "end" ? gmt end ### Subplot cleaner gmt begin gmt figure gmt begin subplot -Ff / -Fs (...) gmt subplot set [...] no "begin" / no "end" gmt subplot end gmt end ### Subplot dirtier gmt begin gmt figure gmt begin subplot -Ff / -Fs (...) [...] -c(row,col) gmt subplot end gmt end
As you can see, all roads lead to … confusion if you’re starting without a map (see what I did there? ).
Well, I guess each individual has some sort of habits when it comes to code… or pretty much anything, but while it’s not forbidden to drive on the left lane, a clear traffic regulation would help (see? I did it again … ok I stop with this lame spinning metaphor ).
The way it works is pretty straightforward and clearly it has been thought for efficiency and plethora of information can be found in the documentation. Still, what’s going on with
-C option ?
Am I the only one to just always use :
gmt makecpt [...] -H > mycpt.cpt
grdimage doesn’t require it ? Can we do like in fortran : IMPLICITE_NONE ? (I might have lost some people here, I’m sorry).
My point is, back to the habits, it’s difficult to become efficient when rules change all the time.
Subplot and figure dimensions, my nemesis. It is actually an experience from last week (as well as this discussion about subplot frame on github that motivated me to rant here).
To cut it short, I plotted 3 figures (x 6 subfigures) in the same gmt-session. Very compact, the advertisement didn’t lie.
subplot -Fs, my laptop was making noise like a 747 and everything was fine
The problem was some labels on the colorbar. If the text was long, the subplot on the right hand side would make the whole figure wider. Inconsistency + OCD = rant.
So I tried
subplot -Ff and let gmt handle the subplot size (maybe related to a reported bug? I don’t know).
But all of a sudden the
grdimage had unexplained offsets. I was tired and just resorted to go back to
-Fs and remove the labels.
Finally, the frame. IMPLICIT_NONE. The intertwining of
-B options and labels is magical when everything’s fine, but can be frustrating when it’s not (at least in subplot environnement).
Do people have problem with overlapping frames, redundant automatic annotations (or even plot shift like my
-Ff above) ?
What can be done to improve and/or promote efficiency, readability and develop a code of good practice ?