DataVisualizationcurrently exposes several plotting utilities only as @staticmethods (plot_series, plot_multiple_series, correlation_heatmap, plot_fft, etc.).
The idea is to refactor this so that each plot is implemented as its own class while keeping the current static API working.
This should allow both styles:
# New style (OO)
plot = PlotSeries(data, title="...")
fig, path = plot.plot()
# Old style (still supported)
fig, path = DataVisualization.plot_series(data, title="...")
Proposal
- Add a common base class:
from abc import ABC, abstractmethod
from matplotlib.figure import Figure
class BaseVisualizer(ABC):
@abstractmethod
def plot(self) -> tuple[Figure, str]:
...
- For each existing static method, create a visualizer class:
class PlotSeries(BaseVisualizer):
def __init__(self, series, title: str = "", save_path: str | None = None):
self.series = series
self.title = title
self.save_path = save_path
def plot(self) -> tuple[Figure, str]:
# plotting logic
path = DataVisualization._save_plot(...)
return fig, path
- Keep
DataVisualization as a façade that delegates to the classes:
class DataVisualization(ABC):
@staticmethod
def plot_series(series, title: str = "", save_path: str | None = None):
return PlotSeries(series, title=title, save_path=save_path).plot()
# Other methods follow the same pattern
DataVisualizationcurrently exposes several plotting utilities only as@staticmethods (plot_series,plot_multiple_series,correlation_heatmap,plot_fft, etc.).The idea is to refactor this so that each plot is implemented as its own class while keeping the current static API working.
This should allow both styles:
Proposal
DataVisualizationas a façade that delegates to the classes: