How to have qualitative expressions in 'x' axis plot in MATLAB?

5 Ansichten (letzte 30 Tage)
Alireza Babaei
Alireza Babaei am 22 Sep. 2020
Bearbeitet: Alireza Babaei am 4 Feb. 2021
Dear scholars,
I was wodering if there is any way that I can write qualitative phrases (e.g. XXXX) in x axis in a plot instead of numerical values.

Antworten (1)

Ameer Hamza
Ameer Hamza am 22 Sep. 2020
Yes. Use XTickLabel property of the axes object. For example
ax = axes();
plot(0:10, rand(1,11));
ax.XTick = [0 5 10];
ax.XTickLabel = {'Zero', 'Five', 'ten'};
  1 Kommentar
Steven Lord
Steven Lord am 22 Sep. 2020
You could also use the xticks and xticklabels functions.
>> plot(1:10);
>> xticks(1:3:10);
>> xticklabels(["one", "four", "seven", "ten"])

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Line Plots finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by