Line graph drawn with MATLAB, x-axis to a string and rotated by a certain angle! ! !

First on the code, and then line by line explanation;

x=1:37;

% This line is actually the beginning, there is no time to write, and later need to give X-axis scale only add several provisions of

plot(x,Y,'linewidth',2);

% Of x is the independent variable, y is the dependent variable drawing, the line width set to 2

xlim ([0 37])

% Setting Section X axis, to avoid blank areas
set (gca, 'xtick', 1: 37)

% Gca mean coordinates designated area, if there are several coordinate area may be divided into ax1, ax2; then use 'Name', 'Value' of a certain format to specify the value of the name,

Here is the x-axis designated as thirty-seven scale, each scale interval of 2

set(gca,'xticklabel',X)

% This is the identity of the x-axis instead of what you want to place, X I have here is that cell type, which is thirty-seven string these words is that these thirty-seven string

On previously specified thirty-seven scale
xtickangle (45);

% Because sometimes, the string will be longer, may affect the front to the back, it is necessary to scale a string rotation angle, xtickangle X-axis can be

String rotated 45 degrees
 title ( 'the Shape')
xlabel ( 's')
ylabel ( 'population (million)')

That is to add back a few% of the title, the X axis plus the variable name, variable name on the Y axis

set (clearly, "trickle", 14)

% Of the final set about font scale values

 

x=1:37;
plot(x,Y,'linewidth',2);
xlim ([0 37])
set(gca,'xtick',1:37)
set(gca,'xticklabel',X)
xtickangle(45);
title('shape')
xlabel ( 's')
ylabel ( 'population (million)')
set (clearly, "trickle", 14)

% There is a problem forgot to say that I find a lot of ways to import text, or import data directly MATLAB comes with the most convenient

 

 

 I have here is a screenshot, save yourself the best, manually export settings

 

Recommended URL: https: //ww2.mathworks.cn/help/search.html qdoc = plot & submitsearch =?

This website introduces the MATLAB, plot and setting aspects of grammar, home and more powerful stuff!

Guess you like

Origin www.cnblogs.com/gaofenzi/p/11769891.html