Skip to content

Commit

Permalink
Merge pull request #758 from pfebrer/plots_update
Browse files Browse the repository at this point in the history
Added declaration of some attributes in Figure
  • Loading branch information
zerothi authored Apr 23, 2024
2 parents 8975066 + a9fad0f commit 005c5ba
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/sisl/viz/figure/figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class Figure:
_SUBPLOTS = 3
_ANIMATION = 4

plot_actions: list = []

def __init__(self, plot_actions, *args, **kwargs):
self.plot_actions = plot_actions
self._build(plot_actions, *args, **kwargs)
Expand Down
4 changes: 4 additions & 0 deletions src/sisl/viz/figure/matplotlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import itertools
import math
from typing import Optional

import matplotlib
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -33,6 +34,9 @@ class MatplotlibFigure(Figure):

_axes_defaults = {}

figure: Optional[plt.Figure] = None
axes: Optional[plt.Axes] = None

def _init_figure(self, *args, **kwargs):
self.figure, self.axes = self._init_plt_figure()
self._init_axes()
Expand Down
2 changes: 2 additions & 0 deletions src/sisl/viz/figure/plotly.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ class PlotlyFigure(Figure):

_layout_defaults = {}

figure: Optional[go.Figure] = None

def _init_figure(self, *args, **kwargs):
self.figure = go.Figure()
self.update_layout(**self._layout_defaults)
Expand Down
7 changes: 1 addition & 6 deletions src/sisl/viz/plots/merged.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,8 @@ def merge_plots(
which controls the arrangement ("rows", "cols" or "square").
"""

def _san_plot(plot):
if isinstance(plot, Plot) and plot._nupdates == 0:
plot.get()
return plot

plot_actions = combined(
*[_san_plot(fig).plot_actions for fig in figures],
*[fig.plot_actions for fig in figures],
composite_method=composite_method,
**kwargs,
)
Expand Down

0 comments on commit 005c5ba

Please sign in to comment.