How to change the numbering system in the y axis? pitcure inside

조회 수: 2 (최근 30일)
Bander
Bander 2014년 6월 24일
댓글: Sara 2014년 6월 25일
Hi
I am new user to Matlab. I have 2 million entries and want to plot them as histogram. The problem I am getting the figure as the one attached where you can notice the y axis start from 0*10^5,0.5*10^5, ..... where I want it like: 1*10^5,2*10^5.... I want the y axis appear like the second picture.
<</matlabcentral/answers/uploaded_files/14594/Untitled.jpg
>>
here is the code I am using:
mydata1=load('data_m256_k5_n37.txt');
pp=hist(mydata1(:,1),max(mydata1(:,1))-min(mydata1(:,1))+1);
figure(1)
bar(min(mydata1(:,1)):max(mydata1(:,1)),pp,'w', 'LineWidth',2)
grid on
xlabel('\rho','FontSize',12)
ylabel('','FontSize',12)

답변 (4개)

Sara
Sara 2014년 6월 24일
I can't see Fig 2 but I think you can rescale the yaxis and the replace the y-ticks if you want the exponent close to each tick:
xx = pp/1e5;
bar(min(mydata1(:,1)) : max(mydata1(:,1)),xx,'w', 'LineWidth',2)
yt = get(gca,'ytick')
ytstr = cell(numel(yt),1);
for i = 1:numel(yt)
ytstr{i} = [num2str(yt(i)),char(215),'10^5'];
end
set(gca,'YTicklabel',ytstr)

Bander
Bander 2014년 6월 24일
Thanks for your reply here are the two figures. I want the y axis in fig 1 displayed as same as fig2.
  댓글 수: 1
Sara
Sara 2014년 6월 24일
What exactly do you want different than fig 1, because they look the same to me?

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


Bander
Bander 2014년 6월 24일
In the first figure y axis start with 0, 0.5, 1, 1.5, 2, 2.5,3)x 10e5 Wereas I want them to exactly as the secound figure. i now the valuse are same but the way they reprsnred is diffrent. The same code above some times gives me y axis like the second figure which is good. But other times it gives me like the first figure but diffrent valuse. I am not sure what should I add to the code to force matlab to represnt the y axis as in figure 2.
Thanks

Ben11
Ben11 2014년 6월 24일
Maybe this:
set(gca,'YTick', 0:1E5:8E5);
  댓글 수: 2
Bander
Bander 2014년 6월 25일
Thanks for you help. I have tried your suggestion but did not work.
Sara
Sara 2014년 6월 25일
what didn't work?

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by