/documentations/python_libraries/matplotlib/

Plotting with Pyplot

Line Properties

The module matplotlib.pyplot (docs) provides functions to add lines, text, images, histograms and more to a plotting area. This is the set of functions used most of the time. We look at pyplot.plot and shortly at pyplot.text. The full list can be found at the pyplot summary. Some examples are:

More information at:

The plot Command

The function pyplot.plot (docs) plots line segments connecting points given as parameter. Matplotlib works internally with numpy arrays, which should be used in case of big arrays. The function accepts a multitude of parameters. If x and y are one dimensional arrays of the same length and m is a two dimensional array having as many rows as x has entries, then some examples are:

Additionally plot accepts formatting strings and a list of line properties:

Below a possibly ugly combination of line properties :

# (Image above)
import matplotlib.pyplot as plt
plt.plot([1,2,3,4],[1,4,9,16], 'gD-.', label='green line',\
         linewidth=8, markerfacecolor='yellow', markersize=15)
plt.legend()
plt.show()