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 件のコメント
G A
2021 年 5 月 24 日
doc shading
It says: The shading function controls the color shading of surface and patch graphics objects.
Voss
2021 年 5 月 24 日
Related: maybe m_pcolor creates a surface object.
Siyi Zhang
2021 年 5 月 25 日
G A
2021 年 5 月 25 日
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
Siyi Zhang
2021 年 5 月 26 日
I don't think that is a bug. It is just not possible to do in Matlab now. See similar question about transparency.
Siyi Zhang
2021 年 5 月 27 日
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Lighting, Transparency, and Shading についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!