Line Plots

Perhaps the most well-known type of plot, it is so generic that in pyplot it is called by the function named plot.


In [1]:
import numpy
from matplotlib import pyplot
%matplotlib inline

###  generate some random data
xdata = numpy.arange(25)
ydata = numpy.random.randn(25)

###  initialize the "figure" and "axes" objects
fig, ax = pyplot.subplots()

line_plot = ax.plot(xdata, ydata)



Linewidth


In [2]:
###  initializing figure
fig, ax = pyplot.subplots()

###  thickness of line
line_plot = ax.plot(xdata, ydata, lw=1)



Dashes


In [3]:
###  initializing figure
fig, ax = pyplot.subplots()

###  adding dashes of various kinds to line
line_plot = ax.plot(xdata, ydata, ls='-')
#line_plot = ax.plot(xdata, ydata, ls='--')
#line_plot = ax.plot(xdata, ydata, ls=':')
#line_plot = ax.plot(xdata, ydata, ls='-.')
#line_plot = ax.plot(xdata, ydata, dashes=[15,3,8,10])



Colors

Python has a variety of ways to choose plotting colors, and using them is pretty straightforward.


In [4]:
###  initializing figure
fig, ax = pyplot.subplots()

line_plot = ax.plot(xdata, ydata, color='r')
#line_plot = ax.plot(xdata, ydata, color='purple')
#line_plot = ax.plot(xdata, ydata, color=(0.2, 0.8, 0.2))
#line_plot = ax.plot(xdata, ydata, color='#cccccc')



Links

W3schools Color Picker:
https://www.w3schools.com/colors/colors_picker.asp

Information on color blindness:
http://mkweb.bcgsc.ca/colorblind/

Color Oracle, software that simulates color blindness:
http://colororacle.org/


In [ ]: