MATLAB plot coordinate axis Scale

Source: Internet
Author: User

[Reprinted] MATLAB plot coordinate axis Scale

Source: http://blog.sina.com.cn/s/blog_4b1fb7610100q9ov.html

How to set the scale of the coordinate axis in MATLAB?

If you use MATLAB plot functions such as plot and plot3, You can manually modify the scale of the coordinate axis. Is there any function that can change the scale of the coordinate axis?

STR = 'e: cjf'
X = [0: 0. 1:1];
Xlab = [1: 11];
For I = 1:10
  Plot ([0 1], [0 1]); Hold on; plot ([0 1], [1 2]);
  Set (GCA, 'xtick', X );
  Set (GCA, 'xticicklab', xlab );
  Hold off;
  Saveas (GCF, [STR num2str (I) '.bmp ']);
End

In addition, the scale is not limited to numbers. For example:
Day = {'sun', 'mon', 'tue ', 'wed', 'thu', 'fri', 'sat '};
Plot );
Set (GCA, 'xticicklabel', Day );

 
Example:
Different types of tick (coordinate axis scale) in MATLABHttp://crust.cn /? P = 287

x=1:8;

subplot(2,2,1)
plot(x)
%tick style 0(auto)

subplot(2,2,2)
plot(x)
set(gca,'xtick',[1 3 6 8]);%style 1
set(gca,'ytick',[]);%style 2

subplot(2,2,3)
plot(x)
set(gca,'xtick',[1 3 6 8]);
set(gca,'xticklabel',sprintf('.4f|',get(gca,'xtick')));%style 3
set(gca,'ytick',[2 4 5 7]);
set(gca,'yticklabel',{'Two','Four','Five','Seven'});%style 4

subplot(2,2,4)
plot(x)
set(gca,'xminortick','on');%style 5
set(gca,'ticklength',[0.05 0.025]);%style 6
set(gca,'tickdir','out');%style 7

x=[1 1.53 4];
y=[1 2 3];
plot(x,y)
set(gca,'XTick',x)
set(gca,'XTickLabel',sprintf('%3.4f|',x))
set(gca,'YTick',y)
set(gca,'YTickLabel',sprintf('%+1.2f|',y))

Set (GCA, 'xtick', [x start coordinate: interval: X end coordinate]);% Set X axis
Set (GCA, 'yzick ', [y start coordinate: interval: Y end coordinate]);% Set Y axis

Non-isothermal coordinates of MATLAB
Set (GCA, 'xtick', [, 140: 40: 400])


About label

Hello everyone. I 'd like to ask you a question. Thank you first.

Yes. When I use 3D plot functions such as plot3 and call xlabel, ylabel, and zlabel, the result is that the text on the X axis and Y axis follows the horizontal direction, if the direction of the text can be set to the same as that of the axis, it will be much more beautiful.

My current method is:
Close all;
Figure;
Plot3 (10, 20, 30, 'marker', 'O', 'markersize', 20 );
Xlabel ('People's Republic of China ');
Set (get (GCA, 'xlabel'), 'rotation', 15 );
Set (get (GCA, 'xlabel'), 'color', 'R ');
Ylabel ('People's Republic of China ');
Set (get (GCA, 'ylabel'), 'rotation',-23 );
Set (get (GCA, 'ylabel'), 'color', 'G ');
Zlabel ('People's Republic of China ');
Set (get (GCA, 'zlabel'), 'color', 'B ');

Among them, the rotation angle 15 and-23 were tried by the way I felt very clumsy. I don't know if there is any better way to set them in place in a step-by-step manner? Thank you very much for your help.

 

About vertical or skewed text

Plot (0: PI/20:2 * Pi, sin (0: PI/20:2 * PI ))
Text (PI, 0, 'leftarrow sin (PI) ', 'fontsize', 18, 'rotation', 90)

 I just saw a problem with the 'position' parameter in an axes function on a blog of MATLAB cool-man,
In a graph, draw some images at different positions.
Example:
X = 0: 0.01: 2 * PI;
Y1 = sin (x); y2 = cos (x); Y3 = sin (x) + cos (X );
Plot (x, Y1)
Axes ('position', [0.55 0.65 0.3 0.2])
Plot (x, Y2)
Xlabel ('y2 = cos (x )');
Axes ('position', [0.15 0.15 0.3 0.2])
Plot (x, Y3)
Xlabel ('y3 = sin (x) + cos (x )');

Set (GCA, 'position', [left bottom width height]
Set (GCA, 'position', [0.15 0.15 0.75 0.75])     % Set the image position

 

Position: Set the text position

Example:

X = 0: 0. 0* PI;

Y = sin (X );

Plot (x, y );

Xlabel ('xlabel', 'position', [2-1.15 1]);

Ylabel ('ylabel', 'position', [-0.5 0 1]);

Title ('title: Y = sin (x) ', 'position', [5 0.6 1], 'rotation', 45 );

Scrsz = get (0, 'screensize') can be used to check the number of pixels on the LZ screen.
 

H0 = figure ('toolbar', 'none ','Position', [198
56 350 300],'Name', 'instance 01 ');
ThisPositionWhat is the specific scope?
198 56 350 300 what do these numbers mean?
H1 = axes ('parent', H0,'Visible ', 'off ');
What is the function of this sentence?
Please give me some advice !!
A:
[The x-axis distance from an object (figure) to the lower left corner of the reference object (screen), Y-axis distance, object width, and object height]
H1 = axes ('parent', H0,'Visible ', 'off ');
Create an axes object in H0 and set its visible attribute to off.
Custom axis content

Ask prawns:

After MATLAB draws a bar chart, how can we use a string to represent the abscissa and correspond to those columns?

For example, to change 1, 2, 3, 4, 5 to B, A, Ba, BCD, and CD
All the automatically generated data is numbers. It has not been changed for a long time and is depressing.

Find the command set (GCA, 'xtick', []) to clear the X axis scale, but how can I display AB CD EF GH IJ in the original bar chart where 1 2 3 4 5 is displayed ????

 

A: Set (GCA, 'xticket', ['AB', 'cd']);
Example:

X = 20:10:20000;
Y = rand (SIZE (x ));
Semilogx (x, y );
Set (GCA, 'xlim', [20 20000]);
Set (GCA, 'xminick ick', 'off ');
Set (GCA, 'xticick', [20 31.5 63 125 250 500 1000 2000 4000 8000 16000]);
Set (GCA, 'xgrid', 'on ');
Set (GCA, 'xminorgrid', 'off ');

Ezplot ('x ^ 3 + x ^ 2 + x + 5', [1,100])
Set (GCA, 'xticick', 'xticicklab', MOD (, 10) % xtick indicates where you want to display the scale, and xticklabel indicates what to display.

Text format settings

Figure_fontsize = 12;
Set (get (GCA, 'xlabel'), 'fontsize', figure_fontsize, 'version', 'top ');
Set (get (GCA, 'ylabel'), 'fontsize', figure_fontsize, 'vertical ', 'middle ');
Set (findobj ('fontsize', 12), 'fontsize', figure_fontsize );

% Changed the font size to 8 characters, which is clear in the thumbnail.

% Set (GCF, 'position', [100 100 260 220]);
% Indicates the drawing size, which does not need to be adjusted in word. The parameter I gave, the image size is 7 cm

% Set (GCA, 'position', [. 13. 17. 80. 74]);
% Indicates the proportion of the XY axis in the image, which may need to be adjusted by yourself.

% Set (findobj (get (GCA, 'Children '), 'linewidth', 0.5), 'linewidth', 2 );

% Changed the line width to 2.

Set (GCA, 'fontname', 'times Newman ', 'fontsize', 12 );

% Set the font type and font size of the image.

 

 


 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.