pygmt.Figure.legend , pygmt.subplot and seaborn.heatmap

Hi Dan,

to me this sounds that you could GMT-ify your workflow a bit more by making a simple grid (using xyz2grd) from your normalised table to generate the heatmap with appropriate grid cell sizes and numbers of x/y cells, assign colours like via a cpt and then plot the table/text (your csv) using the xy info (what you currently put into the legend as numbers of rows/cols) to plot the value via text (ie partly replace stuff you are currently doing with legend).

So you would have to turn the column/row assignment in your impact_table.txt into x and y coords that you feed this to text. Instead of this

N 3 1 1 1 1 1 1 1 1 1 1 1 1 1
L 10p,Courier-New r COMBINED WAVE (M)
L 10p,Courier-New c 1.6
L 10p,Courier-New c 1.7
L 10p,Courier-New c 1.8

would look like this

4 2 1.6 # 4th column, 2nd row, the first after the COMBINED WAVE(M) text
4 3 1.7 #5th col, 3d row value
4 4 1.8

where you then specify font, justification, size etc via the pygmt.text call. Afterwards you just have to figure out where to place your legend (COMBINED WAVE (M)) - either using text or legend.

You could even get more creative using plot to plot a vector in that box to indicate directions similar to what MagicSeaweed is doing for swell directions (see plot).

Cheers,
Christian

1 Like