필터 지우기
필터 지우기

How Do I Get xticklabels to Scale Properly When Zooming on an Imagesc Plot?

조회 수: 9 (최근 30일)
Sean
Sean 2012년 12월 11일
답변: Pratik Mahamuni 2019년 11월 22일
Hi,
I'm using imagesc to display some values in a GUI window. There are three subplots that use imagesc. I want to use the values in g_spectrum.aspectDeg for the xTickLabels. They are just a series of angles in degrees. However, when I try
set(gca, 'xTickLabel', num2str(g_spectrum.aspectDeg));
the xTickLabels that are displayed are the first 8 values (I only have 8 xticks on each imagesc plot). What I need the code to do is to scale the xTickLabels approprietly for the level of zoom on the plot.
i.e. in the case where it is completely "zoomed out", instead of displaying the first 8 labels, I'd like it to display 8 values over the range of the labels (in this case it should be from 337.718 to 176.23). Then, if I zoom in on some values in middle, it might display 257.022 to 256.526).
Here is the code used to display the images.
ha(1)=subplot('Position',[ 0.05 0.66 0.9 0.29]);
imagesc(aspect, yval, ChatCpi,[0 1]);colormap(summer)
axis([-Inf Inf -Inf Inf]);
set(gca,'ytick',1:NumFreq);
set(gca,'yTickLabel',freqstring);
set(gca, 'xTickLabel', num2str(g_spectrum.aspectDeg));
title(title1,'fontsize',12,'fontweight','b');
ha(2)= subplot('Position',[ 0.05 0.37 0.9 0.29]);
imagesc(xval, yval',JemOnly,[0 1]);colormap(summer)
axis([-Inf Inf -Inf Inf]);
set(gca,'ytick',1:NumFreq);
set(gca,'yTickLabel',freqstring);
set(gca, 'xTickLabel', num2str(g_spectrum.aspectDeg));
ha(3)=subplot('Position',[ 0.05 0.08 0.9 0.29]);
imagesc(xval, yval,JemChat,[0 1]);colormap(summer)
xlabel('Aspect(deg)');
axis([-Inf Inf -Inf Inf]);
set(gca,'ytick',1:NumFreq);
set(gca,'yTickLabel',freqstring);
set(gca, 'xTickLabel', num2str(g_spectrum.aspectDeg));

답변 (1개)

Pratik Mahamuni
Pratik Mahamuni 2019년 11월 22일
Sean,
You could try this function Dynamic Date Ticks; you may have to play around it a little bit considering the function is written for dates. But a similar concept can be used for other XTicks.

카테고리

Help CenterFile Exchange에서 Grid Lines, Tick Values, and Labels에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by