stam.colorline
The contents of colorline.py are taken from David P. Sanders’ Jupyter Notebook: https://nbviewer.jupyter.org/github/dpsanders/matplotlib-examples/blob/master/colorline.ipynb
Defines a function colorline that draws a (multi-)colored 2D line with coordinates x and y. The color is taken from optional data in z, and creates a LineCollection.
z can be: - empty, in which case a default coloring will be used based on the position along the input arrays - a single number, for a uniform color [this can also be accomplished with the usual plt.plot] - an array of the length of at least the same length as x, to color according to this data - an array of a smaller length, in which case the colors are repeated along the curve
The function colorline returns the LineCollection created, which can be modified afterwards.
See also: plt.streamplot
Functions
|
|
|
Plot a colored line with coordinates x and y Optionally specify colors in the array z Optionally specify a colormap, a norm function and a line width |
|
Create list of line segments from x and y coordinates, in the correct format for LineCollection: an array of the form numlines x (points per line) x 2 (x and y) array |