Skip to content

docs(tick-change): add deprecation warning #19

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
Aug 14, 2023
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
23 changes: 16 additions & 7 deletions cosmoplots/axes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Module for modifying the axis properties of plots."""

import warnings

import matplotlib.pyplot as plt
import numpy as np
from matplotlib import ticker
Expand Down Expand Up @@ -34,6 +36,11 @@ def change_log_axis_base(axes: plt.Axes, which: str, base: float = 10) -> plt.Ax
ValueError
If the axes given in `which` is not `x`, `y` or `both`.
"""
warnings.warn(
"The 'change_log_axis_base' function is deprecated and will be removed in the"
" next major version release of cosmoplots, v1.0.0. Instead, use the `mplstyle`"
" files to set the figure dimensions: \nplt.style.use('cosmoplots.default')"
)
if which == "both":
axs, pltype = ["xaxis", "yaxis"], "loglog"
elif which == "x":
Expand All @@ -49,13 +56,15 @@ def change_log_axis_base(axes: plt.Axes, which: str, base: float = 10) -> plt.Ax
f = getattr(axes, ax)
f.set_major_formatter(
ticker.FuncFormatter(
lambda x, _: r"${:g}$".format(x)
if np.log(x) / np.log(base) in [0, 1]
else r"$"
+ str(base)
+ "^{"
+ "{:g}".format(np.log(x) / np.log(base))
+ r"}$"
lambda x, _: (
r"${:g}$".format(x)
if np.log(x) / np.log(base) in [0, 1]
else r"$"
+ str(base)
+ "^{"
+ "{:g}".format(np.log(x) / np.log(base))
+ r"}$"
)
)
)
return axes