Azzera filtri
Azzera filtri

how to label y axis tick marks?

1 visualizzazione (ultimi 30 giorni)
Minka Califf
Minka Califf il 17 Mag 2018
Commentato: Minka Califf il 17 Mag 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');

Risposta accettata

the cyclist
the cyclist il 17 Mag 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.

Più risposte (0)

Categorie

Scopri di più su Labels and Annotations in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by