One surface is changing the color of another
조회 수: 1 (최근 30일)
이전 댓글 표시
I have a program that, without going into needless detail, plots the potential energy wells of several regions around the surface of a sphere. The simplified code looks a bit like:
for i=1:n
% spend a few lines calculating the potential, P, in the region with coordinates
% (az,el) which surrounds point i
[x,y,z] = sph2cart(az, el, P)
surf(x,y,z,P)
end
%draw the sphere so a reference height can be gauged:
[x,y,z] = sphere
surf(x,y,z, 'FaceColor',[0.7 0.7 0.7])
What's weird is that the potential wells are showing up as monochromatic. Pausing the code in the debugger after each surface is drawn, I noticed that each successive surface is changing the colors of all the previous ones, with the sphere causing the most dramatic change. My guess is that there is some sort of global color map for all surfaces on a set of axes, but I can't find a way to turn that off.
Thanks in advance!
댓글 수: 1
Image Analyst
2023년 8월 26일
You forgot to attach a screenshot to help us visualize it. Is it something like a golf ball and you want the surface to be one color and the dimples to be other colors (depending on the depth of the dimple at each location)?
채택된 답변
DGM
2023년 8월 26일
이동: DGM
2023년 8월 26일
Without knowing the specifics, my guess is that there is fairly significant z-difference between the ranges of values represented by each surf plot.
All of the objects in a given axes share the same colormap and clim/caxis settings. When you add a new surf plot to the axes, it will update the current setting for clim to suit the range of the newest plot.
Even though you're explicitly setting a flat face color for the sphere surf, it still updates clim, and thus it can still affect the way all the other surfaces are colormapped (depending on the relative range of values).
I suggest looking at clim() and picking some fixed limits based on the overall range of the data that needs to be colormapped.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Colormaps에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!