how to label y axis tick marks?

1 次查看(过去 30 天)
I can't get the labels on the y-axis to show. I used
yticklabels({'A380','A350','A330-200','A318','A319neo','A320neo','A321neo'})
and it still isn't showing?
%load data
data = [239 199 192 146 123 111 103];
labels = {'A380', 'A350', 'A330-200', 'A318', 'A319neo', 'A320neo', 'A321neo'};
figure;
%make line dotted, make bars thinner
barh(data, 'FaceColor', [0.75 0.75 0.75], 'LineStyle',':', 'BarWidth', .6);
%title
title('Airplane length in feet', 'fontsize', 16, 'fontweight', 'normal');
%move x axis to top
set(gca, 'XAxisLocation', 'top');

采纳的回答

the cyclist
the cyclist 2018-5-17

This code (which just combines your code) works fine for me:

%load data
data = [239 199 192 146 123 111 103];
labels = {'A380', 'A350', 'A330-200', 'A318', 'A319neo', 'A320neo', 'A321neo'};
figure;
%make line dotted, make bars thinner
barh(data, 'FaceColor', [0.75 0.75 0.75], 'LineStyle',':', 'BarWidth', .6);
%title
title('Airplane length in feet', 'fontsize', 16, 'fontweight', 'normal');
%move x axis to top
set(gca, 'XAxisLocation', 'top');
yticklabels({'A380','A350','A330-200','A318','A319neo','A320neo','A321neo'})

Is it possible that you accidentally created a variable named yticklabels that is causing the problem? Maybe try this code in a fresh MATLAB instance.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Axis Labels 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by