To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit 33150107 authored by Cyrill Mast's avatar Cyrill Mast
Browse files

added method to only show selected figure

parent 24d6e31f
Pipeline #88886 passed with stages
in 4 minutes and 49 seconds
......@@ -23,7 +23,6 @@ class PlotGeneral:
self._fig, self._ax = plt.subplots()
self._ax.plot(self.x_data, self.y_data)
plt.style.use('ggplot')
"""
......@@ -37,6 +36,7 @@ class PlotGeneral:
@x_data.setter
def x_data(self, value):
self._ax.lines[0].set_xdata(value)
self._ax.set_xlim(min(value), max(value))
self._x_data.value = value
@property
......@@ -46,6 +46,7 @@ class PlotGeneral:
@y_data.setter
def y_data(self, value):
self._ax.lines[0].set_ydata(value)
self._ax.set_ylim(min(value), max(value))
self._y_data.value = value
@property
......@@ -86,3 +87,9 @@ class PlotGeneral:
"""
d_out = d_in
return d_out
def figshow(self, figure):
for i in plt.get_fignums():
if figure != plt.figure(i):
plt.close(plt.figure(i))
plt.show()
import matplotlib.pyplot as plt
import numpy as np
from .plot_General import PlotGeneral
......@@ -22,7 +21,7 @@ class PlotVarious(PlotGeneral):
self.x_label = "n"
self.y_label = "A_n"
self.title = "The first {} coefficients of A_n".format(self.res)
plt.show()
self.figshow(self._fig)
def plot_B_n(self, res=None) -> None:
"""
......@@ -35,7 +34,7 @@ class PlotVarious(PlotGeneral):
self.x_label = "n"
self.y_label = "B_n"
self.title = "The first {} coefficients of B_n".format(self.res)
plt.show()
self.figshow(self._fig)
def plot_K_n(self, res=None) -> None:
"""
......@@ -48,8 +47,7 @@ class PlotVarious(PlotGeneral):
self.x_label = "n"
self.y_label = "K_n"
self.title = "The first {} coefficients of K_n".format(self.res)
plt.show()
self.figshow(self._fig)
def plot_M_n(self, res=None) -> None:
"""
......@@ -62,7 +60,7 @@ class PlotVarious(PlotGeneral):
self.x_label = "n"
self.y_label = "M_n"
self.title = "The first {} coefficients of M_n".format(self.res)
plt.show()
self.figshow(self._fig)
def plot_f1(self, res=None) -> None:
"""
......@@ -73,6 +71,6 @@ class PlotVarious(PlotGeneral):
self.x_data = np.linspace(0, self.res - 1, self.res)
self.y_data = [self.b.f1 for n in self.x_data]
self.x_label = "n"
self.y_label = "M_n"
self.y_label = "f1"
self.title = "The first {} coefficients of f1".format(self.res)
plt.show()
self.figshow(self._fig)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment