Current location - Music Encyclopedia - Dating - Matlab drawing problem, how to add data to the graph
Matlab drawing problem, how to add data to the graph

When drawing a graph, you can add some descriptions to the graph, such as the name of the graph, description of the coordinate axis, and the meaning of a certain part of the graph. These operations are called adding graph annotations. The calling format of the graphic labeling function is:

title ('Graphic name') (all placed within single quotes)

xlabel ('x-axis description')

ylabel('y-axis description')

text(x, y, 'graph description')

legend('Legend 1', 'Legend 2', ...) P190

Among them, the title, xlabel and ylabel functions are used to describe the names of graphics and coordinate axes respectively. The text function adds a graphic description at the coordinate point (x, y). (P88 or use gtext command). The legend function is used to mark the legend with the line type, color or data points used to draw the curve. The legend is placed in the blank space. The user can also move the legend with the mouse and place it at the desired location. In addition to the legend function, other functions are also applicable to three-dimensional graphics. In three-dimensional z-axis, the zlabel function is used.

In addition to using standard ASCII characters, the description text in the above function can also use control characters in the LaTex (a popular mathematical typesetting software) format, so that Greek characters can be added to the graphics. Mathematical symbols and formulas, etc. In the LaTex string supported by Matlab, the /bf, /it, and /rm control characters are used to define bold, italic, and regular characters respectively. The parts controlled by the LaTex string must be enclosed in braces {}. For example, text(0.3, 0.5, 'the usful {/bf MATLAB}') will make the word MATLAB appear in bold. Some commonly used LaTex characters are shown in the table. Each character can be used alone or in combination with other characters and commands. Such as text(0.3, 0.5,’sin({/omega}t {/beta})’)