how to label y axis tick marks?

1 visualización (últimos 30 días)
Minka Califf
Minka Califf el 17 de Mayo de 2018
Comentada: Minka Califf el 17 de Mayo de 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');

Respuesta aceptada

the cyclist
the cyclist el 17 de Mayo de 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 comentario
Minka Califf
Minka Califf el 17 de Mayo de 2018
Ah, you're right. Thanks so much!

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by