Skip to content

Commit

Permalink
fix: Remove scienceplots import
Browse files Browse the repository at this point in the history
  • Loading branch information
Beforerr committed Nov 22, 2024
1 parent 2928a76 commit 48a6b4b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 28 deletions.
15 changes: 0 additions & 15 deletions notebooks/utils/01_plotting.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
"source": [
"# | default_exp utils/plot\n",
"# | export\n",
"import matplotlib.pyplot as plt\n",
"\n",
"import xarray as xr\n",
"import pandas as pd\n",
"from datetime import datetime\n",
Expand All @@ -34,19 +32,6 @@
"### MVA plotting"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# | export\n",
"import importlib.util\n",
"\n",
"if importlib.util.find_spec(\"scienceplots\") is not None:\n",
" plt.style.use([\"science\", \"nature\", \"notebook\"])"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down
18 changes: 5 additions & 13 deletions src/discontinuitypy/utils/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
'plot_event', 'plot_candidates']

# %% ../../../notebooks/utils/01_plotting.ipynb 0
import matplotlib.pyplot as plt

import xarray as xr
import pandas as pd
from datetime import datetime
Expand All @@ -24,17 +22,11 @@
from loguru import logger

# %% ../../../notebooks/utils/01_plotting.ipynb 2
import importlib.util

if importlib.util.find_spec("scienceplots") is not None:
plt.style.use(["science", "nature", "notebook"])

# %% ../../../notebooks/utils/01_plotting.ipynb 3
def time_stamp(ts):
"Return POSIX timestamp as float."
return pd.Timestamp(ts, tz="UTC").timestamp()

# %% ../../../notebooks/utils/01_plotting.ipynb 4
# %% ../../../notebooks/utils/01_plotting.ipynb 3
def setup_mva_tplot_base(
tname: str,
mva_tname: str,
Expand Down Expand Up @@ -69,7 +61,7 @@ def ts_mva(

return ts

# %% ../../../notebooks/utils/01_plotting.ipynb 5
# %% ../../../notebooks/utils/01_plotting.ipynb 4
def setup_mva_plot(
data: xr.DataArray,
tstart: datetime,
Expand Down Expand Up @@ -113,7 +105,7 @@ def set_mva_tname_option(
options(tname, "ysubtitle", type_options["subtitle"])
options(tname, "legend_names", type_options["legend_names"])

# %% ../../../notebooks/utils/01_plotting.ipynb 6
# %% ../../../notebooks/utils/01_plotting.ipynb 5
def format_candidate_title(candidate: dict):
def format_float(x):
return rf"$\bf {x:.2f} $" if isinstance(x, (float, int)) else rf"$\bf {x} $"
Expand All @@ -126,7 +118,7 @@ def format_float(x):
{info_line}"""
return title

# %% ../../../notebooks/utils/01_plotting.ipynb 7
# %% ../../../notebooks/utils/01_plotting.ipynb 6
def plot_candidate(
event: dict,
data: xr.DataArray,
Expand Down Expand Up @@ -235,7 +227,7 @@ def plot_candidate(

return fig, axes

# %% ../../../notebooks/utils/01_plotting.ipynb 8
# %% ../../../notebooks/utils/01_plotting.ipynb 7
def plot_event(self: IDsDataset, event=None, index=None, **kwargs):
if event is None:
event = self.get_event(index)
Expand Down

0 comments on commit 48a6b4b

Please sign in to comment.