Да, это, естественно, можно сделать, и вы уже знаете ключевые слова, которые нужно использовать: label
и legend
:
import pyvista as pv
from pyvista import examples
unstructured = examples.load_hexbeam()
poly = examples.load_ant()
poly.points /= 10
poly.points += [0, 2, 3]
plotter = pv.Plotter()
plotter.add_mesh(unstructured, color=[0.6, 0.2, 0.1], label='beamy')
plotter.add_mesh(poly, color=[0.1, 0.6, 0.6], label='anty')
plotter.add_legend()
plotter.show()
As you can see the strings passed as the label
keyword argument of add_mesh
turn into labels in a legend which you can enable with the add_legend()
call. For customization options of the legend см. Документацию .