pyvista.Renderer.set_color_cycler

pyvista.Renderer.set_color_cycler#

Renderer.set_color_cycler(color_cycler) None[ソース]#

このレンダラーのカラーサイクラーを設定またはリセットします.

このカラーサイクラーは,プロットされるデータセットのデフォルトカラーを設定するために,連続した add_mesh() の呼び出しによって反復されます.

設定するとき,値は色のようなオブジェクトのリスト,または色のようなオブジェクトのサイクラーのいずれかでなければなりません.渡された値が単一の文字列である場合,それは以下のうちの1つでなければなりません.

  • 'default' - デフォルトのカラーサイクラーを使用します (matplotlib のデフォルトと一致します)

  • 'matplotlib - Matplotlib の現在のテーマのカラーサイクラーを動的に返します.

  • 'all' - pyvista.plotting.colors.hexcolors で利用可能なすべての色を循環させます.

None に設定すると,このレンダラーでのカラーサイクラーの使用を無効にします.

注釈

If a mesh has scalar data, set color=True in the call to add_mesh() to color the mesh with the next color in the cycler. Otherwise the mesh's scalars are used to color the mesh by default.

パラメータ:
color_cyclerstr | cycler.Cycler | sequence[ColorLike]

循環させる色.

デフォルトのカラーサイクラーで,赤,緑,青を反復するように設定します.

>>> import pyvista as pv
>>> pl = pv.Plotter()
>>> pl.renderer.set_color_cycler(['red', 'green', 'blue'])
>>> _ = pl.add_mesh(pv.Cone(center=(0, 0, 0)))  # red
>>> _ = pl.add_mesh(pv.Cube(center=(1, 0, 0)))  # green
>>> _ = pl.add_mesh(pv.Sphere(center=(1, 1, 0)))  # blue
>>> _ = pl.add_mesh(pv.Cylinder(center=(0, 1, 0)))  # red again
>>> pl.show()
../../../_images/pyvista-Renderer-set_color_cycler-1_00_00.png

Load a mesh with active scalars and split it into two separate meshes.

>>> mesh = pv.Wavelet()
>>> mesh.active_scalars_name
'RTData'
>>> a = mesh.clip(invert=True)
>>> b = mesh.clip(invert=False)

Enable color cycling and set color=True to force the meshes to be colored with the cycler's colors.

>>> pv.global_theme.color_cycler = 'default'
>>> pl = pv.Plotter()
>>> _ = pl.add_mesh(a, color=True)
>>> _ = pl.add_mesh(b, color=True)
>>> pl.show()
../../../_images/pyvista-Renderer-set_color_cycler-1_01_00.png