Hi Ankush,

We hope you are doing well.We have listed below some of the relevant examples for you. We have run one of them. See below.

import matplotlib.pyplot as plt plt.plot([1,2,3,4]) plt.ylabel('some numbers') plt.show()You may be wondering why the x-axis ranges from 0-3 and the y-axis from 1-4. If you provide a single list or array to the`plot()`

command, matplotlib assumes it is a sequence of y values, and automatically generates the x values for you. Since python ranges start with 0, the default x vector has the same length as y but starts with 0. Hence the x data are`[0,1,2,3]`

.`plot()`

is a versatile command, and will take an arbitrary number of arguments. For example, to plot x versus y, you can issue the command:plt.plot([1, 2, 3, 4], [1, 4, 9, 16])For every x, y pair of arguments, there is an optional third argument which is the format string that indicates the color and line type of the plot. The letters and symbols of the format string are from MATLAB, and you concatenate a color string with a line style string. The default format string is ‘b-‘, which is a solid blue line. For example, to plot the above with red circles, you would issueimport matplotlib.pyplot as plt plt.plot([1,2,3,4], [1,4,9,16], 'ro') plt.axis([0, 6, 0, 20]) plt.show()See the`plot()`

documentation for a complete list of line styles and format strings. The`axis()`

command in the example above takes a list of`[xmin, xmax, ymin, ymax]`

and specifies the viewport of the axes.If matplotlib were limited to working with lists, it would be fairly useless for numeric processing. Generally, you will use numpy arrays. In fact, all sequences are converted to numpy arrays internally. The example below illustrates a plotting several lines with different format styles in one command using arrays.import numpy as np import matplotlib.pyplot as plt # evenly sampled time at 200ms intervals t = np.arange(0., 5., 0.2) # red dashes, blue squares and green triangles plt.plot(t, t, 'r--', t, t**2, 'bs', t, t**3, 'g^') plt.show()We hope it will help you.Kindly give your valuable feedback by clicking on any one of the smiley's below.

If you have any issue feel free to revert.

## Python program on hive not working Print

Modified on: Wed, 6 Jul, 2016 at 12:04 PM

Did you find it helpful? Yes No

Send feedbackSorry we couldn't be helpful. Help us improve this article with your feedback.