how to label y axis tick marks?

1 view (last 30 days)
Minka Califf
Minka Califf on 17 May 2018
Commented: Minka Califf on 17 May 2018
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');

Accepted Answer

the cyclist
the cyclist on 17 May 2018

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.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!