If I use
set(gca,'xtick',[])
the ticks vanish as expected, but the exponent, common for all ticks, remains in the plot at the end of the axis.
How can I avoid this

 채택된 답변

Friedrich
Friedrich 2011년 4월 1일

7 개 추천

Hi Hans,
now I get it. In this special case you have to deactivate the xticklabels, too. This should works fine:
A(1,1:21)= 100000:100020;
B(1:100,1)= 1:100;
C(1:100,1:21)=33;
figure;
pcolor(A,B,C)
set(gca,'xtick',[])
set(gca,'xticklabel',[])
Best regards,
Friedrich

댓글 수: 1

Jan
Jan 2011년 4월 1일
Removing the XTickLabel is enough and the XTick can be omitted.

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

추가 답변 (12개)

Friedrich
Friedrich 2011년 4월 1일

1 개 추천

Hi Hans,
which MATLAB and Operating System are you using? I ask this because the following code works fine for me in R2010b and Win7 64bit:
>> nn2 = 1.0e-156*[ 1 2];
>> plot(nn2)
>> set(gca,'YTick',[])
Best regards,
Friedrich
Friedrich
Friedrich 2011년 4월 1일

1 개 추천

Hi Hans,
could you please post a working code? Because I am not able to reproduce your problem. Under Win7 64bit and R2009a the following code work fine:
>>n = 6;
>>r = (0:n)'/n;
>>theta = pi*(-n:n)/n;
>>X = r*cos(theta);
>>Y = r*sin(theta);
>>C = r*cos(2*theta);
>> pcolor(X*1e-4,Y*1e-4,C)
>> set(gca,'XTick',[])
So it must be related to your code.
Friedrich
Jan
Jan 2011년 4월 1일

1 개 추천

A workaround:
A(1,1:21)= 100000:100020;
B(1:100,1)= 1:100;
C(1:100,1:21)=33;
figure;
ax = axes('XTick', [], 'nextplot', 'add');
pcolor(ax, A,B,C)
set(ax, 'YLim', [min(B), max(B)]);

댓글 수: 1

hans
hans 2011년 4월 1일
Thank You this also works !
The strategy seems to be to avoid the generation of the ticks, so it doesn't hurt that the delete function has a bug..

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

David
David 2011년 8월 19일

1 개 추천

I found this elsewhere.
1 vote Kelly Kearney answered 17 days ago Change the renderer from OpenGL to zbuffer.
set(gcf, 'renderer', 'zbuffer');Why this fixes the problem, I really have no idea. But I encounter it a lot when I add dateticks to my axes. Not sure if it's intended behavior or a bug, but most renderers eliminate the factor when manual tick labels are added; OpenGL does not (or at least doesn't always).

댓글 수: 1

Aurelien Queffurust
Aurelien Queffurust 2014년 3월 5일
I confirm this solution allows to removes exponent on my Windows 64-bit

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

Greg
Greg 2015년 11월 18일

1 개 추천

I realize this is a pretty old thread, but I think I've figured out what might have been causing a lot of the confusion in there after running into this issue myself...
Basically, the "opengl" renderer in older versions of MATLAB seems to have a bug that, when a custom XTickLabel is set, the axis exponent is still displayed. This does bug does not appear to happen with the "zbuffer" or "painters" Renderers.
The size of the "B" matrix matters because when you add a very large graphics object to a plot, MATLAB automatically switches the renderer over to opengl (presumably because of the better performance vs. painters or zbuffer).
So, when you execute this code in R2011b, you get no exponent on the axis:
figure
plot(1e6*(1:10),rand(10))
set(gca,'XTickLabel',{'a','b'})
But then if you flip the renderer to opengl, the exponent will appear:
set(gcf,'Renderer','opengl')
You can get rid of it again by going back to painters or zbuffer:
set(gcf,'Renderer','zbuffer')
set(gcf,'Renderer','painters')
I've tested this in R2011b (where the described issue exists) and in R2015a (where it does not), both on 64-bit Windows.
the cyclist
the cyclist 2011년 4월 1일

0 개 추천

Can you give a simple example of code that exhibits this problem, because I am not seeing that behavior. For example, does this code
figure
plot(10.^(1:10),1:10)
set(gca,'XTick',[])
leave the exponent remaining? It does not for me.
hans
hans 2011년 4월 1일

0 개 추천

I'm using R2009a and Win7 64bit.
pcolor(Times{Sensor}, Freq{Sensor}, Pow{Sensor});
set(gca,'xtick',[])
It's true, when I just use
plot(a,b);
set(gca,'xtick',[])
the exponent vanishes. But not in the upper code with pcolor.
hans
hans 2011년 4월 1일

0 개 추천

A very simple code with data generating my problem is:
clear
A(1,1:21)= 100000:100020;
B(1:100,1)= 1:100;
C(1:100,1:21)=33;
figure;
pcolor(A,B,C)
set(gca,'xtick',[])
a simple code that does not generate the problem is just a slightly smaller matrix
clear
A(1,1:21)= 100000:100020;
B(1:10,1)= 1:10;
C(1:10,1:21)=33;
figure;
pcolor(A,B,C)
set(gca,'xtick',[])

댓글 수: 2

hans
hans 2011년 4월 1일
I have modified this answer slightly in the way I included a code that worked fine and one not working fine for comparison.
Just the size of matrix seems to make a difference.
Jan
Jan 2011년 4월 1일
Bug confirmed for Matlab 2009a32 on WinXP32. Please send a bug report to MathWorks.

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

hans
hans 2011년 4월 1일

0 개 추천

Yes, You are right, that works ! Thank You.
However I'm still confused:
1: That I do not have to remove the xticklabel, if I use a matrix for B with a slightly smaller number of elements.
2: That the extracted exponential part of the ticks is not part of the tick but is a ticklabel
Do You have an explanation which could help me to understand ?

댓글 수: 4

Jan
Jan 2011년 4월 1일
This is a bug. The handle of the exponent TEXT object is attached to the XTickLabels, but the delete function of the XTick's forget to care about it, while the delete function of the XTickLabel's do care.
hans
hans 2011년 4월 1일
OK, thank You for the explanation of question 2.
Do You also have an idea regarding question 1 ?
Jan
Jan 2011년 4월 1일
The exponent string looks different for these two methods: For the bigger matrix, the exponent is set above the base number, while for the smaller the exponent is set to the right top. It seems like the strings are created by different methods depending on the number of YTicks! And only one method has the bug.
hans
hans 2011년 4월 1일
That suggests a quick and dirty programming of the Matlab people has remained in the code ...

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

hans
hans 2011년 4월 1일

0 개 추천

OK, thank You Friedrich and Jan Both Your suggestions work.
To summarize the explanation of Jan why the problem occurs: The exponent object is attached to the XTickLabels.
What I still do not understand is:
Why does the size of the matrix B make a difference, if the leaving behind of the exponent occurs or not.
hans
hans 2011년 4월 1일

0 개 추천

a continuation of this problem occurs if I apply the command
datetick
This changes the number-labels into dates but leaves behind the 10^5 from the original numbers at the axis.
Any suggestions how to deal with this other than rewriting the datetick.m ?

카테고리

도움말 센터File Exchange에서 Graphics Performance에 대해 자세히 알아보기

제품

태그

질문:

2011년 4월 1일

답변:

2015년 11월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by