Skip to content

Commit

Permalink
ex16 - recent code for ticks to work with older matplotlib
Browse files Browse the repository at this point in the history
  • Loading branch information
rpoleski committed Jun 3, 2024
1 parent a136ed3 commit da1c56d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions examples/example_16/ulens_model_fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
except Exception:
raise ImportError('\nYou have to install MulensModel first!\n')

__version__ = '0.36.1'
__version__ = '0.36.2'


class UlensModelFit(object):
Expand Down Expand Up @@ -3143,7 +3143,12 @@ def _mark_second_Y_axis_in_best_plot(self):
return

ticks = mm.Utils.get_mag_from_flux(flux)
ax2.set_yticks(ticks, labels)
try: # matplotlib version 3.5 or later
ax2.set_yticks(ticks=ticks, labels=labels)
except Exception: # matplotlib version 3.4.X or smaller
ax2.set_yticks(ticks=ticks)
ax2.set_yticklabels(labels=labels)

ax2.set_ylim(ylim[0], ylim[1])

def _second_Y_axis_settings(self):
Expand Down Expand Up @@ -3209,7 +3214,7 @@ def _second_Y_axis_minor_ticks(self, ax2, A_values, ref_fluxes):
Get minor ticks for magnification axis from matplotlib
"""
ax2.minorticks_on()
minor_ticks_A = ax2.yaxis.get_ticklocs(minor=True)
minor_ticks_A = np.array(ax2.yaxis.get_ticklocs(minor=True))
minor_ticks_A = minor_ticks_A[~np.isin(minor_ticks_A, A_values)]

minor_ticks_flux = ref_fluxes[0] * minor_ticks_A + ref_fluxes[1]
Expand Down

0 comments on commit da1c56d

Please sign in to comment.