How can I change legend bands and reflect those results on the mesh?
Ayush Kumar
Member, Moderator, Employee Posts: 468
✭✭✭✭
in Structures
Comments
-
You need to define
scalar_bar_args
argument for theplotter.add_field
method. This will change only legend properties. To sync it with mesh, use same values forn_colors
andn_labels
as direct argument forplotter.add_field
.import os from ansys.dpf import core as dpf from ansys.dpf.core.plotter import DpfPlotter out_path = r"\PATH\TO\RST" rst_path = os.path.join(out_path, "file.rst") ds = dpf.DataSources(rst_path) model = dpf.Model(ds) mesh = model.metadata.meshed_region nsn = ["B1", "B2"] for ns in nsn: mesh_scoping = dpf.operators.scoping.on_named_selection(named_selection_name=ns, data_sources=ds).outputs.mesh_scoping() mesh_region = dpf.operators.mesh.from_scoping(scoping=mesh_scoping, mesh=mesh).outputs.mesh() elastic_strain = dpf.operators.result.elastic_strain(data_sources=ds, requested_location="Nodal", mesh_scoping=mesh_scoping) es_f = elastic_strain.outputs.fields_container()[0] plotter = DpfPlotter() sargs = dict(title="Legend", fmt="%.2e", title_font_size=30, label_font_size=20, n_labels=3, n_colors=2) plotter.add_field(es_f, meshed_region=mesh_region, label_text_size=15, label_point_size=5, scalar_bar_args=sargs, n_colors=2, n_labels=3) plotter.show_figure()
0