Hello, I'm using MatLab for my cs class in college, it's an intro class and I know close to nothing about coding.
I would like to make a graph of x and y values, I understand that part, with numbers though.
My x values are i guess words instead of numbers, how do I represent that?
Thank you!

 Respuesta aceptada

BN
BN el 1 de Feb. de 2020
Editada: BN el 1 de Feb. de 2020

3 votos

First, you can create Words
Words = {'word_one'; 'word_two'; 'word_three'};
then plot what ever you want, and after plot part:
set(gca,'xtick',[1:3],'xticklabel',Words)
Further, you can read Label x-axis.
If you want to rotate Words after doing this, as I can predict, it you can read this documentation: xtickangle

4 comentarios

Star Strider
Star Strider el 1 de Feb. de 2020
Since we do not know what the values are on the x-axis, a more appropriate approach would be:
set(gca,'xtick',linspace(min(xlim),max(xlim),3),'xticklabel',Words)
BN
BN el 1 de Feb. de 2020
You are right. Sorry, it's my bad. Thank you for let me know. ?
Star Strider
Star Strider el 1 de Feb. de 2020
No worries!
Monica Rochnowski
Monica Rochnowski el 1 de Feb. de 2020
You guys are both awesome! Thank you so much!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre 2-D and 3-D Plots en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 1 de Feb. de 2020

Comentada:

el 1 de Feb. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by