-
Notifications
You must be signed in to change notification settings - Fork 23
Fixes the use of notebook argument for plot commands #259
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
147c358
Fixes the use of notebook argument for plot commands going through Pl…
PProfizi ad5a855
Fixing kwargs in plot_contour for call to pv.Plotter.show with cpos_r…
PProfizi db48fa9
Update the example to show "notebook=False" is required for screensho…
PProfizi 064a6a5
Merge branch 'master' into fix/notebook_false_for_fields
PProfizi a8ae193
Fix an error with pv.Plotter.__init__
PProfizi bd14d2f
Fix support for cpos_return
PProfizi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,7 +67,7 @@ def __init__(self, **kwargs): | |
) | ||
# Filter kwargs | ||
kwargs_in = _sort_supported_kwargs( | ||
bound_method=pv.Plotter, | ||
bound_method=pv.Plotter.__init__, | ||
**kwargs) | ||
# Initiate pyvista Plotter | ||
self._plotter = pv.Plotter(**kwargs_in) | ||
|
@@ -601,10 +601,7 @@ def plot_chart(fields_container, off_screen=False, screenshot=None): | |
def plot_contour( | ||
self, | ||
field_or_fields_container, | ||
notebook=None, | ||
shell_layers=None, | ||
off_screen=None, | ||
show_axes=True, | ||
meshed_region=None, | ||
**kwargs | ||
): | ||
|
@@ -617,20 +614,9 @@ def plot_contour( | |
---------- | ||
field_or_fields_container : dpf.core.Field or dpf.core.FieldsContainer | ||
Field or field container that contains the result to plot. | ||
notebook : bool, optional | ||
Whether to plot a static image within an iPython notebook | ||
if available. The default is `None`, in which case an attempt is | ||
made to plot a static imaage within an iPython notebook. When ``False``, | ||
a plot external to the notebook is generated with an interactive window. | ||
When ``True``, a plot is always generated within a notebook. | ||
shell_layers : core.shell_layers, optional | ||
Enum used to set the shell layers if the model to plot | ||
contains shell elements. | ||
off_screen : bool, optional | ||
Whether to render off screen, which is useful for automated | ||
screenshots. The default is ``None``. | ||
show_axes : bool, optional | ||
Whether to show a VTK axes widget. The default is ``True``. | ||
**kwargs : optional | ||
Additional keyword arguments for the plotter. For more information, | ||
see ``help(pyvista.plot)``. | ||
|
@@ -726,51 +712,44 @@ def plot_contour( | |
overall_data[ind] = field.data[mask] | ||
|
||
# create the plotter and add the meshes | ||
background = kwargs.pop("background", None) | ||
cpos = kwargs.pop("cpos", None) | ||
return_cpos = kwargs.pop("return_cpos", None) | ||
|
||
# plotter = pv.Plotter(notebook=notebook, off_screen=off_screen) | ||
if notebook is not None: | ||
self._internal_plotter._plotter.notebook = notebook | ||
if off_screen is not None: | ||
self._internal_plotter._plotter.off_screen = off_screen | ||
|
||
# add meshes | ||
kwargs.setdefault("show_edges", True) | ||
kwargs.setdefault("nan_color", "grey") | ||
kwargs.setdefault("stitle", name) | ||
|
||
text = kwargs.pop('text', None) | ||
if text is not None: | ||
self._internal_plotter._plotter.add_text(text, position='lower_edge') | ||
kwargs.pop("title", None) | ||
|
||
kwargs_in = _sort_supported_kwargs( | ||
bound_method=self._internal_plotter._plotter.add_mesh, | ||
**kwargs | ||
) | ||
self._internal_plotter._plotter.add_mesh(mesh.grid, scalars=overall_data, **kwargs_in) | ||
|
||
background = kwargs.pop("background", None) | ||
if background is not None: | ||
self._internal_plotter._plotter.set_background(background) | ||
|
||
cpos = kwargs.pop("cpos", None) | ||
if cpos is not None: | ||
self._internal_plotter._plotter.camera_position = cpos | ||
|
||
# show result | ||
if show_axes: | ||
self._internal_plotter._plotter.add_axes() | ||
return_cpos = kwargs.pop("return_cpos", None) | ||
kwargs_in = _sort_supported_kwargs( | ||
bound_method=self._internal_plotter._plotter.show, | ||
**kwargs) | ||
if return_cpos is None: | ||
kwargs_in = _sort_supported_kwargs( | ||
bound_method=self._internal_plotter._plotter.show, | ||
**kwargs) | ||
return self._internal_plotter._plotter.show(**kwargs_in) | ||
else: | ||
import pyvista as pv | ||
pv_version = pv.__version__ | ||
version_to_reach = '0.32.0' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @anslpa I did, I found a bug, I fixed it, it should work :) |
||
meet_ver = meets_version(pv_version, version_to_reach) | ||
if meet_ver: | ||
return self._internal_plotter._plotter.show(return_cpos=return_cpos) | ||
return self._internal_plotter._plotter.show(return_cpos=return_cpos, **kwargs_in) | ||
else: | ||
txt = """To use the return_cpos option, please upgrade | ||
your pyvista module with a version higher than """ | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.