Gridlines and annotations but no borders?

I’m trying to plot gridlines and the corresponding annotations but I want no borders. Something like this:

All I currently get is this:

As soon as I specify annotations I get a border. If I use -Bg2.5 I get my gridlines but also some artifacts which look like something of a fancy border on the N and S borders.

I have the feeling I’m looking at the wrong doc pages. There certainly is a way to achieve this. Would you kindly point me in the right direction?

Command used:

gmt coast -W -RDE+R10m -JL10.5/51/49/53/17c -Bg2.5 -B+t"Federal Republic of Germany" -N1/1p,darkred -Saliceblue -pdf mapDE --GMT_THEME=modern

GMT version:


Your -B+t turns on the frame but you can turn it off by adding +n.

Hi Paul, thank you – this indeed removes the border remains on N and S sides of the plot. But how do I get annotations? -Ba turns on the borders again?

There is no mechanism to plot annotations without the frame, currently. We would have to add a flag for that, and it should be doable without too much fuss for geographic maps. For Cartesian plots all the axis plotting is done by a single function so there things are more complicated. There may also be some general complications related to offset calculations based on the width of the frame as well (which in your case is zero. I am guessing a new +N modifier could mean "do not draw the frame but otherwise annotated, tick, and draw gridlines as requested.

Ok, I’m somewhat relieved, that I didn’t miss it in the docs. The whole -B option seems very powerful but rather complicated to me. Adding +n to the plot title to switch off borders is not very intuitive for me. Might be a language problem on my side. +N seems to be an easy solution (backwards compatible).

Maybe – on a broader scale – it is an idea to think about to have

  • border
  • grid
  • annotations

separated and defined independently from each other? I have the feeling this might be more work than this problem warrants in the end.

Making those changes takes us into backwards incompatibility. Most GMT users expect those frames without asking for them, so we had to add +n to actually not plot them. Now with your special case there is the need to plot annotations but not the frames themselves, so this is evolving.

Point taken. So you think of something like -Ba1+n similar to the -B+t"PlotTitle"+n ?

No, the -Ba axis option does not take +n; this is a frame issue, so it would be -B+t"PlotTitle"+N I assume.

Mh, but when I don’t use -B+t and only use -Ba I get borders none the less? How am I supposed to switch off the borders in this case?

Yes, the -B option has two flavors. One is dealing with frame issues and one is dealing with axes issues. We have chosen to let the frame version (-BWESn…) deal with options like +o, +g +n +b etc. so they are not available for an axis setting.

I’ve also crossed with this issue a couple times recently. My workaround in Julia was to plot the axes with 0 thickness, which oddly still plots a line, and full transparent (to get rid of the 0th thick line)

Hi @Joaquim – this is a nice idea. The “zero width is not invisible” problem haunted me as well when experimenting with unusual pen designs for polygon lines. Maybe you remember.

I found this in the CookBook:

Minimum-thickness pens can be achieved by giving zero width. The result is device-dependent but typically means that as you zoom in on the feature in a display, the line thickness stays at the minimum.

@pwessel my apologies but I think I don’t understand your point. Would you kindly explain once again: What would be your proposed way to switch off borders if I just want grid lines and annotations (no plot title or similar)?

I understand so far that -Ba is an axis thing which, among other things, deals with the annotations. But it switches on borders as well?

gmt coast -W -RDE+R10m -JL10.5/51/49/53/17c -Ba -N1/1p,darkred -Saliceblue -pdf mapDE

gives me

and that’s -Ba without anything else?

Maybe I would be more precise by saying that -Ba switches on frames.

If you look at the -B documentation you will see the frame vs axis settings. But yes, because frames and annotations/ticks have always been implicitly coupled, you never had to add -BWESN to draw the frames if you just did -Ba. I do not think we can break that and force people to add some flag to get frames with their annotations since I think the vast majority of users expect both. Thus, we need to tell GMT to not draw the frame even though you want annotations, gridlines, etc. That is not currently possible, but it clearly is a frame setting in my mind (+n is a frame setting, as is WESNwesnlrbtzZ, +b +g, etc.). So that is why I think +N is required.

@pwessel, thank you for taking the time for explaining it to me, again. Now I understand it.

My idea was not to break the current function but to have a third way to specify all this. More of a modular concept. Crude idea:

-BG for grid lines (-BpG and -BsG being also possible)
-BF for frames (primary and secondary similar to above)
-BA for annotations/ticks (primary and secondary similar to above)

The basic rule is rather simple: What isn’t specified isn’t plotted.

But I understand that this will make a rather complex -B option even more complex … The user didn’t read the docs and start mixing legacy and new stuff and strange things happen. I’m guilty of this as well. +N gets more and more attractive. I should listen more to the father of GMT :wink:

No worries, Kristoff. I would like to tear down many things in GMT that is legacy but have usually been stopped by my co-developers. Such as module names, options, and more. As you might be aware, the entire +modifier system only started a handful of years ago since too many options were like -Xarg1/arg2[/arg3] etc so to set arg3 you had to set arg1 and arg2 as well, even if you did not really want them. So GMT syntax continues to change. -B changed a lot for GMT 5, and will probably evolve as we go forward, and when long-option-syntax hits us then it will be simpler to understand as well.

As a heavy user of classic mode (for being able to “recycle” layers, a unique feature of GMT) I appreciate your not tearing everything down, @pwessel. I can live with adapting to new syntax and module names and stuff but every users needs are different.

I took the liberty and wrote a feature request for +N over at GitHub.