Page 105 - Informatics_Practices_Fliipbook_Class12
P. 105
Fig 3.1: Point (3, 2)
In the above code, the first line imports the pyplot module from the Matplotlib library, allowing us to access its
plotting methods. In the second statement, plt.plot() method is invoked for creating a plot. The first argument
represents the x-coordinate of the point, the second argument represents the y-coordinate, and the third argument is
a string that specifies the style. In line 2, the string 'ro' specifies that the point is to be plotted as a red circle marker.
Once we have created and customized our plot, we need to display it. Matplotlib provides the plt.show() method
to render the plot on the screen. It is important to note that this method should be called only once per script.
To plot the point(x,y), invoke the plot() method of pyplot module as follows: plt.plot(x, y, format_
string)
Marker Shapes
Matplotlib offers the several options for marker shapes that can be used to represent a point in a plot using a format_
string. Some of them are provided below:
Table 3.1
Marker Shapes Description
Point Marker ('.') The point marker displays a single point as a small dot.
Pixel Marker (',') The pixel marker represents each point as a single pixel.
Circle Marker ('o') The circle marker displays each point as a filled circle.
Triangle Down Marker ('v') The triangle down marker represents each point as a downward-pointing
triangle.
Triangle Up Marker ('^') The triangle up marker displays each point as an upward-pointing triangle.
Triangle Left Marker ('<') The triangle left marker represents each point as a left-pointing triangle.
Triangle Right Marker ('>') The triangle right marker displays each point as a right-pointing triangle.
Square Marker ('s') The square marker represents each point as a filled square.
Pentagon Marker ('p') The pentagon marker displays each point as a filled pentagon.
Star Marker ('*') The star marker represents each point as a star symbol.
Data Visualization 91

