vispy.plot.plotwidget module#
- class vispy.plot.plotwidget.PlotWidget(*args, **kwargs)#
Bases:
Widget
Widget to facilitate plotting
- Parameters:
- *argsarguments
Arguments passed to the ViewBox super class.
- **kwargskeywoard arguments
Keyword arguments passed to the ViewBox super class.
Notes
This class is typically instantiated implicitly by a Figure instance, e.g., by doing
fig[0, 0]
.- colorbar(cmap, position='right', label='', clim=('', ''), border_width=0.0, border_color='black', **kwargs)#
Show a ColorBar
- Parameters:
- cmapstr | vispy.color.ColorMap
Either the name of the ColorMap to be used from the standard set of names (refer to vispy.color.get_colormap), or a custom ColorMap object. The ColorMap is used to apply a gradient on the colorbar.
- position{‘left’, ‘right’, ‘top’, ‘bottom’}
The position of the colorbar with respect to the plot. ‘top’ and ‘bottom’ are placed horizontally, while ‘left’ and ‘right’ are placed vertically
- labelstr
The label that is to be drawn with the colorbar that provides information about the colorbar.
- climtuple (min, max)
the minimum and maximum values of the data that is given to the colorbar. This is used to draw the scale on the side of the colorbar.
- border_widthfloat (in px)
The width of the border the colormap should have. This measurement is given in pixels
- border_colorstr | vispy.color.Color
The color of the border of the colormap. This can either be a str as the color’s name or an actual instace of a vipy.color.Color
- Returns:
- colorbarinstance of ColorBarWidget
See also
ColorBarWidget
- histogram(data, bins=10, color='w', orientation='h')#
Calculate and show a histogram of data
- Parameters:
- dataarray-like
Data to histogram. Currently only 1D data is supported.
- binsint | array-like
Number of bins, or bin edges.
- colorinstance of Color
Color of the histogram.
- orientation{‘h’, ‘v’}
Orientation of the histogram.
- Returns:
- histinstance of Polygon
The histogram polygon.
- image(data, cmap='cubehelix', clim='auto', fg_color=None, **kwargs)#
Show an image
- Parameters:
- datandarray
Should have shape (N, M), (N, M, 3) or (N, M, 4).
- cmapstr
Colormap name.
- climstr | tuple
Colormap limits. Should be
'auto'
or a two-element tuple of min and max values.- fg_colorColor or None
Sets the plot foreground color if specified.
- kwargskeyword arguments.
More args to pass to
Image
.
- Returns:
- imageinstance of Image
The image.
Notes
The colormap is only used if the image pixels are scalars.
- mesh(vertices=None, faces=None, vertex_colors=None, face_colors=None, color=(0.5, 0.5, 1.0), fname=None, meshdata=None, shading='auto')#
Show a 3D mesh
- Parameters:
- verticesarray
Vertices.
- facesarray | None
Face definitions.
- vertex_colorsarray | None
Vertex colors.
- face_colorsarray | None
Face colors.
- colorinstance of Color
Color to use.
- fnamestr | None
Filename to load. If not None, then vertices, faces, and meshdata must be None.
- meshdataMeshData | None
Meshdata to use. If not None, then vertices, faces, and fname must be None.
- shadingstr
Shading to use, can be None, ‘smooth’, ‘flat’, or ‘auto’. Default (‘auto’) will use None if face_colors is set, and ‘smooth’ otherwise.
- Returns:
- meshinstance of Mesh
The mesh.
- plot(data, color='k', symbol=None, line_kind='-', width=1.0, marker_size=10.0, edge_color='k', face_color='b', edge_width=1.0, title=None, xlabel=None, ylabel=None, connect='strip')#
Plot a series of data using lines and markers
- Parameters:
- dataarray | two arrays
Arguments can be passed as
(Y,)
,(X, Y)
ornp.array((X, Y))
.- colorinstance of Color
Color of the line.
- symbolstr
Marker symbol to use.
- line_kindstr
Kind of line to draw. For now, only solid lines (
'-'
) are supported.- widthfloat
Line width.
- marker_sizefloat
Marker size. If size == 0 markers will not be shown.
- edge_colorinstance of Color
Color of the marker edge.
- face_colorinstance of Color
Color of the marker face.
- edge_widthfloat
Edge width of the marker.
- titlestr | None
The title string to be displayed above the plot
- xlabelstr | None
The label to display along the bottom axis
- ylabelstr | None
The label to display along the left axis.
- connectstr | array
Determines which vertices are connected by lines.
- Returns:
- lineinstance of LinePlot
The line plot.
See also
LinePlot
- spectrogram(x, n_fft=256, step=None, fs=1.0, window='hann', normalize=False, color_scale='log', cmap='cubehelix', clim='auto')#
Calculate and show a spectrogram
- Parameters:
- xarray-like
1D signal to operate on.
If len(x) < n_fft
, x will be zero-padded to lengthn_fft
.- n_fftint
Number of FFT points. Much faster for powers of two.
- stepint | None
Step size between calculations. If None,
n_fft // 2
will be used.- fsfloat
The sample rate of the data.
- windowstr | None
Window function to use. Can be
'hann'
for Hann window, or None for no windowing.- normalizebool
Normalization of spectrogram values across frequencies.
- color_scale{‘linear’, ‘log’}
Scale to apply to the result of the STFT.
'log'
will use10 * log10(power)
.- cmapstr
Colormap name.
- climstr | tuple
Colormap limits. Should be
'auto'
or a two-element tuple of min and max values.
- Returns:
- specinstance of Spectrogram
The spectrogram.
See also
Image
- surface(zdata, **kwargs)#
Show a 3D surface plot.
Extra keyword arguments are passed to SurfacePlot().
- Parameters:
- zdataarray-like
A 2D array of the surface Z values.
- volume(vol, clim=None, method='mip', threshold=None, cmap='grays', **kwargs)#
Show a 3D volume
- Parameters:
- volndarray
Volume to render.
- climtuple of two floats | None
The contrast limits. The values in the volume are mapped to black and white corresponding to these values. Default maps between min and max.
- method{‘mip’, ‘iso’, ‘translucent’, ‘additive’}
The render style to use. See corresponding docs for details. Default ‘mip’.
- thresholdfloat
The threshold to use for the isosurafce render style. By default the mean of the given volume is used.
- cmapstr
The colormap to use.
- kwargskeyword arguments.
More args to pass to
Volume
.
- Returns:
- volumeinstance of Volume
The volume visualization.
See also
Volume