Skip to content
Snippets Groups Projects
Commit 52ca8db0 authored by Felix Fischer's avatar Felix Fischer :shrimp:
Browse files

Add import of scienceplots

parent 9f313b0a
Branches
No related tags found
1 merge request!53Plot import
......@@ -5,4 +5,4 @@ useful across several different projects and repositories. It also contains
stub-files with several data-type annotations for scipy and matplot-lib
functions."""
__version__ = "1.8.1"
__version__ = "1.8.2"
......@@ -24,6 +24,7 @@ mpl.use("Agg")
In = TypeVar("In", List[float], Tuple[float],
Vector)
# pylint: disable=invalid-name
In2D = TypeVar("In2D", List[List[float]], List[Vector], Tuple[Vector],
Matrix)
......@@ -239,6 +240,7 @@ def plot_surface(X: In2D, Y: In2D, Z: In2D,
antialiased: bool = True,
rcount: int = 200, ccount: int = 200) -> None:
"""create a 2D surface plot of meshgrid-like valued Xs, Ys and Zs"""
# pylint: disable=too-many-branches
if not check_inputs(
np.array(X).flatten(),
np.array(Z).flatten(), xlabel, zlabel):
......@@ -409,8 +411,8 @@ def two_plots(x1: In, y1: In, label1: str,
if xlim is not None:
pass
elif outer:
xlim = (min(min(x1), min(x2)),
max(max(x1), max(x2)))
xlim = (min(*x1, *x2),
max(*x1, *x2))
else:
xlim = (max(min(x1), min(x2)),
min(max(x1), max(x2)))
......@@ -473,8 +475,8 @@ def three_plots(x1: In, y1: In, label1: str,
plt.plot(x3, y3, label=label3, linestyle="dotted")
plt.xlabel(xlabel)
plt.ylabel(ylabel)
min_ = min(min(y1), min(y2), min(y3))
max_ = max(max(y1), max(y2), max(y3))
min_ = min(*y1, *y2, *y3)
max_ = max(*y1, *y2, *y3)
if not logscale:
plt.ylim(
min_ - (max_ - min_) * 0.02,
......
......@@ -18,6 +18,8 @@ from pathlib import Path
from warnings import warn, catch_warnings, simplefilter
from textwrap import dedent
# pylint: disable=unused-import
import scienceplots # noqa: F401
import mpl_toolkits
import matplotlib as mpl
import matplotlib.pyplot as plt
......
......@@ -145,7 +145,7 @@ def write_file(filename: Union[Path, str],
"""write the rows given in 'arga' to a file"""
# write data to a file
if not any(args[0]):
raise Exception("Tried to write an empty row to a file")
raise ValueError("Tried to write an empty row to a file.")
if isinstance(filename, str):
filename = Path(filename)
with open(filename, "w", encoding="utf-8") as output_file:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment