Phase 2: Editing the plot display using attributes from the chart line object ‘p’. The code below generates two linear curves and edits the display of the graphs by altering the attributes of the chart line object. The generated plot gets assigned to a chart line object, and its display gets customized by altering the attributes from the storing chart line object. Matlab extends its feature in 2D line plots to customize the plot presentation through the execution even after the plot is generated. Plot(x,y1,x,y2,'-o','MarkerIndices',1:1:50)Ĭustomizing the presentation of the lines after the creation of the plot. The below example generates 2 line plots, and we highlight one plot with the marker symbol ‘-o’. In the case of a graph containing lines more than three and having overlapped presentation, it helps to determine which data point belongs to which plot. Markers help point out distinct data points on the plotted line to determine the exact values calculated from the function. The code snippet below generates six lines for the function defined by ‘y’, the looping variable’ x’ function.ĭisplaying markers for specific data points for the lines. This can also be achieved by calling the plot function in a loop where the plotting function can be defined as a function of the looping variable. Matlab enables users to plot more than two lines in a single plane. The code displays the data mapping each line to its corresponding plotting function. Including legend to distinguish the line plots: Application of the attribute ‘legend’ adds information to the plot to guide the user in identifying the lines with respect to their plotting functions. %Placing the second line plot in the second cell of the frame %Placing the first line plot in the first cell of the frame The below example presents 2 line plots generated from one single execution of the program with two different sets of axes. Arranging multiple line plots in different subplots: Matlab supports presenting the line plots generated in a single execution with a distinct set of axes. %The minimum value of the y-axis gets updated to -0.1 and the maximum value for the x-axis is updated to 12. Syntax to incorporate axes limit: axis ( )Ĭode: plot(x, y1,x,y2), axis() The limit values for the plots can be imposed on the axes using the command ‘axis’. Plot(x, y1,x,y2), xlabel('x-axis'), ylabel('y-axis'), title('Graph customisation'), %Adding x-label, y-label and title to the resultant plot The example defined below demonstrates the process of customization of the presentation of the graph by modifying the attributes given above. Axis square: A set of square plots can be generated. Axis equal: The plots can be created with a common scale factor and spaces for both axis.į. Grid on: Makes the grid lines visible for the graph.Į. The customization of the lines drawn from single plot functions can be achieved by altering any of the attributes or any combination of the attributes described below:Ĭ. Plot the sine function over three different ranges using different line styles, colors, and markers.Ĭreate a plot illustrating how to set line properties.The resultant plot consists of 2 sinusoidal line curves, ‘y1’ and ‘y2′, having two different sets of values’,x1′ and ‘x2’, but share a common x-y plane. See ColorSpec for more information on color. This is useful if you want to specify a color that is not in the list by using RGB values. In addition, you can specify the LineStyle, Color, and Marker properties instead of using the symbol string. MarkerSize - specifies the size of the marker in points.MarkerFaceColor - specifies the color of the face of filled markers.MarkerEdgeColor - specifies the color of the marker or the edge color forfilled markers (circle, square, diamond, pentagram, hexagram, and the four triangles).LineWidth - specifies the width (in points) of the line.When using the plot and plot3 functions, you can also specify other characteristics of lines using graphics properties: If you specify a marker, but not a line style, MATLAB plots only the markers. Specify the components (in any order) as a quoted string after the data arguments. ), places circular markers ( o) at the data points, and colors both line and marker red ( r). Plots y versus x using a dash-dot line (. Many plotting commands accept a LineSpec argument that defines three components used to specify lines: By default, there is only one line style (a solid line). The following tables list these specifiers. MATLAB also cycles through different line styles in addition to colors. MATLAB defines string specifiers for line styles, marker types, and colors. Marker face and edge coloring (for filled markers).MATLAB enables you to define many characteristics including: This page describes how to specify the properties of lines used for plotting. LineSpec (MATLAB Functions) MATLAB Function Reference
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |