MATLAB GRAPH SHİFT A UNİT TO THE RIGHT.

When I run the codes written below, AK is where the graphic should start here; however, the graph starts from AZ. Here we can say that the graph is not where it should be, so the graph a unit has shifted to the right. How can I solve that problem. I mentioned the code snippet below.
a=linspace(0,16,51);
s = data.state_code;
b=s(1:3:51);
gdp9=data.gdp_growth_2009;
gdp12=data.gdp_growth_2012;
a4=[gdp9,gdp12];
stem(gdp9,'filled','LineStyle','-','LineWidth',1)
hold on
stem(gdp12, 'LineStyle','-' ,'LineWidth',1)
c={'#F00','#00F'};
colororder(c)
xticklabels(b)
xticks([0:16])
xlim([-.5 17.56])
legend('2009','2012','Location',"best")
title('Growth Rates in 2009 and 2012')
xlabel('States')
ylabel('Growth Rates')
grid on
hold off

 Respuesta aceptada

Ameer Hamza
Ameer Hamza el 20 de Mayo de 2020
Change these lines
xticks([1:17]) % start from 1
xlim([0.5 17.5])

2 comentarios

Hasan Berke Bankoglu
Hasan Berke Bankoglu el 20 de Mayo de 2020
Thank you very much Hamza. It is work!
Ameer Hamza
Ameer Hamza el 20 de Mayo de 2020
I am glad to be of help!

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.

Productos

Versión

R2020a

Preguntada:

el 20 de Mayo de 2020

Comentada:

el 20 de Mayo de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by