Skip to content

Commit

Permalink
Only apply inaccurate axis label transparency to x axis labels
Browse files Browse the repository at this point in the history
  • Loading branch information
scottshambaugh committed Dec 18, 2023
1 parent 44b8470 commit 9f0fc53
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
### Added
* AxesAnaglyph for red-cyan anaglyphs
### Changed
* Only apply inaccurate axis label transparency to x axis labels
### Removed


Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ axstereo.scatter(x, y, z, c=z, cmap='viridis', s=10)
</p>
When you are viewing the stereogram properly, you should see the knot weave in and out of the page!

*Warning*: Please note that for 2D plots the stereoscopic effect requires shifting data, so the data will *not* necessarily line up with the axis labels! Right now this is controlled with the `focal_plane` parameter. Calling `AxesStereo2D(focal_plane=-1)` (the default) will ensure that the left axes data is not shifted, whereas `AxesStereo2D(focal_plane=1)` will lock down the right axes data. The tick labels for axes where the data is not aligned will have transparency applied. So in the plot above, the right side labels being lighter gray indicates that you should not trust that data to be positioned correctly, but the left subplot with its black labeling is accurate.
*Warning*: Please note that for 2D plots the stereoscopic effect requires shifting data, so the data will *not* necessarily line up with the x-axis labels! Right now this is controlled with the `focal_plane` parameter. Calling `AxesStereo2D(focal_plane=-1)` (the default) will ensure that the left x-axis data is not shifted, whereas `AxesStereo2D(focal_plane=1)` will lock down the right x-axis data. The tick labels for x-axes where the data is not aligned will have transparency applied. So in the plot above, the right side labels being lighter gray indicates that you should not trust that x-axis data to be positioned correctly, but the left subplot with its black labeling is accurate.

### 3D Stereogram plots
The stereoscopic effect in 3D is made just by rotating the plot view, so all of matplotlib's 3D plot types are supported, and there are no concerns about data not lining up with the axis labels.
Expand Down
Binary file modified docs/trefoil_2d.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 2 additions & 7 deletions src/mpl_stereo/AxesStereo.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,8 @@ def __init__(self,
is_3d=False)
self.known_methods = ['plot', 'scatter', 'stem', 'bar']

# Turn on all the axis labels then make semitransparent not accurate at the edges
self.ax_right.yaxis.set_tick_params(labelleft=True)
self.set_axlabel_alphas(0.5)
# Give the innacurate x-axis labels some transparency
self.set_axlabel_alphas(alpha=0.5)

def __getattr__(self, name: str):
"""
Expand Down Expand Up @@ -225,13 +224,9 @@ def set_axlabel_alphas(self, alpha: float):
if self.focal_plane != -1:
for label in self.ax_left.get_xticklabels():
label.set_alpha(alpha)
for label in self.ax_left.get_yticklabels():
label.set_alpha(alpha)
elif self.focal_plane != 1:
for label in self.ax_right.get_xticklabels():
label.set_alpha(alpha)
for label in self.ax_right.get_yticklabels():
label.set_alpha(alpha)


class AxesStereo3D(AxesStereo):
Expand Down

0 comments on commit 9f0fc53

Please sign in to comment.