-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MeshedRegion.plot() with PropertyField #1526
base: master
Are you sure you want to change the base?
Conversation
Hi @AlejandroFernandezLuces, could you please take a look at this PR? |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1526 +/- ##
==========================================
+ Coverage 84.16% 84.20% +0.03%
==========================================
Files 82 82
Lines 9655 9672 +17
==========================================
+ Hits 8126 8144 +18
+ Misses 1529 1528 -1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think activating categories
flag and using the scalars_bar
is the best way to represent what you want.
A side comment, why are you filling a kwargs
map instead of using the arguments in the function calls? I personally find it clearer to use the parameters directly.
src/ansys/dpf/core/plotter.py
Outdated
kwargs = self._set_scalar_bar_title(kwargs) | ||
kwargs["scalar_bar_args"]["n_labels"] = len(set(field.data)) | ||
kwargs["scalar_bar_args"]["fmt"] = "%.0f" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to directly use the add_scalar_bar
directly, I think something like this should work in this context
kwargs = self._set_scalar_bar_title(kwargs) | |
kwargs["scalar_bar_args"]["n_labels"] = len(set(field.data)) | |
kwargs["scalar_bar_args"]["fmt"] = "%.0f" | |
self._plotter.add_scalar_bar( | |
title='Your title', | |
n_labels=len(set(field.data)) | |
fmt='%.0f', | |
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AlejandroFernandezLuces I think the original idea of using kwargs is to use setdefault
so that if the argument is given as a kwarg to the plot function by the user then it is not overriden by what we put here. I'll improve the code to do that correctly.
Thanks @AlejandroFernandezLuces! |
Not sure what is happening there, you can try to set |
NB: the default cmap used is |
Signed-off-by: paul.profizi <[email protected]>
Signed-off-by: paul.profizi <[email protected]>
Signed-off-by: paul.profizi <[email protected]>
Signed-off-by: paul.profizi <[email protected]>
Signed-off-by: paul.profizi <[email protected]>
Signed-off-by: paul.profizi <[email protected]>
Signed-off-by: paul.profizi <[email protected]>
Signed-off-by: paul.profizi <[email protected]>
3ef8f12
to
c8eb2b3
Compare
os.environ["PYVISTA_OFF_SCREEN"] = "true" | ||
core.settings.bypass_pv_opengl_osmesa_crash() | ||
os.environ["MPLBACKEND"] = "Agg" | ||
# core.settings.disable_off_screen_rendering() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be reverted before merging, right?
@@ -585,6 +597,8 @@ def plot( | |||
show_axes=kwargs.pop("show_axes", True), | |||
**kwargs, | |||
) | |||
if isinstance(field_or_fields_container, PropertyField): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if isinstance(field_or_fields_container, PropertyField): | |
elif isinstance(field_or_fields_container, PropertyField): |
Add the possibility to plot a
PropertyField
on aMeshedRegion
.Will have to add
PropertyField.plot(mesh)
with mandatory mesh as aPropertyField
currently most likely does not have a mesh asosciated.The PyVista options for the scalar bar still need a little bit of tweaking. Some colors are even missing from the scalar bar: