Plot: vertical legend for x axis

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.

 采纳的回答

Star Strider
Star Strider 2018-4-5

0 个投票

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 个评论

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)
As always, my pleasure.

请先登录,再进行评论。

更多回答(0 个)

类别

产品

标签

Community Treasure Hunt

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

Start Hunting!

Translated by