Skip to content

Domain iPython display #179

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 1 commit into from
Oct 18, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions spatialpy/Domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,9 @@ def __str__(self):

return "\n".join(domain_strs)

def _ipython_display_(self, use_matplotlib=False):
self.plot_types(width="auto", height="auto", use_matplotlib=use_matplotlib)

def add_point(self, x, vol, mass, type, nu, fixed):
""" Add a single point particle to the domain space.

Expand Down Expand Up @@ -347,10 +350,14 @@ def plot_types(self, width=None, height=None, colormap=None, size=5, title=None,
:type use_matplotlib: bool
'''

if width is None:
width = 6.4 if use_matplotlib else 500
if height is None:
height = 4.8 if use_matplotlib else 500
if use_matplotlib:
width = 6.4 if width in (None, "auto") else width
height = 4.8 if height in (None, "auto") else height
else:
if width in (None, "auto"):
width = None if width == "auto" else 500
if height is None:
height = None if height == "auto" else 500

if not numpy.count_nonzero(self.vertices[:,1]):
self.dimensions = 1
Expand Down