kwant.plotter.streamplot(field, box, cmap=None, bgcolor=None, linecolor='k', max_linewidth=3, min_linewidth=1, density=0.2222222222222222, colorbar=True, file=None, show=True, dpi=None, fig_size=None, ax=None, vmax=None)[source]

Draw streamlines of a flow field in Kwant style

Solid colored streamlines are drawn, superimposed on a color plot of the flow speed that may be disabled by setting bgcolor. The width of the streamlines is proportional to the flow speed. Lines that would be thinner than min_linewidth are blended in a perceptually correct way into the background color in order to create the illusion of arbitrarily thin lines. (This is done because some plot backends like PDF do not support lines of arbitrarily thin width.)

Internally, this routine uses matplotlib’s streamplot.

field3d arraylike of float

2d array of 2d vectors.

box2-sequence of 2-sequences of float

the extents of field: ((x0, x1), (y0, y1))

cmapcolormap, optional

Colormap for the background color plot. When not set the colormap “kwant_red” is used by default, unless bgcolor is set.

bgcolorcolor definition, optional

The solid color of the background. Mutually exclusive with cmap.

linecolorcolor definition

Color of the flow lines.


Width of lines at maximum flow speed.


Minimum width of lines before blending into the background color begins.


Number of flow lines per point of the field. The default value of 2/9 is chosen to show two lines per default width of the interpolation bump of interpolate_current.


Whether to show a colorbar if a colormap is used. Ignored if ax is provided.

filestring or file object or None

The output file. If None, output will be shown instead.


Whether is to be called, and the output is to be shown immediately. Defaults to True.

dpifloat or None

Number of pixels per inch. If not set the matplotlib default is used.

fig_sizetuple or None

Figure size (width, height) in inches. If not set, the default matplotlib value is used.

axmatplotlib.axes.Axes instance or None

If ax is not None, no new figure is created, but the plot is done within the existing Axes ax. in this case, file, show, dpi and fig_size are ignored.

vmaxfloat or None

The upper saturation limit for the colormap; flows higher than this will saturate. Note that there is no corresponding vmin option, vmin being fixed at zero.

figmatplotlib figure

A figure with the output if ax is not set, else None.

Previous topic


Next topic


This Page