How can I plot Months in x axis in Matlab

I have a excel sheet
Jan =-9.863459038
Feb=-34.33708151
Mar=-57.98922801
Apr=-52.98083559
May=-46.13563686
Jun=-24.15487463
Jul=-8.47398491
Aug=-4.773884307
Sep=-10.32493525
Oct=-7.700825238
Nov=6.015198544
Dec=11.1233672
I have to plot a graph whose x axis is month.I want to plot it by Jan,Feb etc. How can I do it.

Respuestas (1)

Michael Haderlein
Michael Haderlein el 1 de Abr. de 2015
You can set the xticklabels:
y=rand(1,12);
figure, plot(y)
set(gca,'xtick',1:12,...
'xticklabel',{'Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'})

5 comentarios

Thank you sir.This is really useful.If we want to make a bar chart how can we change this code?
Michael Haderlein
Michael Haderlein el 1 de Abr. de 2015
Editada: Michael Haderlein el 1 de Abr. de 2015
Just replace "plot" with "bar". Also, you can leave out the part 'xtick',1:12,' as bar plots have xticks at all bars anyway, I think.
per isakson
per isakson el 20 de Mzo. de 2016
Answer by Tanmoyee Bhattacharya on 1 Apr 2015
Thanks sir. It works..
ntambara owen
ntambara owen el 9 de Ag. de 2019
It works.....
Dedong Huang
Dedong Huang el 11 de Dic. de 2021
Hello,
I just tried this method with my data and it plotted a line graph but the y axis is less than 1 and my y axis data on my table are all above 5, how do i fix this?

Iniciar sesión para comentar.

Categorías

Etiquetas

Preguntada:

el 1 de Abr. de 2015

Comentada:

el 11 de Dic. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by