Error in using "shading interp" with logarithmic colorscale

I want to do a shading interp to my plot. It works fine when I use linear(default) colorscale, but when I set the colorscale to "log", the plot on that ax disappeared.
  • do shading interp earlier
ax2 = axes;
m_proj('miller','long',[lon1 lon2],'lat',[lat1 lat2]); %m_proj is function from m_map package
m_pcolor(X,Y,delta_p); % from m_map package
shading interp;
m_grid('linest','none','tickdir','out','box','fancy','fontsize',10); % from m_map package
axis equal; % "merge" the plots on ax1 and ax2
set(ax2,'ColorScale','log');
% >>Warning: Error creating or updating Surface
% Error in value of property <a
% href="matlab:helpUtils.reference.showPropertyHelp('matlab.graphics.primitive.Surface','CData');")">CData</a>
% DataSpace or ColorSpace transform method failed
Then the plot on ax2 disappeared
  • do shading interp later
ax2 = axes;
m_proj('miller','long',[lon1 lon2],'lat',[lat1 lat2]);
m_pcolor(X,Y,delta_p);
m_grid('linest','none','tickdir','out','box','fancy','fontsize',10);
axis equal;
shading interp;
%>> Warning: Error creating or updating Patch
%Error in value of property <a
%href="matlab:helpUtils.reference.showPropertyHelp('matlab.graphics.primitive.Patch','FaceVertexCData');")">FaceVertexCData</a>
% Number of colors must equal number of vertices
%%%%%% This warning appears 5 times. Despite of this warning, shading interp still works
set(ax2,'ColorScale','log');
Then I received the same warning again, but this time the whole plot on ax2 disappeared, only left with the axes.
Then I tried first setting to log scale then shading interp:
ax2 = axes;
m_proj('miller','long',[lon1 lon2],'lat',[lat1 lat2]);
m_pcolor(X,Y,delta_p);
m_grid('linest','none','tickdir','out','box','fancy','fontsize',10);
set(ax2,'ColorScale','log');
s1=findobj(ax2,'Type','surf');
set(s1,'FaceColor','interp')
But I still got the Dataspace/Color Space transform warning, and the plot still disappeared.
Other answers to this issue suggest replace numbers that are close to 0 with NaN, I tried but it still didn't work.
delta_p(delta_p<1e-04)=NaN;

7 Kommentare

doc shading
It says: The shading function controls the color shading of surface and patch graphics objects.
Related: maybe m_pcolor creates a surface object.
Thank you both. I have updated my question.
pcolor(peaks);
set(gca,'ColorScale','log');
colormap(parula(256));
shading flat;
works
pcolor(peaks);
set(gca,'ColorScale','linear');
colormap(parula(256));
shading interp
works
pcolor(peaks);
set(gca,'ColorScale','log');
colormap(parula(256));
shading interp;
% Warning: Error creating or updating Surface
% Error in value of property CData
% DataSpace or ColorSpace transform method failed.
does not work
so it's a bug?
G A
G A am 26 Mai 2021
Bearbeitet: Jan am 26 Mai 2021
I don't think that is a bug. It is just not possible to do in Matlab now. See similar question about transparency.
Thanks!!

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Tags

Gefragt:

am 24 Mai 2021

Kommentiert:

am 27 Mai 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by