I have the horizontal legend for x-axis as you see in the attached graphics. But in this way numbers are hard to see. I would like to set the legend to be vertical to improve readability. Please advise.

 Akzeptierte Antwort

Star Strider
Star Strider am 5 Apr. 2018

0 Stimmen

See if you can use the 'XTickLabelRotation' (link) ‘axes’ property. (I do not remember when this option first appeared. I believe it was R2015b.)

4 Kommentare

Would you explain how it works in the following example?
w=0:0.05:1;
ncount1 = histc(x(:,1),w);
relativefreq1=ncount1/NSamples;
ncount2 = histc(x(:,2),w);
relativefreq2=ncount2/NSamples;
ncount3 = histc(x(:,3),w);
relativefreq3=ncount3/NSamples;
figure (4)
plot(w, relativefreq1)
hold on
plot(w, relativefreq2,'LineWidth',1.0)
hold on
plot(w, relativefreq3,'LineWidth',1.5)
legend('Data1','Data2','Data')
title('Distribution of Data')
xlabel('Data')
ylabel('Frequency')
xlim([min(w) max(w)])
set(gca, 'xtick', w)
Tweak the last line to be:
set(gca, 'xtick', w, 'XTickLabelRotation',90)
alpedhuez
alpedhuez am 5 Apr. 2018
Thank you.
Star Strider
Star Strider am 5 Apr. 2018
As always, my pleasure.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by