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

remove two d scatter plots

parent a8194748
No related branches found
No related tags found
1 merge request!51Stix
Pipeline #1120560 failed
#!/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"))
......@@ -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
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment