Skip to content

Commit 5c19a21

Browse files
committed
Update: specify plot size
1 parent 9c2b442 commit 5c19a21

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

kaleidoscope/interface/plot.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def plot(
2626
ylim: tuple[Any, Any] | None = None,
2727
title: str | None = None,
2828
fn: str | None = None,
29+
plot_size: tuple[Any, Any] | None = None,
2930
show: bool = False,
3031
**kwargs,
3132
) -> Figure:
@@ -39,6 +40,7 @@ def plot(
3940
:param ylim: The limits for the y-axis.
4041
:param title: The title of the plot.
4142
:param fn: The file name to save the figure.
43+
:param plot_size: The size of the plot.
4244
:param show: Show the figure.
4345
:param kwargs: Additional keyword arguments.
4446
:return: The plot.

kaleidoscope/val/plots.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import dask.array as da
1212
import numpy as np
13+
from IPython.core.pylabtools import figsize
1314
from matplotlib import colors as plc
1415
from matplotlib import pyplot as plt
1516
from matplotlib.axes import Axes
@@ -35,6 +36,7 @@ def plot(
3536
ylim: tuple[Any, Any] | None = None,
3637
title: str | None = None,
3738
fn: str | None = None,
39+
plot_size: tuple[Any, Any] | None = None,
3840
show: bool = False,
3941
*,
4042
cbar_label: str | None = None,
@@ -51,6 +53,7 @@ def plot(
5153
if projection is None:
5254
projection = self.projection
5355
fig, ax = plt.subplots(
56+
figsize=plot_size,
5457
subplot_kw={"projection": projection},
5558
)
5659
cbar_kwargs = {}
@@ -130,14 +133,15 @@ def plot(
130133
ylim: tuple[Any, Any] | None = None,
131134
title: str | None = None,
132135
fn: str | None = None,
136+
plot_size: tuple[Any, Any] | None = None,
133137
show: bool = False,
134138
*,
135139
bins: int | None = None,
136140
density: bool = False,
137141
log: bool = False,
138142
hist_range: tuple[Any, Any] | None = None,
139143
) -> Figure:
140-
fig, ax = plt.subplots()
144+
fig, ax = plt.subplots(figsize=plot_size)
141145
data.plot.hist(
142146
ax=ax, bins=bins, range=hist_range, density=density, log=log
143147
)
@@ -166,6 +170,7 @@ def plot(
166170
ylim: tuple[Any, Any] | None = None,
167171
title: str | None = None,
168172
fn: str | None = None,
173+
plot_size: tuple[Any, Any] | None = None,
169174
show: bool = False,
170175
*,
171176
bins: tuple[int, int] | None = None,
@@ -177,7 +182,7 @@ def plot(
177182
vmin: Any | None = None,
178183
vmax: Any | None = None,
179184
) -> Figure:
180-
fig, ax = plt.subplots()
185+
fig, ax = plt.subplots(figsize=plot_size)
181186
cbar_kwargs = {}
182187
if cbar_label is not None:
183188
cbar_kwargs["label"] = cbar_label
@@ -217,14 +222,15 @@ def plot(
217222
ylim: tuple[Any, Any] | None = None,
218223
title: str | None = None,
219224
fn: str | None = None,
225+
plot_size: tuple[Any, Any] | None = None,
220226
show: bool = False,
221227
*,
222228
point_alpha: Any | None = None,
223229
point_color: str | None = None,
224230
point_marker: str | None = ".",
225231
sample_count: int = 4000,
226232
) -> Figure:
227-
fig, ax = plt.subplots()
233+
fig, ax = plt.subplots(figsize=plot_size)
228234
rand(data, sample_count).plot.scatter(
229235
ax=ax,
230236
x="x",
@@ -262,12 +268,13 @@ def plot(
262268
ylim: tuple | None = None,
263269
title: str | None = None,
264270
fn: str | None = None,
271+
plot_size: tuple[Any, Any] | None = None,
265272
show: bool = False,
266273
*,
267274
point_marker: str = ".",
268275
group_by: str | None = "time.month",
269276
) -> Figure:
270-
fig, ax = plt.subplots()
277+
fig, ax = plt.subplots(figsize=plot_size)
271278

272279
if group_by is not None:
273280
for _, period in time_series(data).groupby(group_by):

0 commit comments

Comments
 (0)