Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement GMT themes (sets of GMT defaults) #3344

Merged
merged 206 commits into from
Mar 12, 2021
Merged

Implement GMT themes (sets of GMT defaults) #3344

merged 206 commits into from
Mar 12, 2021

Conversation

PaulWessel
Copy link
Member

@PaulWessel PaulWessel commented May 17, 2020

Description of proposed changes

This PR follows up on #2290 and adds the new GMT defaults parameter GMT_THEME. A theme is simply a collection of GMT default parameter settings that make sense together and have been given a suitable name. GMT comes with a few built-in themes:

  • classic: The basic GMT defaults as distributed
  • modern: Currently same as classic (but see Themes for default settings #2290 for ideas)
  • inverse: White pen/fonts on black background
  • darkmode: Light-gray pens/fonts on very dark-blue background

The last two are of course experimental, and to implement modern (#2290) requires new coding as well. Users can add their own themes as theme.conf files in ~/.gmt.

The theme machinery has been implemented and working. For instance,

gmt coast -W -RFR -B -pdf map1 --GMT_THEME=inverse
gmt coast -W -RIS -B -Gturquoise -pdf map1 --GMT_THEME=darkmode

Remaking tasks:

  1. Better define a cool darkmode set of parameters
  2. Implement the font and dimensions scalings discussed in Themes for default settings #2290.

doc/rst/source/gmt.conf.rst Outdated Show resolved Hide resolved
share/themes/darkmode.conf Outdated Show resolved Hide resolved
@PaulWessel
Copy link
Member Author

PaulWessel commented May 17, 2020

Time for some discussion on the themes. I will focus on modern here, and I am doing it via a modern.conf for now. It has the settings below: Note: All of this is open for discussion - I do not consider any of these choices final:

# FONT Parameters
#
FONT_ANNOT_PRIMARY             = 10p,Palatino-Bold,black
FONT_ANNOT_SECONDARY           = 12p,Palatino-Roman,black
FONT_HEADING                   = 28p,Palatino-Bold,black
FONT_LABEL                     = 14p,Palatino-Bold,black
FONT_LOGO                      = 8p,Helvetica,black
FONT_TAG                       = 18p,Palatino-Roman,black
FONT_TITLE                     = 22p,Palatino-Bold,black
#
# FORMAT Parameters
#
FORMAT_GEO_MAP                 = ddd:mm:ssF
#
# MAP Parameters
#
MAP_ANNOT_ORTHO                = we
MAP_FRAME_AXES                 = WeSnZ
MAP_ANNOT_OFFSET_PRIMARY       = 4p
MAP_ANNOT_OFFSET_SECONDARY     = 4p
MAP_FRAME_PEN                  = thicker,black
MAP_FRAME_TYPE                 = fancy
MAP_FRAME_WIDTH                = 3p
MAP_GRID_PEN_PRIMARY           = default,gray
MAP_GRID_PEN_SECONDARY         = thinner,gray
MAP_HEADING_OFFSET             = 16p
MAP_LABEL_OFFSET               = 6p
MAP_TITLE_OFFSET               = 12p
MAP_VECTOR_SHAPE               = 0.5
#
# PostScript Parameters
#
PS_LINE_CAP                    = round

The reasoning behind these are as follows:

  1. We should shake up a few things just so it is noticeable. The change of annotation font falls in that category.
  2. The font choices and offsets are a bit ~10-15% smaller. For pretty much all plots destined for a paper our fonts are too big. I will give examples below.
  3. The ancient WESN default for all sides drawn and annotated is wasteful.
  4. I think maps should have W-E-S-N indicators on them
  5. Those arrows should always have a nonzero shape. 0 is lame.
  6. The map frame for fancy is way to thick, especially for most normal-sized maps.

Most figures in a paper will fit in a 1-column formatting. Those are something like 8.5 cm wide. Attached is a 8.5 cm pscoast map, first from classic and second with modern:

gmt coast -W -RFR -B -JM8.5c -N1/1p,darkred -Glavender -png mapc --GMT_THEME=classic

mapc

I can't tell you how many maps like this I have seen in Nature or Science, with their obese map frames. Now, with the modern theme:

gmt coast -W -RFR -B -JM8.5c -N1/1p,darkred -Glavender -png mapm --GMT_THEME=modern

mapm

I like that the frame and annotations are smaller, and that the ticks are showing. But what happens if I make a plain map:

gmt coast -W -RFR -B -JM8.5c -N1/1p,darkred -Glavender -png mapmp --GMT_THEME=modern --MAP_FRAME_TYPE=plain

mapmp

What I see is that those ticks that worked well with the fancy is way too long for the plain. This is obvious because the lengths are measured from the inside frame and thus they only stick out 2 points with the fancy frame but the full 5 points for plain (minus half the pen width). Since we dont really want to have two settings for tick lengths (fancy vs plain) I think we need to change this to be measured from the outside of the frame, i.e., we subtract the fancy width from the tick length when plain.
Another issue is maps versus plots. For a similar Cartesian plot, see this:

gmt basemap -R0/80/0/25 -B -JX8.5c -png mapc --GMT_THEME=modern

mapc

This shares the too-long ticks with the plain map, plus I think it is unseemly with all those ticks on the right and top side. It seems better without anything (plain WS):

gmt basemap -R0/80/0/25 -B -JX8.5c -png mapc --GMT_THEME=modern --MAP_FRAME_AXES=WS

mapc

or with just lines (which is new in GMT 6)

gmt basemap -R0/80/0/25 -B -JX8.5c -png mapc --GMT_THEME=modern --MAP_FRAME_AXES=WSrt

mapc

It may be that geo and cart should not have the same default MAP_FRAME_AXES. I am also interested in adding a default for canvas color (inside map frame). MAP_CANVAS_COLOR = none in classic but could be set to something slightly less white in modern.
I will stop here and take comments. I have a feeing @KristofKoch might be interested in themes.

@PaulWessel
Copy link
Member Author

Still too much space around the Cartesian plot I think, and frame is too thick. Maybe

gmt basemap -R0/80/0/25 -B -JX8.5c -png mapc --GMT_THEME=modern --MAP_FRAME_AXES=WSrt --MAP_TICK_LENGTH_PRIMARY=3.5p/2p --MAP_FRAME_PEN=thick --MAP_ANNOT_OFFSET_PRIMARY=3p

mapc

@joa-quim
Copy link
Member

OK, some comments.

  1. The axes thickness in plain maps and plots is too thick.
  2. I like it that plots have WSlt. I.e no ticks or annotations n right and top (that's what I do in Julia)
  3. Tick marks on plain are not centered on the black-white transition (or the other way arround probably).
  4. Annotations in bold make them too heavy.

Still on annotations size. Specially with modern mode cropping out the white areas and automatic display, small figures get displayed on screens with a kind of automatic zoom and for small figures the labels really look too big. Having their size scaled to fig size is really important.

@KristofKoch
Copy link
Contributor

As @PaulWessel said I'm interested in something like this. currently I'm helping myself with config pages which I include in my scripts. In my eyes @joa-quim has a point with the scaling of the annotations depending on plot size. And I support Paul's idea of different styles for geographic and cartesian plots.

There are several different use-cases. You guys currently seem to think only about illustrations in papers/journals. I'm coming from the navigational chart corner where media size is given and reading conditions are usually bad with low light intensity and monochromatic color by night and harsh contrasts/shadows by day. So for me it's more sans-serif fonts. But as I understand it everything from gmt.conf can be configured in theme.conf so I'm happy. NASA has a nice technical report about typography on the flight deck.

Using a serif font in modern.conf is funny in my eyes. I would expect a sleek, clean sans-serif design. Maybe I'm biased but I'd prefer something like this:

mapAvantGarde

gmt coast -W -RDE -JL10.5/51/49/53/8.5c -B -B+t"Federal Republic of Germany" \
  -N1/1p,darkred -Saliceblue -png mapAvantGarde \
  --GMT_THEME=modern \
  --FONT_ANNOT_PRIMARY=8p,AvantGarde-Book,black \
  --FONT_TITLE=16p,AvantGarde-Demi,black \
  --MAP_FRAME_AXES=WSEN \
  --MAP_TICK_LENGTH_PRIMARY=3p/2p \
  --MAP_FRAME_PEN=thin \
  --MAP_ANNOT_OFFSET_PRIMARY=2p \
  --MAP_FRAME_TYPE=plain

over this

mapDefault

gmt coast -W -RDE -JL10.5/51/49/53/8.5c -B -B+t"Federal Republic of Germany" \
  -N1/1p,darkred -Saliceblue -png mapDefault \
  --GMT_THEME=modern

In my eyes the current version (4551f91) of modern.conf looks somewhat old school. But that's coming from someone who doesn't publish in journals.

@PaulWessel
Copy link
Member Author

Great, AvantGarde was actually my first choice (!) but then I regressed. I have updated modern.conf with that choice in this branch. And not bold.
@joa-quim, I did not understand your comment about tick centering, can you elaborate?
For axes, do we introduce PLOT_FRAME_AXES to complement MAP_FRAME_AXES, and possibly other PLOT_* settings to enable different sets of defaults for maps and plots? I think having something like

MAP_FRAME_AXES = WEsnZ,WSrtZ

is a bit unclear and messy.
Regarding old-school: The whole black/white checkerboard frame is old-school; I first coded that up in 1987. Perhaps modern.conf should simply have MAP_FRAME_TYPE=plain as the default?

@PaulWessel
Copy link
Member Author

Would be good to hear from @leouieda and @remkos on this as well.

@PaulWessel
Copy link
Member Author

Regarding automatic sizing, pretty much anything related to a plot should depend on size. But we need to be able to switch between auto and fixed, I think. It should be possible to get a 10 point font for annotations without guessing what the map width should be. So we need an overarching setting, maybe PLOT_SCALING = auto|manual. auto in modern and manual in classic?

@joa-quim
Copy link
Member

The auto-scaling is needed in classical too.
But regarding the ticks, it's tricky. Sometimes they look centered, others not. An example of a non-centered tick

image

@PaulWessel
Copy link
Member Author

auto-scaling will be available in classic but it wont be active by default. classic.conf will retain current defaults.

@PaulWessel
Copy link
Member Author

A little bit trial and error suggest a draft equation for font size in points as function of map size (in cm):

fontsize = (2/15)*(mapsize-10) + 8

this gives 8p for a 10 cm map, 10p for a 25cm map, and 20p for a 1meter map. Would also need to apply to offsets, ticklenghs, pen thicknesses, other fontsizes for titles, labels, etc. Not sure if map size should be measured as max dimension or sqrt(area).

@PaulWessel
Copy link
Member Author

It is also a bit unfortunate that we are using MAP_ for a lot of parameters that are not specific to maps, but plots in general. A Cartesian x-y plot is not a MAP, yet MAP_GRID_CROSS_SIZE_PRIMARY controls its behavior just as well. Maybe it is time to start a whole new group called PLOT_.

@KristofKoch
Copy link
Contributor

@PaulWessel wrote:

It should be possible to get a 10 point font for annotations without guessing what the map width should be.

Definitely! Otherwise I will get crazy …

After thinking about the auto-mode a bit more I asked myself who will benefit from it. In my eyes it is only useful for

  • new users who want to see quick, appealing results
  • the lazy power user who needs a quick plot for something without caring too much about the design

As soon as you go the publication route (paper/journal/charts) there most certainly are strict design and layout rules to follow.

Maybe this could be a niche to shine so you can claim: "GMT offers themes to comply with design rules for journal XY – just use journalXY.conf in your command"

@PaulWessel
Copy link
Member Author

Good points. I can see that making modern with auto the default for modern mode may be going too far since people who know what they want have to make changes all the time. I will keep this open. There are some journal guidelines, mostly on minimum font sizes, but there is probably a lot of variability. We should also allow for the fact that other people will likely create better design conf files that we can, so if we publicize this then people could contribute themes. I will retreat a bit to work on the scaling laws; this will be available to both modern and classic, and come up with some proposals.

@KristofKoch
Copy link
Contributor

Just for good measure my above example with the Helvetica font which is close to the classic version:

mapHelvetica

gmt coast -W -RDE -JL10.5/51/49/53/8.5c -B -B+t"Federal Republic of Germany" \
  -N1/1p,darkred -Saliceblue -png mapHelvetica \
  --GMT_THEME=modern \
  --FONT_ANNOT_PRIMARY=8p,Helvetica,black \
  --FONT_TITLE=16p,Helvetica-Bold,black \
  --MAP_FRAME_AXES=WSEN \
  --MAP_TICK_LENGTH_PRIMARY=3p/2p \
  --MAP_FRAME_PEN=thin \
  --MAP_ANNOT_OFFSET_PRIMARY=2p \
  --MAP_FRAME_TYPE=plain

Unfortunately not everybody has the Futura font-family available which might be another good option for the font (sleeker/similar to AvantGarde) and I like the "R" more.

Why not bold for the title? Too … bold?

@joa-quim
Copy link
Member

Don't know if I prefer this font for annotations but what I clearly prefer is that it's not bold. The Bold title looks good and way shorter.

Did not mention in the other comment. I prefer the WSen axes to the WSEN, which is too wasteful as Paul put it.

@PaulWessel
Copy link
Member Author

OK, so we have some agreements. Given the relatively short list of standard PostScript fonts I think AvantGarde-Book is the best we can do. I also prefer bold in the title (and HEADING, which is master title for a bunch of subplots) but no bold on labels and the two levels of annotations.

Both differ from origs but are good. Origs updated.
@PaulWessel PaulWessel merged commit f1c04a9 into master Mar 12, 2021
@PaulWessel PaulWessel deleted the gmt-themes branch March 12, 2021 02:38
@PaulWessel
Copy link
Member Author

Giant gmt-themes branch merged!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants