[MATLAB] basic Tutorial Study Notes (V): Two-Dimensional bottom layer plotting

Source: Internet
Author: User

First, we will introduce the content of objects and handles.

MATLAB calls each basic element of a graph as a graph object. When every graph object is generated, Matlab automatically assigns a unique value to indicate this object, which is called a handle.


Basic Relationship between objects:
Computer Screen-> graphic window-> (User menu, user control, axis)
Axis> (curve, surface, text, image, light source, area, box)

Basic underlying plotting functions:

Line object and line function
H = line ('pro1', 'val1 ',
'Pro2', 'val2 ',...);

For example, the following function:

H = line ([-Pi: 0.01: Pi], sin ([-Pi: 0.01: Pi]); % is equivalent to HP = plot ([-Pi: 0.01: pi], sin ([-Pi: 0.01: Pi]);

After running, the system will generate:


Generate line object. H is the line object handle;
Line object modification:
Color Attribute;
Linewidth attribute;
Linestyle attribute;
Marker attributes;
Markersize attribute;
The plot drawn by plot is also a line object, which can be modified later by using the line Object modification method.


You can draw a curve and define relevant attributes as follows:

hl = line('XData', [-pi:0.1:pi], 'YData', sin([-pi:0.1:pi]), ...    'LineWidth', 1, 'LineStyle', ':', 'Color', 'r');

If this does not fully meet our requirements, we can use set to modify attributes:

hl = line('XData', [-pi:0.1:pi], 'YData', sin([-pi:0.1:pi]), ...    'LineWidth', 1, 'LineStyle', ':', 'Color', 'r');set(hl, 'LineWidth', 2, 'Marker', 'p', 'MarkerSize', 15);

Next, let's take a look at the underlying tagging operations:

Text object and text function.

We can use the text function to return a handle value.

Modifier:
Color Attribute
String attribute
Fontsize attribute
Rotation attributes

hl = line('XData', [-pi:0.1:pi], 'YData', sin([-pi:0.1:pi]), ...    'LineWidth', 1, 'LineStyle', ':', 'Color', 'r');set(hl, 'LineWidth', 2, 'Marker', 'p', 'MarkerSize', 15);ht = text(0, 0, 'sin');set(ht, 'String', 'cos');set(ht, 'FontSize', 20);

The effect is as follows:


Next, let's take a look at the problems related to the coordinate axis.

Axes object and axes Function
Axis attribute modification:
Box attribute
Gridlinestyle attributes
Position attribute
Units attributes (common)
Xlabel, ylabel, and zlabel attributes
Xlim, ylim, and zlim attributes

If the unit attribute of the axis is not set to normalization at the beginning, the default axis attribute is normalized.

We can use the figure function for demonstration. The Unit attribute is changed to pixels by default.

However, when the window is changed, the size of the window changes greatly. Therefore, normalized is recommended.

hf = figure;ha = axes('Parent', hf, 'Units', 'normalized', 'Position', [.1 .1 .6 .5]);

Effect after running:


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.