Get clim values from colormap and adjust them in real time

조회 수: 35 (최근 30일)
Pelajar UM
Pelajar UM 2022년 3월 11일
댓글: Pelajar UM 2022년 3월 11일
I am trying to get the cmin and cmax values from a colormap, output them to editfields and let the user change them to update the plot in real time.
s = trisurf(F,P(:,1),P(:,2),P(:,3), Thickness2, 'Parent', app.UIAxes2_5);
c = colorbar(app.UIAxes2_5);
d = colormap(app.UIAxes2_5, jet);
d.clim([cmin cmax]); %Error: unrecognized function or variable 'cmin'
app.MinEditField.Enable = 'on';
app.MinEditField.Value = cmin;
app.MaxEditField.Enable = 'on';
app.MaxEditField.Value = cmax;
I also want the faceAlpha to be 0 for values above cmax and below cmin. But before I reach there, I get an error.

채택된 답변

Sugar Daddy
Sugar Daddy 2022년 3월 11일
boyaa, let me show you how to do that in a simple matlab figure. then figure it out yourself, how to do it for uiaxes
ax = gca;
mesh(ax,rand(100,100));
colormap(ax,'jet')
[cmin cmax] = deal(ax.CLim);
Now you have current cmin and cmax value.
change their value in Clim
ax.CLim = [0.1 1]
  댓글 수: 1
Pelajar UM
Pelajar UM 2022년 3월 11일
Thanks. This was helpful.
Two problems here:
  1. "deal" doesn't work. cmin and cmax give the same result (min and max together in two columns).
  2. gca doesn't seem to work in app designer
This one did the job:
x = app.UIAxes2_5.CLim;
cmin = x(:,1);
cmax= x(:,2);

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Simon Chan
Simon Chan 2022년 3월 11일
Use clim(app.UIAxes2_5,[cmin cmax])

카테고리

Help CenterFile Exchange에서 Blue에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by