How to plot a high-resolution heatmap?

Hey, I am trying to visualize a matrix with grdimage. What I would like the figure to look like is this:

They key feature being that each entry of the 25x25 matrix is clearly visible.

When I tried this with GMT, using the following:

gmt makecpt -CgrayC -T0/80/1 > custom.cpt
gmt grdimage data/coupling_coeffs.nc -R1/25/1/25 -JX5i/-5i -Y5i -K -Ccustom.cpt >$ps

I got some thing like this:

I think the data is being read correctly, but GMT smears the data so it doesn’t look as discreet as what I want it to be.

I looked at the “-E” option but it seems like by default it uses the 25x25 resolution the data provides and what it really does is to smear the data more?

Please let me know if it’s possible to create something like the first picture using GMT. Thanks!

Hi axelwang

I think it should be possible to do that. Could you share a dataset to test your issue?

If you are working on a mac, I think that it might be this (grdimage — GMT 6.5.0 documentation).

You are 100% correct. Thanks for pointing this out!
I am working on a mac. When I opened it in Adobe Acrobat, it looks like this:

However, I think this is still somewhat sampled different than what I want it to be. Looking at the corners and edges, we have half or a quarter of a square, whereas what I really want is a 25x25 matrix with each entry being represented by a full colored square.

You need to check and change your grid registration.

Thanks. Could you provide me some further directions on how to change this? I googled around and looked at the options of “grdimage” but didn’t find anything useful. Thanks.

You can find info here about the registration: 4. Standardized command line options — GMT 6.6.0 documentation

For your issue, you could remove this (-R1/25/1/25) from your command. I think it might work.

gmt grdimage data/coupling_coeffs.nc -JX5i/-5i -Y5i -K -Ccustom.cpt >$ps