altmany / export_fig

A MATLAB toolbox for exporting publication quality figures
BSD 3-Clause "New" or "Revised" License
1.27k stars 365 forks source link

Colormap seems to be ignored for surf #391

Closed Stknx closed 3 months ago

Stknx commented 3 months ago

I'm trying to export some surface plots I'm making with a custom colormap but noticed that the surfaces were being plotted with the default colormap rather than the specified colormap. Ran a few checks and this even extends to the basic swapping of colormaps to another of the defaults. E.g the following

surf(peaks)
colormap("hot")
export_fig 'colortest.png'

gives colortest.png colortest rather than colortest_desired.png (desired made by a copy and paste job) colortest_desired

Any thoughts? I tried playing with the renderer and no immediate luck there.

altmany commented 3 months ago

I cannot reproduce - it runs ok on my system when I run your code in the Matlab console. Perhaps you try to run it in a Live Editor script? without additional information about your run-time environment I cannot assist

altmany commented 3 months ago

You can also try to add a call to drawnow before you call export_fig, to ensure that the colormap is updated prior to export.

Stknx commented 3 months ago

Thanks for this - it was because I was in Live Editor scripts (for both example and original problem). Ran as standalone script and all fine. Much appreciated.