-
Notifications
You must be signed in to change notification settings - Fork 66
add opacity kwrgs for monitor and source in sim.plot #328
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -573,7 +573,14 @@ def background_structure(self) -> Structure: | |
@equal_aspect | ||
@add_ax_if_none | ||
def plot( | ||
self, x: float = None, y: float = None, z: float = None, ax: Ax = None, **patch_kwargs | ||
self, | ||
x: float = None, | ||
y: float = None, | ||
z: float = None, | ||
ax: Ax = None, | ||
source_alpha: float = None, | ||
monitor_alpha: float = None, | ||
**patch_kwargs, | ||
) -> Ax: | ||
"""Plot each of simulation's components on a plane defined by one nonzero x,y,z coordinate. | ||
|
||
|
@@ -585,6 +592,10 @@ def plot( | |
position of plane in y direction, only one of x, y, z must be specified to define plane. | ||
z : float = None | ||
position of plane in z direction, only one of x, y, z must be specified to define plane. | ||
source_alpha : float = None | ||
Opacity of the sources. If ``None``, uses to Tidy3d default. | ||
monitor_alpha : float = None | ||
Opacity of the monitors. If ``None``, uses to Tidy3d default. | ||
ax : matplotlib.axes._subplots.Axes = None | ||
Matplotlib axes to plot on, if not specified, one is created. | ||
|
||
|
@@ -595,8 +606,8 @@ def plot( | |
""" | ||
|
||
ax = self.plot_structures(ax=ax, x=x, y=y, z=z) | ||
ax = self.plot_sources(ax=ax, x=x, y=y, z=z) | ||
ax = self.plot_monitors(ax=ax, x=x, y=y, z=z) | ||
ax = self.plot_sources(ax=ax, x=x, y=y, z=z, alpha=source_alpha) | ||
ax = self.plot_monitors(ax=ax, x=x, y=y, z=z, alpha=monitor_alpha) | ||
ax = self.plot_symmetries(ax=ax, x=x, y=y, z=z) | ||
ax = self.plot_pml(ax=ax, x=x, y=y, z=z) | ||
ax = self._set_plot_bounds(ax=ax, x=x, y=y, z=z) | ||
|
@@ -611,6 +622,8 @@ def plot_eps( # pylint:disable=too-many-arguments | |
z: float = None, | ||
freq: float = None, | ||
alpha: float = None, | ||
source_alpha: float = None, | ||
monitor_alpha: float = None, | ||
ax: Ax = None, | ||
) -> Ax: | ||
"""Plot each of simulation's components on a plane defined by one nonzero x,y,z coordinate. | ||
|
@@ -630,6 +643,10 @@ def plot_eps( # pylint:disable=too-many-arguments | |
alpha : float = None | ||
Opacity of the structures being plotted. | ||
Defaults to the structure default alpha. | ||
source_alpha : float = None | ||
Opacity of the sources. If ``None``, uses to Tidy3d default. | ||
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. "uses Tidy3D default"? (Also next line) |
||
monitor_alpha : float = None | ||
Opacity of the monitors. If ``None``, uses to Tidy3d default. | ||
ax : matplotlib.axes._subplots.Axes = None | ||
Matplotlib axes to plot on, if not specified, one is created. | ||
|
||
|
@@ -640,8 +657,8 @@ def plot_eps( # pylint:disable=too-many-arguments | |
""" | ||
|
||
ax = self.plot_structures_eps(freq=freq, cbar=True, alpha=alpha, ax=ax, x=x, y=y, z=z) | ||
ax = self.plot_sources(ax=ax, x=x, y=y, z=z) | ||
ax = self.plot_monitors(ax=ax, x=x, y=y, z=z) | ||
ax = self.plot_sources(ax=ax, x=x, y=y, z=z, alpha=source_alpha) | ||
ax = self.plot_monitors(ax=ax, x=x, y=y, z=z, alpha=monitor_alpha) | ||
ax = self.plot_symmetries(ax=ax, x=x, y=y, z=z) | ||
ax = self.plot_pml(ax=ax, x=x, y=y, z=z) | ||
ax = self._set_plot_bounds(ax=ax, x=x, y=y, z=z) | ||
|
@@ -871,7 +888,9 @@ def _plot_shape_structure_eps( | |
|
||
@equal_aspect | ||
@add_ax_if_none | ||
def plot_sources(self, x: float = None, y: float = None, z: float = None, ax: Ax = None) -> Ax: | ||
def plot_sources( | ||
self, x: float = None, y: float = None, z: float = None, alpha: float = None, ax: Ax = None | ||
) -> Ax: | ||
"""Plot each of simulation's sources on a plane defined by one nonzero x,y,z coordinate. | ||
|
||
Parameters | ||
|
@@ -882,6 +901,8 @@ def plot_sources(self, x: float = None, y: float = None, z: float = None, ax: Ax | |
position of plane in y direction, only one of x, y, z must be specified to define plane. | ||
z : float = None | ||
position of plane in z direction, only one of x, y, z must be specified to define plane. | ||
alpha : float = None | ||
Opacity of the sources, If ``None`` uses Tidy3d default. | ||
ax : matplotlib.axes._subplots.Axes = None | ||
Matplotlib axes to plot on, if not specified, one is created. | ||
|
||
|
@@ -891,13 +912,15 @@ def plot_sources(self, x: float = None, y: float = None, z: float = None, ax: Ax | |
The supplied or created matplotlib axes. | ||
""" | ||
for source in self.sources: | ||
ax = source.plot(x=x, y=y, z=z, ax=ax) | ||
ax = source.plot(x=x, y=y, z=z, alpha=alpha, ax=ax) | ||
ax = self._set_plot_bounds(ax=ax, x=x, y=y, z=z) | ||
return ax | ||
|
||
@equal_aspect | ||
@add_ax_if_none | ||
def plot_monitors(self, x: float = None, y: float = None, z: float = None, ax: Ax = None) -> Ax: | ||
def plot_monitors( | ||
self, x: float = None, y: float = None, z: float = None, alpha: float = None, ax: Ax = None | ||
) -> Ax: | ||
"""Plot each of simulation's monitors on a plane defined by one nonzero x,y,z coordinate. | ||
|
||
Parameters | ||
|
@@ -908,6 +931,8 @@ def plot_monitors(self, x: float = None, y: float = None, z: float = None, ax: A | |
position of plane in y direction, only one of x, y, z must be specified to define plane. | ||
z : float = None | ||
position of plane in z direction, only one of x, y, z must be specified to define plane. | ||
alpha : float = None | ||
Opacity of the sources, If ``None`` uses Tidy3d default. | ||
ax : matplotlib.axes._subplots.Axes = None | ||
Matplotlib axes to plot on, if not specified, one is created. | ||
|
||
|
@@ -917,7 +942,7 @@ def plot_monitors(self, x: float = None, y: float = None, z: float = None, ax: A | |
The supplied or created matplotlib axes. | ||
""" | ||
for monitor in self.monitors: | ||
ax = monitor.plot(x=x, y=y, z=z, ax=ax) | ||
ax = monitor.plot(x=x, y=y, z=z, alpha=alpha, ax=ax) | ||
ax = self._set_plot_bounds(ax=ax, x=x, y=y, z=z) | ||
return ax | ||
|
||
|
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.
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.
"uses Tidy3D default"? (Also next line)
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.
oops, just saw these. thanks. will fix