pyvista.Renderer.remove_chart

pyvista.Renderer.remove_chart#

Renderer.remove_chart(chart_or_index)[source]#

Remove a chart from this renderer.

Parameters:
chart_or_indexChart or int

Either the chart to remove from this renderer or its index in the collection of charts.

Examples

First define a function to add two charts to a renderer.

>>> import pyvista as pv
>>> def plotter_with_charts():
...     pl = pv.Plotter()
...     pl.background_color = 'w'
...     chart_left = pv.Chart2D(size=(0.5, 1))
...     _ = chart_left.line([0, 1, 2], [2, 1, 3])
...     pl.add_chart(chart_left)
...     chart_right = pv.Chart2D(size=(0.5, 1), loc=(0.5, 0))
...     _ = chart_right.line([0, 1, 2], [3, 1, 2])
...     pl.add_chart(chart_right)
...     return pl, chart_left, chart_right
...
>>> pl, *_ = plotter_with_charts()
>>> pl.show()
../../../_images/pyvista-Renderer-remove_chart-1_00_00.png

Now reconstruct the same plotter but remove the right chart by index.

>>> pl, *_ = plotter_with_charts()
>>> pl.remove_chart(1)
>>> pl.show()
../../../_images/pyvista-Renderer-remove_chart-1_01_00.png

Finally, remove the left chart by reference.

>>> pl, chart_left, chart_right = plotter_with_charts()
>>> pl.remove_chart(chart_left)
>>> pl.show()
../../../_images/pyvista-Renderer-remove_chart-1_02_00.png