Mixing PyGMT and matplotlib

Is there a way to put a matplotlib axis next to a pyGMT map? For example in a 2-column setup with the matplotlib plot on the left and pyGMT map on the right. I can imagine that I could generate the matplotlib figure, export it as an eps and then dump it into a pyGMT subplot (or shift x and y) with the “image” command, but that seems a little kludgy. Yes, I could also re-write the matplotlib function using pyGMT commands, but I’d rather not. I’ve also looked at putting a pyGMT figure into a matplotlib subfigure but that doesn’t seem to work either.

Should I give up this dream or is there something I’m missing?


Probably :slight_smile:

GMT produces postscript. Matplotlib can export it’s final figure in postscript but I don’t even know if it’s a raster postscript or a true vector ps. So only chance from the GMT perspective is to import an external image (be it whatever kind Matplotlib exports).

1 Like