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

2 Ansichten (letzte 30 Tage)
Bander
Bander am 24 Jun. 2014
Kommentiert: Sara am 25 Jun. 2014
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)

Antworten (4)

Sara
Sara am 24 Jun. 2014
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 am 24 Jun. 2014
Thanks for your reply here are the two figures. I want the y axis in fig 1 displayed as same as fig2.
  1 Kommentar
Sara
Sara am 24 Jun. 2014
What exactly do you want different than fig 1, because they look the same to me?

Melden Sie sich an, um zu kommentieren.


Bander
Bander am 24 Jun. 2014
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 am 24 Jun. 2014
Maybe this:
set(gca,'YTick', 0:1E5:8E5);
  2 Kommentare
Bander
Bander am 25 Jun. 2014
Thanks for you help. I have tried your suggestion but did not work.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Line Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by