marsilea 0.5.2__py3-none-any.whl → 0.5.4__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.4"
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)
marsilea/plotter/mesh.py CHANGED
@@ -483,8 +483,6 @@ class SizedMesh(MeshBase):
483
483
  >>> h.add_right(mesh, size=0.2, pad=0.05)
484
484
  >>> h.render()
485
485
 
486
-
487
-
488
486
  """
489
487
 
490
488
  def __init__(
@@ -550,6 +548,9 @@ class SizedMesh(MeshBase):
550
548
  render_colors.append(c)
551
549
  self.cmap = ListedColormap(render_colors)
552
550
  self.color2d = encode_numeric(color, encoder)
551
+ if self.norm is None:
552
+ vs = encoder.values()
553
+ self.norm = Normalize(vmin=min(vs), vmax=max(vs))
553
554
  else:
554
555
  self._process_cmap(color, vmin, vmax, cmap, norm, center)
555
556
  self.color2d = color
@@ -636,9 +637,8 @@ class SizedMesh(MeshBase):
636
637
  linewidths=self.linewidth,
637
638
  marker=self.marker,
638
639
  )
639
-
640
640
  if self.color is not None:
641
- options["c"] = self.color
641
+ options["c"] = color
642
642
  else:
643
643
  options.update(dict(c=color, norm=self.norm, cmap=self.cmap))
644
644
  self._collections = ax.scatter(xv, yv, **options, **self.kwargs)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: marsilea
3
- Version: 0.5.2
3
+ Version: 0.5.4
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=Ml3xgdyN-IinhsaejVadUjIURHJzg8fhi2Y_uERAuI8,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
@@ -19,13 +19,13 @@ marsilea/plotter/bar.py,sha256=RWDsNbyCUKbybpsBOgbl43lVZc_ynZmTOevE-CtJ5KE,12354
19
19
  marsilea/plotter/base.py,sha256=b_NmrW_oNPc-HwQsjx1NsC2lknYK6qSaDp_7SxeoUEM,18938
20
20
  marsilea/plotter/bio.py,sha256=34tucmxs4LM3TFZoGsrjnXTolyrzYaHVEiRe4dzDH68,5040
21
21
  marsilea/plotter/images.py,sha256=gb0xIQhUch3rNAt3FfvuUoamSGEynoBBBky2eE754ec,9560
22
- marsilea/plotter/mesh.py,sha256=4jTa05GQsxStDur6FkrNGXAIHUsoipFEDydP8CMCExE,24376
22
+ marsilea/plotter/mesh.py,sha256=D6snenMjQ-rM9g3O4PGelSiaBNKmY2OPZU5onILlmO0,24530
23
23
  marsilea/plotter/range.py,sha256=sXWKrvpq7nU7giiHPjayM7h9Q7gblhjXxHm8ioB3cm4,3770
24
24
  marsilea/plotter/text.py,sha256=6S4mnAxLJLMkduKiyor03lPd86oTOJ5TojVREA9oU6s,37466
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.4.dist-info/METADATA,sha256=9SS9_JT6N9FRdBenz-95mnzFY5LVal4lhMocoyvcUsA,7265
29
+ marsilea-0.5.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
30
+ marsilea-0.5.4.dist-info/licenses/LICENSE,sha256=RhHHDuP61qzKmfHtOQUVLZfCgMkKx9PXzxzkLtmAjHo,1078
31
+ marsilea-0.5.4.dist-info/RECORD,,