marsilea 0.5.2__py3-none-any.whl → 0.5.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
marsilea/__init__.py CHANGED
@@ -1,6 +1,6 @@
1
1
  """Declarative creation of composable visualization"""
2
2
 
3
- __version__ = "0.5.2"
3
+ __version__ = "0.5.3"
4
4
 
5
5
  import marsilea.plotter as plotter
6
6
  from ._deform import Deformation
marsilea/layers.py CHANGED
@@ -1,7 +1,10 @@
1
+ from __future__ import annotations
2
+
1
3
  import numpy as np
2
4
  from legendkit import ListLegend
3
5
  from matplotlib import pyplot as plt
4
6
  from matplotlib.artist import Artist
7
+ from matplotlib.axes import Axes
5
8
  from matplotlib.collections import PathCollection
6
9
  from matplotlib.lines import Line2D
7
10
  from matplotlib.markers import MarkerStyle
@@ -14,6 +17,25 @@ from .layout import close_ticks
14
17
  from .plotter import RenderPlan
15
18
 
16
19
 
20
+ def add_artists(ax: Axes, artists: Artist | Iterable[Artist]):
21
+ """Adds one or more Matplotlib artists to an Axes object.
22
+
23
+ Parameters
24
+ ----------
25
+ ax : matplotlib.axes.Axes
26
+ The Matplotlib Axes object to which the artists will be added.
27
+ artists : matplotlib.artist.Artist or Iterable[matplotlib.artist.Artist]
28
+ A single Matplotlib Artist instance or an iterable
29
+ containing multiple Artist instances to be added to the Axes.
30
+
31
+ """
32
+ if isinstance(artists, Artist): # add one artist
33
+ ax.add_artist(artists)
34
+ else: # add multiple artists
35
+ for art in artists:
36
+ ax.add_artist(art)
37
+
38
+
17
39
  class LayersMesh(RenderPlan):
18
40
  """The mesh that draw customized elements in multi-layers
19
41
 
@@ -186,7 +208,7 @@ class LayersMesh(RenderPlan):
186
208
  self.height,
187
209
  ax,
188
210
  )
189
- ax.add_artist(art)
211
+ add_artists(ax, art)
190
212
  else:
191
213
  for iy, row in enumerate(data):
192
214
  for ix, v in enumerate(row):
@@ -198,7 +220,7 @@ class LayersMesh(RenderPlan):
198
220
  self.height,
199
221
  ax,
200
222
  )
201
- ax.add_artist(art)
223
+ add_artists(ax, art)
202
224
  ax.invert_yaxis()
203
225
 
204
226
 
@@ -253,7 +275,7 @@ class Piece:
253
275
  cy = y + h / 2.0
254
276
  return cx, cy
255
277
 
256
- def draw(self, x, y, w, h, ax) -> Artist:
278
+ def draw(self, x, y, w, h, ax) -> Artist | Iterable[Artist]:
257
279
  raise NotImplementedError
258
280
 
259
281
  def legend(self, x, y, w, h) -> Artist:
@@ -388,4 +410,4 @@ def preview(piece: Piece, figsize=(1, 1)):
388
410
  arts = piece.draw(0, 0, 1, 1, ax)
389
411
  ax.set_xlim(0, 1)
390
412
  ax.set_ylim(0, 1)
391
- ax.add_artist(arts)
413
+ add_artists(ax, arts)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: marsilea
3
- Version: 0.5.2
3
+ Version: 0.5.3
4
4
  Summary: Declarative creation of composable visualizations
5
5
  Project-URL: Home, https://github.com/Marsilea-viz/marsilea
6
6
  Project-URL: Documentation, https://marsilea.readthedocs.io
@@ -1,4 +1,4 @@
1
- marsilea/__init__.py,sha256=0fpp21uDy2gLto0wOvlbShNTZS-1M9twBFuFumSwwlw,595
1
+ marsilea/__init__.py,sha256=sJ1qYZyJvKSKnbyOUwBjhnDU2pB4TMjOaPBE-msoo3E,595
2
2
  marsilea/_api.py,sha256=tymWZHfjhx8-0NNd9762znfdIu36NrARRweEIr5L1mA,283
3
3
  marsilea/_deform.py,sha256=QRz4OGXMsQzbiIkC3ASzZayMPhHhoFsEK38oBzSeQG8,14440
4
4
  marsilea/base.py,sha256=CmzuwFu0JzgkNpPdI1SqAnkUxINShjT73hrJpksKjhE,46872
@@ -6,7 +6,7 @@ marsilea/dataset.py,sha256=Qh8k1DhTiwP_Me709CkpNwRaYLDzlenRTIk0U6D58_g,4631
6
6
  marsilea/dendrogram.py,sha256=Ung43zseybZKzTEvH5P_ge3WGfsr7i7qsX7YEVDlC74,15590
7
7
  marsilea/exceptions.py,sha256=wN5ElUZxuaJKSnnwWdkNx6P-Oc16dzSuaRPbRKWIBEM,1046
8
8
  marsilea/heatmap.py,sha256=8Wo1NxFTBp1a7NOISmer0yQYWWgf51Xsvjav1h1vTYk,4316
9
- marsilea/layers.py,sha256=puXLlGGpEqAzaTqadpgpsYmIDPH33WyyHIuysRSqFZQ,12163
9
+ marsilea/layers.py,sha256=w_yvghwYAO112mVvp1krjUjEIQYq_1nz2uCsTUJdB-Y,12909
10
10
  marsilea/layout.py,sha256=yNuGvIDfWjbCksQZO-4aUWSA78LJwBBKF5Z5cthC6fM,39741
11
11
  marsilea/upset.py,sha256=9m4Los-yVvVZOEHg6X-yfOdLA9eUBQdK1A_BkOaLIMA,30602
12
12
  marsilea/utils.py,sha256=y_KYs4ToiuKEsiBdmcIVtmxMXFpD4wKiJ0k7iBa11z8,2854
@@ -25,7 +25,7 @@ marsilea/plotter/text.py,sha256=6S4mnAxLJLMkduKiyor03lPd86oTOJ5TojVREA9oU6s,3746
25
25
  oncoprinter/__init__.py,sha256=efshcAD1h9s-NVJj4HLU9-hXc_LtTeIrNYqLHl-sm_g,106
26
26
  oncoprinter/core.py,sha256=5KPnKW5ivlxPp14uJd0OtfTv-pXV2UEym8EbII2VCcw,11846
27
27
  oncoprinter/preset.py,sha256=mBk2tFCqoTj_1ZZKRYuv4j2I3NTBa6Swc9wjzbmxRVw,8238
28
- marsilea-0.5.2.dist-info/METADATA,sha256=ItfPnIgJLjJRHgNax36iPM48Wwb7DHUvg-P-UZkyMS8,7265
29
- marsilea-0.5.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
30
- marsilea-0.5.2.dist-info/licenses/LICENSE,sha256=RhHHDuP61qzKmfHtOQUVLZfCgMkKx9PXzxzkLtmAjHo,1078
31
- marsilea-0.5.2.dist-info/RECORD,,
28
+ marsilea-0.5.3.dist-info/METADATA,sha256=lsolvQQM7C1em-dpNvnkwU2Pr8fAtiIu-H-8DxOQtaU,7265
29
+ marsilea-0.5.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
30
+ marsilea-0.5.3.dist-info/licenses/LICENSE,sha256=RhHHDuP61qzKmfHtOQUVLZfCgMkKx9PXzxzkLtmAjHo,1078
31
+ marsilea-0.5.3.dist-info/RECORD,,