Skip to content

Commit

Permalink
Fix y axis (#123)
Browse files Browse the repository at this point in the history
* refactor: rmv CallCurator

* fix error where some ticks that should be been made invisible remained on the y axis

* fix hiding axis elements. Generate new test figures

* update test figures
  • Loading branch information
bendichter authored Sep 18, 2024
1 parent 3ff20da commit 042e2fa
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 12 deletions.
22 changes: 12 additions & 10 deletions brokenaxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ def __init__(
self.draw_diags()
self.set_spines()

def _calculate_ratios(self, lims, scale):
@staticmethod
def _calculate_ratios(lims, scale):
"""
Calculate width or height ratios based on axis limits and scale.
Expand Down Expand Up @@ -229,29 +230,30 @@ def draw_diags(self, d=None, tilt=None):

def set_spines(self):
"""Removes the spines of internal axes that are not boarder spines."""

# Helper function to hide axis elements
def hide_axis_elements(axis):
for element in (axis.get_majorticklines() + axis.get_minorticklines() +
axis.get_majorticklabels() + axis.get_minorticklabels()):
element.set_visible(False)

for ax in self.axs:
ax.xaxis.tick_bottom()
ax.yaxis.tick_left()
subplotspec = ax.get_subplotspec()
if not subplotspec.is_last_row():
ax.spines["bottom"].set_visible(False)
plt.setp(ax.xaxis.get_minorticklabels(), visible=False)
plt.setp(ax.xaxis.get_minorticklines(), visible=False)
plt.setp(ax.xaxis.get_majorticklabels(), visible=False)
plt.setp(ax.xaxis.get_majorticklines(), visible=False)
hide_axis_elements(ax.xaxis)
if self.despine or not subplotspec.is_first_row():
ax.spines["top"].set_visible(False)
if not subplotspec.is_first_col():
ax.spines["left"].set_visible(False)
plt.setp(ax.yaxis.get_minorticklabels(), visible=False)
plt.setp(ax.yaxis.get_minorticklines(), visible=False)
plt.setp(ax.yaxis.get_majorticklabels(), visible=False)
plt.setp(ax.yaxis.get_majorticklines(), visible=False)
hide_axis_elements(ax.yaxis)
if self.despine or not subplotspec.is_last_col():
ax.spines["right"].set_visible(False)

def standardize_ticks(self, xbase=None, ybase=None):
"""Make all of the internal axes share tick bases
"""Make all the internal axes share tick bases
Parameters
----------
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

setup(
name='brokenaxes',
version='0.6.1',
version='0.6.2',
description='Create broken axes',
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down
2 changes: 1 addition & 1 deletion test.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def test_text():

@pytest.mark.mpl_image_compare
def test_lims_arrays():
lims = np.arange(6).reshape((-1,2))
lims = np.arange(6).reshape((-1, 2))
brokenaxes(xlims=lims, ylims=lims)

return plt.gcf()
Expand Down
Binary file modified test_baseline/test_datetime.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test_baseline/test_datetime_y.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test_baseline/test_log.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 042e2fa

Please sign in to comment.