pyvista.ChartMPL

class ChartMPL(figure=None, size=(1, 1), loc=(0, 0))

Create new chart from an existing matplotlib figure.

Parameters
figurematplotlib.figure.Figure

The matplotlib figure to draw.

sizelist or tuple, optional

Size of the chart in normalized coordinates. A size of (0, 0) is invisible, a size of (1, 1) occupies the whole renderer’s width and height.

loclist or tuple, optional

Location of the chart (its bottom left corner) in normalized coordinates. A location of (0, 0) corresponds to the renderer’s bottom left corner, a location of (1, 1) corresponds to the renderer’s top right corner.

Examples

Plot streamlines of a vector field with varying colors (based on this example).

>>> import pyvista
>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> w = 3
>>> Y, X = np.mgrid[-w:w:100j, -w:w:100j]
>>> U = -1 - X**2 + Y
>>> V = 1 + X - Y**2
>>> speed = np.sqrt(U**2 + V**2)
>>> f, ax = plt.subplots()
>>> strm = ax.streamplot(X, Y, U, V, color=U, linewidth=2, cmap='autumn')
>>> _ = f.colorbar(strm.lines)
>>> _ = ax.set_title('Streamplot with varying Color')
>>> plt.tight_layout()
>>> chart = pyvista.ChartMPL(f)
>>> chart.show()
../../../../_images/pyvista-ChartMPL-1_00_00.png

Methods

ChartMPL.show([off_screen, full_screen, ...])

Show this chart in a self contained plotter.

ChartMPL.toggle()

Toggle the chart's visibility.

Attributes

ChartMPL.background_color

Return or set the chart's background color.

ChartMPL.background_texture

Return or set the chart's background texture.

ChartMPL.border_color

Return or set the chart's border color.

ChartMPL.border_style

Return or set the chart's border style.

ChartMPL.border_width

Return or set the chart's border width.

ChartMPL.figure

Retrieve the matplotlib figure associated with this chart.

ChartMPL.legend_visible

Return or set the visibility of the chart's legend.

ChartMPL.loc

Return or set the chart position in normalized coordinates.

ChartMPL.position

Chart position w.r.t the bottom left corner (in pixels).

ChartMPL.size

Return or set the chart size in normalized coordinates.

ChartMPL.title

Return or set the chart's title.

ChartMPL.visible

Return or set the chart's visibility.