how to label y axis tick marks?

1 vue (au cours des 30 derniers jours)
Minka Califf
Minka Califf le 17 Mai 2018
Commenté : Minka Califf le 17 Mai 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');

Réponse acceptée

the cyclist
the cyclist le 17 Mai 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.

  1 commentaire
Minka Califf
Minka Califf le 17 Mai 2018
Ah, you're right. Thanks so much!

Connectez-vous pour commenter.

Plus de réponses (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by