diff --git a/src/scientific_plots/two_d_plot.py b/src/scientific_plots/two_d_plot.py deleted file mode 100644 index d816c5b6ac0b5c2a0e9f411ec443f96d1cd8f870..0000000000000000000000000000000000000000 --- a/src/scientific_plots/two_d_plot.py +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env python3 -""" -This file contains the settings for 2D surface -plots -""" -from __future__ import annotations - -from os.path import join -from math import pi -from queue import Queue -from threading import Thread -from subprocess import check_output -from typing import ( - List, Tuple, TypeVar, Union, Iterable, Any, Optional) -from pathlib import Path - -import matplotlib as mpl -import matplotlib.pyplot as plt -from numpy import array - -from .plot_settings import apply_styles, rwth_gradient_map -from .types_ import Vector - -mpl.use("Agg") -SURFACEFOLDER = join("simulation", "surface_data") - -In = TypeVar("In", List[float], Tuple[float], - Vector) - - -@apply_styles -def create_two_d_scatter_plot( - X: In, Y: In, Z: In, - folder: Union[str, Path], - plot_title: str, - xlabel: Optional[str], ylabel: Optional[str], zlabel: str)\ - -> None: - """create two_d_plots""" - # rearrange x, y, z to fit the shape needed for the plot - fig = plt.figure() - plt.set_cmap("jet") - - ax = fig.add_subplot(projection="3d") - ax.scatter(Y, X, Z, cmap=rwth_gradient_map) - - if xlabel: - ax.set_ylabel(xlabel) - if ylabel: - ax.set_xlabel(ylabel) - ax.set_zlabel(zlabel) - - plt.tight_layout() - - plt.savefig(join(folder, plot_title.replace(" ", "_") + ".pdf")) - - -@apply_styles -def create_two_d_surface_plot( - X: In, Y: In, Z: In, - folder: Union[str, Path], - plot_title: str, - xlabel: Optional[str], ylabel: Optional[str], zlabel: str)\ - -> None: - """create two_d_plots""" - # rearrange x, y, z to fit the shape needed for the plot - fig = plt.figure() - plt.set_cmap("jet") - Z_flat: Vector = array(Z) - - # X_two_d, Y_two_d=meshgrid(X_flat, Y_flat) - - ax = fig.add_subplot(projection="3d") - # ax.plot_surface(X_two_d, Y_two_d, Z_flat, cmap=rwth_gradient_map) - ax.plot_trisurf(Y, X, Z, cmap=rwth_gradient_map) - - if ylabel: - ax.set_ylabel(ylabel) - if xlabel: - ax.set_xlabel(xlabel) - ax.set_zlabel(zlabel) - - ax.set_zlim(min(Z_flat) * 0.98, max(Z_flat) * 1.05) - ax.set_xlim(min(Y), max(Y)) - ax.set_ylim(min(X), max(X)) - - plt.tight_layout() - - plt.savefig(join(folder, plot_title.replace(" ", "_") + ".pdf")) diff --git a/src/scientific_plots/types_.py b/src/scientific_plots/types_.py index 24aab1adb65405690b4f016bd467bfbe6dfae4af..3710fc5ed2cdd1f252bcf708e8772eda323440f4 100644 --- a/src/scientific_plots/types_.py +++ b/src/scientific_plots/types_.py @@ -9,7 +9,6 @@ import numpy as np from pytest import FixtureRequest if TYPE_CHECKING: - NTensor = np.ndarray[Tuple[int, int, int, int], np.dtype[np.float64]] Tensor = np.ndarray[Tuple[int, int, int], np.dtype[np.float64]] Matrix = np.ndarray[Tuple[int, int], np.dtype[np.float64]] @@ -24,5 +23,4 @@ else: class Request(FixtureRequest): """This is the pytest-fixture request plus the missing attribute 'param'. It contains the given parameters to this object and thus this fixture.""" - param: Any diff --git a/tests/test_plots.py b/tests/test_plots.py index 158c4c3a33d5e4e1cf471f7d97e406fd327dfc1b..e9b6aeb1d9db157b65797725055f4031add32935 100644 --- a/tests/test_plots.py +++ b/tests/test_plots.py @@ -13,6 +13,7 @@ from scientific_plots.types_ import Vector from scientific_plots.plot_settings import read_data_plot from scientific_plots.default_plots import ( plot, two_plots, two_axis_plots, plot_surface) +from scientific_plots import two_d_plot @mark.use_style