Geoscience Reference
In-Depth Information
in the following chapters of this topic.
2.10 Generating Code to Recreate Graphics
MATLAB supports various ways of editing all objects in a graph interactively
using a computer mouse. First, the Edit Plot mode of the Figure Window
needs to be activated by clicking on the arrow icon or by selecting Edit Plot
from the To o l s menu. h e Figure Window also contains some other options,
such as Rotate 3D , Zoom or Insert Legend . h e various objects in a graph,
however, are selected by double-clicking on the specii c component, which
opens the Property Editor . h e Property Editor allows changes to be made
to many features (or properties) of the graph such as axes, lines, patches and
text objects.
h e Generate Code option enables us to automatically generate the
MATLAB code of a i gure to recreate a similar graph with dif erent data. We
use a simple plot to illustrate the use of the Property Editor and the Generate
Code option to recreate a graph.
clear
x = 0 : pi/10 : 2*pi;
y1 = sin(x);
plot(x,y1)
h e default layout of the graph is that of Figure 2.4. Clicking on the arrow
icon in the Figure Toolbar enables the Edit Plot mode. h e selection handles
of the graph appear, identifying the objects that are activated. Double-
clicking an object in a graph opens the Property Editor .
As an example we can use the Property Editor to change various
properties of the graph. Double-clicking the gray background of the Figure
Window gives access to properties such as Figure Name, the Colormap used
in the i gure, and the Figure Color. We can change this color to light blue
represented by the light blue square in the 4th row and 8rd column of the
color chart. Moving the mouse over this square displays the RGB color code
[0.68 0.92 1] (see Chapter 8 for more details on RGB colors). Activating the
blue line in the graph allows us to change the line thickness to 2.0 and select
a 15-point square marker. We can deactivate the Edit Plot mode of the Figure
Window by clicking on the arrow icon in the Figure Toolbar.
At er having made all necessary changes to the graph, the corresponding
commands can even be exported by selecting Generate Code from the File
menu of the Figure Window. h e generated code displays in the MATLAB
Editor.
Search WWH ::




Custom Search