Skip to content

Commit 65d7644

Browse files
committed
replace kwargs with explicit arguments
1 parent d944768 commit 65d7644

File tree

2 files changed

+72
-70
lines changed

2 files changed

+72
-70
lines changed

src/maxplotlib/canvas/canvas.py

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,23 @@ def add_subplot(
133133
self,
134134
col: int | None = None,
135135
row: int | None = None,
136+
figsize: tuple = (10, 6),
137+
title: str | None = None,
138+
caption: str | None = None,
139+
description: str | None = None,
136140
label: str | None = None,
137-
**kwargs,
141+
grid: bool = False,
142+
legend: bool = False,
143+
xmin: float | int | None = None,
144+
xmax: float | int | None = None,
145+
ymin: float | int | None = None,
146+
ymax: float | int | None = None,
147+
xlabel: str | None = None,
148+
ylabel: str | None = None,
149+
xscale: float | int = 1.0,
150+
yscale: float | int = 1.0,
151+
xshift: float | int = 0.0,
152+
yshift: float | int = 0.0,
138153
):
139154
"""
140155
Adds a subplot to the figure.
@@ -149,7 +164,21 @@ def add_subplot(
149164
row, col = self.generate_new_rowcol(row, col)
150165

151166
# Initialize the LinePlot for the given subplot position
152-
line_plot = LinePlot(col=col, row=row, label=label, **kwargs)
167+
line_plot = LinePlot(
168+
title=title,
169+
grid=grid,
170+
legend=legend,
171+
xmin=xmin,
172+
xmax=xmax,
173+
ymin=ymin,
174+
ymax=ymax,
175+
xlabel=xlabel,
176+
ylabel=ylabel,
177+
xscale=xscale,
178+
yscale=yscale,
179+
xshift=xshift,
180+
yshift=yshift,
181+
)
153182
self._subplot_matrix[row][col] = line_plot
154183

155184
# Store the LinePlot instance by its position for easy access

src/maxplotlib/subfigure/line_plot.py

Lines changed: 41 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -30,52 +30,63 @@ def __init__(
3030

3131

3232
class LinePlot:
33-
def __init__(self, **kwargs):
33+
def __init__(
34+
self,
35+
title: str | None = None,
36+
grid: bool = False,
37+
legend: bool = False,
38+
xmin: float | int | None = None,
39+
xmax: float | int | None = None,
40+
ymin: float | int | None = None,
41+
ymax: float | int | None = None,
42+
xlabel: str | None = None,
43+
ylabel: str | None = None,
44+
xscale: float | int = 1.0,
45+
yscale: float | int = 1.0,
46+
xshift: float | int = 0.0,
47+
yshift: float | int = 0.0,
48+
):
3449
"""
3550
Initialize the LinePlot class for a subplot.
3651
3752
Parameters:
38-
**kwargs: Arbitrary keyword arguments.
39-
- figsize (tuple): Figure size (default is (10, 6)).
40-
- caption (str): Caption for the plot.
41-
- description (str): Description of the plot.
42-
- label (str): Label for the plot.
43-
- grid (bool): Whether to display grid lines (default is False).
44-
TODO: Add all options
53+
title (str): Title of the plot.
54+
caption (str): Caption for the plot.
55+
description (str): Description of the plot.
56+
label (str): Label for the plot.
57+
grid (bool): Whether to display grid lines (default is False).
58+
legend (bool): Whether to display legend (default is False).
59+
xmin, xmax, ymin, ymax (float): Axis limits.
60+
xlabel, ylabel (str): Axis labels.
61+
xscale, yscale (float): Scaling factors for axes.
62+
xshift, yshift (float): Shifts for axes.
4563
"""
46-
# Set default values
47-
self._figsize = kwargs.get("figsize", (10, 6))
48-
self._title = kwargs.get("title", None)
49-
self._caption = kwargs.get("caption", None)
50-
self._description = kwargs.get("description", None)
51-
self._label = kwargs.get("label", None)
52-
self._grid = kwargs.get("grid", False)
53-
self._legend = kwargs.get("legend", False)
54-
self._xmin = kwargs.get("xmin", None)
55-
self._xmax = kwargs.get("xmax", None)
56-
self._ymin = kwargs.get("ymin", None)
57-
self._ymax = kwargs.get("ymax", None)
58-
59-
self._xlabel = kwargs.get("xlabel", None)
60-
self._ylabel = kwargs.get("ylabel", None)
64+
65+
self._title = title
66+
self._grid = grid
67+
self._legend = legend
68+
self._xmin = xmin
69+
self._xmax = xmax
70+
self._ymin = ymin
71+
self._ymax = ymax
72+
self._xlabel = xlabel
73+
self._ylabel = ylabel
74+
self._xscale = xscale
75+
self._yscale = yscale
76+
self._xshift = xshift
77+
self._yshift = yshift
78+
6179
# List to store line data, each entry contains x and y data, label, and plot kwargs
6280
self.line_data = []
6381
self.layered_line_data = {}
6482

6583
# Initialize lists to hold Node and Path objects
6684
self.nodes = []
6785
self.paths = []
68-
# self.layers = {}
6986

7087
# Counter for unnamed nodes
7188
self._node_counter = 0
7289

73-
# Scaling
74-
self._xscale = kwargs.get("xscale", 1.0)
75-
self._yscale = kwargs.get("yscale", 1.0)
76-
self._xshift = kwargs.get("xshift", 0.0)
77-
self._yshift = kwargs.get("yshift", 0.0)
78-
7990
def add_caption(self, caption):
8091
self._caption = caption
8192

@@ -185,8 +196,6 @@ def plot_matplotlib(self, ax, layers=None):
185196
plt.colorbar(im, cax=cax, label="Potential (V)")
186197
if self._title:
187198
ax.set_title(self._title)
188-
if self._label:
189-
ax.set_ylabel(self._label)
190199
if self._xlabel:
191200
ax.set_xlabel(self._xlabel)
192201
if self._ylabel:
@@ -312,42 +321,6 @@ def ymin(self):
312321
def ymax(self):
313322
return self._ymax
314323

315-
# Getter and Setter for figsize
316-
@property
317-
def figsize(self):
318-
return self._figsize
319-
320-
@figsize.setter
321-
def figsize(self, value):
322-
self._figsize = value
323-
324-
# Getter and Setter for caption
325-
@property
326-
def caption(self):
327-
return self._caption
328-
329-
@caption.setter
330-
def caption(self, value):
331-
self._caption = value
332-
333-
# Getter and Setter for description
334-
@property
335-
def description(self):
336-
return self._description
337-
338-
@description.setter
339-
def description(self, value):
340-
self._description = value
341-
342-
# Getter and Setter for label
343-
@property
344-
def label(self):
345-
return self._label
346-
347-
@label.setter
348-
def label(self, value):
349-
self._label = value
350-
351324
# Getter and Setter for grid
352325
@property
353326
def grid(self):

0 commit comments

Comments
 (0)