marsilea 0.3.3__py3-none-any.whl → 0.3.5__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,10 +1,12 @@
1
1
  """Create x-layout visualization"""
2
2
 
3
- __version__ = "0.3.3"
3
+ __version__ = "0.3.5"
4
4
 
5
5
  import marsilea.plotter as plotter
6
6
  from ._deform import Deformation
7
- from .base import WhiteBoard, ClusterBoard, ZeroWidth, ZeroHeight
7
+ from .base import (WhiteBoard, ClusterBoard,
8
+ ZeroWidth, ZeroHeight,
9
+ ZeroWidthCluster, ZeroHeightCluster)
8
10
  from .dataset import load_data
9
11
  from .dendrogram import Dendrogram, GroupDendrogram
10
12
  from .heatmap import Heatmap, SizedHeatmap, CatHeatmap
marsilea/base.py CHANGED
@@ -80,7 +80,7 @@ class LegendMaker:
80
80
  """
81
81
  if name is None:
82
82
  name = str(uuid4())
83
- self._user_legends[name] = legend
83
+ self._user_legends[name] = [legend]
84
84
 
85
85
  def add_legends(
86
86
  self,
@@ -1403,3 +1403,50 @@ class ClusterBoard(WhiteBoard):
1403
1403
  # add row and col dendrogram
1404
1404
  self._render_dendrogram()
1405
1405
  self._render_legend()
1406
+
1407
+
1408
+ class ZeroWidthCluster(ClusterBoard):
1409
+ """
1410
+ A utility class to initialize a canvas \
1411
+ with zero width and cluster data
1412
+
1413
+ Parameters
1414
+ ----------
1415
+ cluster_data : ndarray
1416
+ The cluster data
1417
+ height : float
1418
+ The height of the main canvas in inches
1419
+ name : str
1420
+ The name of the main canvas
1421
+ margin : float, 4-tuple
1422
+ The margin of the main canvas in inches
1423
+
1424
+ """
1425
+
1426
+ def __init__(self, cluster_data, height, name=None, margin=0.2):
1427
+ super().__init__(cluster_data=cluster_data, width=0, height=height,
1428
+ name=name, margin=margin, init_main=False)
1429
+
1430
+
1431
+ class ZeroHeightCluster(ClusterBoard):
1432
+ """
1433
+ A utility class to initialize a canvas \
1434
+ with zero height and cluster data
1435
+
1436
+ Parameters
1437
+ ----------
1438
+ cluster_data : ndarray
1439
+ The cluster data
1440
+ width : float
1441
+ The width of the main canvas in inches
1442
+ name : str
1443
+ The name of the main canvas
1444
+ margin : float, 4-tuple
1445
+ The margin of the main canvas in inches
1446
+
1447
+
1448
+ """
1449
+
1450
+ def __init__(self, cluster_data, width, name=None, margin=0.2):
1451
+ super().__init__(cluster_data=cluster_data, width=width, height=0,
1452
+ name=name, margin=margin, init_main=False)
marsilea/layers.py CHANGED
@@ -360,6 +360,7 @@ class Marker(Piece):
360
360
  self.size = size
361
361
  m = MarkerStyle(marker)
362
362
  self.path = m.get_path().transformed(m.get_transform())
363
+ self.marker = marker
363
364
 
364
365
  def draw(self, x, y, w, h, ax):
365
366
  c = self.draw_center(x, y, w, h)
@@ -2,7 +2,7 @@ import pandas as pd
2
2
  import seaborn
3
3
  from legendkit import CatLegend
4
4
  from seaborn import color_palette
5
- from typing import Mapping
5
+ from typing import Mapping, Sequence
6
6
 
7
7
  from .base import StatsBase
8
8
  from ..utils import ECHARTS16
@@ -51,6 +51,8 @@ class _SeabornBase(StatsBase):
51
51
  # kwargs['palette'] = "dark:C0"
52
52
  if palette is not None:
53
53
  kwargs["palette"] = palette
54
+ if isinstance(palette, Sequence):
55
+ self.set_params({"palette": palette})
54
56
 
55
57
  kwargs.pop("x", None)
56
58
  kwargs.pop("y", None)
@@ -80,6 +82,7 @@ class _SeabornBase(StatsBase):
80
82
  ax = spec.ax
81
83
  data = spec.data
82
84
  gp = spec.group_params
85
+
83
86
  if gp is None:
84
87
  gp = {}
85
88
  x, y = "var", "value"
@@ -106,6 +109,9 @@ class _SeabornBase(StatsBase):
106
109
  x, y = y, x
107
110
  self.kws["x"] = x
108
111
  self.kws["y"] = y
112
+ if spec.params is not None:
113
+ palette = [p.get("palette", "C0") for p in spec.params]
114
+ self.kws["palette"] = palette
109
115
  options = {**self.kws, **gp}
110
116
  if options.get("palette") is not None:
111
117
  options["hue"] = "var"
marsilea/plotter/area.py CHANGED
@@ -26,6 +26,20 @@ class Area(StatsBase):
26
26
  Additional configurations for the area plot, \
27
27
  see :func:`matplotlib.pyplot.fill_between`
28
28
 
29
+ Examples
30
+ --------
31
+ .. plot::
32
+ :context: close-figs
33
+
34
+ import numpy as np
35
+ import matplotlib.pyplot as plt
36
+
37
+ from marsilea.plotter import Area
38
+
39
+ _, ax = plt.subplots()
40
+ data = np.random.randint(0, 10, 10) + 1
41
+ Area(data).render(ax)
42
+
29
43
  """
30
44
 
31
45
  def __init__(self, data, color=None, add_outline=True, alpha=.4,
@@ -46,6 +60,7 @@ class Area(StatsBase):
46
60
  self.kws = kwargs
47
61
 
48
62
  self.set_data(data)
63
+ self.set_label(label, label_loc, label_props)
49
64
  if group_kws is not None:
50
65
  self.set_group_params(group_kws)
51
66
 
@@ -56,7 +71,7 @@ class Area(StatsBase):
56
71
  if gp is None:
57
72
  gp = {}
58
73
 
59
- fill_options = {'colo': self.color, 'alpha': self.alpha, **self.kws, **gp}
74
+ fill_options = {'color': self.color, 'alpha': self.alpha, **self.kws, **gp}
60
75
  line_options = {'color': self.linecolor, 'linewidth': self.linewidth, **gp}
61
76
 
62
77
  x = np.arange(len(data))
@@ -1,12 +1,14 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: marsilea
3
- Version: 0.3.3
3
+ Version: 0.3.5
4
4
  Summary: Create x-layout visualization
5
5
  Author: Zhihang Zheng
6
6
  Author-email: Mr-Milk <yzheng@cemm.at>
7
7
  Requires-Python: >=3.8
8
8
  Description-Content-Type: text/markdown
9
9
  Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Framework :: Matplotlib
10
12
  Requires-Dist: numpy
11
13
  Requires-Dist: pandas
12
14
  Requires-Dist: matplotlib>=3.6
@@ -1,27 +1,27 @@
1
- marsilea/__init__.py,sha256=xgLPjY3onsVFvFuqNclgBCu1mnbLdstf0yXZ2zrT1rs,456
1
+ marsilea/__init__.py,sha256=MK00zrdKPjFGFcfH0KfoZz9MZhkYffJ-QTwDtzELohs,533
2
2
  marsilea/_api.py,sha256=tymWZHfjhx8-0NNd9762znfdIu36NrARRweEIr5L1mA,283
3
3
  marsilea/_deform.py,sha256=SKXLvhyUrwTRAw7Fl--OpupDLk6T3S5DRfwCAdewHQs,14138
4
- marsilea/base.py,sha256=yxnuHZMa7xFBC0eerp4zkiQY5Mn1SsIK32B4TUwhuI4,44608
4
+ marsilea/base.py,sha256=YQNgkLPX2RoQzhLdEaxf6ZLFECjAqXdye9G5XG64sAY,45869
5
5
  marsilea/dataset.py,sha256=a0mXjPu9_tRGHofnnQaTryFpxftkfqldq_ZLXMSBf7A,4410
6
6
  marsilea/dendrogram.py,sha256=WUnV2JMSY9mPt1sfkFAEikkl2ta7xHFD13teas_iZgE,14767
7
7
  marsilea/exceptions.py,sha256=Wxy31eCWkoXTPwqaa7R5F7cJ3uCtzqhJXmxVqqX8eAA,661
8
8
  marsilea/heatmap.py,sha256=lKGt0lTtziNFDsb_SBfFt3zoYzVYRzezc9aae5RxHyk,4168
9
- marsilea/layers.py,sha256=my_QcvKGsIu4BV6yKpUUs5v4bdAz915tmS-q48_rEGg,12134
9
+ marsilea/layers.py,sha256=puXLlGGpEqAzaTqadpgpsYmIDPH33WyyHIuysRSqFZQ,12163
10
10
  marsilea/layout.py,sha256=X8MGPlAbbr7dcZiqW4pI7sEb8U3jVaiS7t1DKOqMYLI,27758
11
11
  marsilea/upset.py,sha256=12ExZ6yUQocd3bSLYtizEblJgILn_QCQaoeP-SP2q9E,30138
12
12
  marsilea/utils.py,sha256=IaAaOBdE668XuGiA-k_gmOtHYqfpIxPv_-molMSBPfs,2851
13
13
  marsilea/plotter/__init__.py,sha256=aEN-Yta4USY5_l-D97XYySALEgxMmFieA08DzK3xdB4,737
14
14
  marsilea/plotter/_images.py,sha256=BC9iyWBLVY-nmUW1pSZq06pwHZN1MrW2psMIDreLReg,3062
15
- marsilea/plotter/_seaborn.py,sha256=wC2sqVokSsk_uqYkjtg6HNrsifawLwqsQoDgJWIkSPs,7834
15
+ marsilea/plotter/_seaborn.py,sha256=XePOYnIFf9lDXXZffSL-YKSV162hKOWsvuxAvH2oHQo,8111
16
16
  marsilea/plotter/_utils.py,sha256=Efhdk-TrrAanhbXRiEVWThMYvZ4vVHZMVYMs5X3JvIM,710
17
17
  marsilea/plotter/arc.py,sha256=iBAvQeYLMNaXsykkpE6BJN1CTaBNntlfispFV2LvSUE,8102
18
- marsilea/plotter/area.py,sha256=BYqi522L5h5fy5fmnI2_GZEzKR7NE2QFBJpMySmohT4,2244
18
+ marsilea/plotter/area.py,sha256=UOI8xdXMORXdgEG7fT9Lmx3Zk0_7XZl9nMw9A_CZkKA,2590
19
19
  marsilea/plotter/bar.py,sha256=jbWukeTkUSge_TLC3ikJeg7GLHG4WuyN6EwIERvh0sc,11976
20
20
  marsilea/plotter/base.py,sha256=Kzp0474WlXQse5jK4kLPtkVQLH9zpEwYNocV4c0CD-A,19621
21
21
  marsilea/plotter/bio.py,sha256=_pZkGoAei7eirFCpu7AcZJhebBneNjUKcZlI36bpqUE,5044
22
22
  marsilea/plotter/mesh.py,sha256=JctVkK5xjsUnRjX2ik3ntL-k-Didi7OAUfdmgkZu6IQ,23116
23
23
  marsilea/plotter/text.py,sha256=oYJ5py3_nGHKi60DSVzFgPg4drnTSTw__IcYs0cut4M,36222
24
- marsilea-0.3.3.dist-info/LICENSE,sha256=2TLD8FnLJqXzg8YBRs7W3VZBwfWfp4ArDfBl-rn96Qc,1074
25
- marsilea-0.3.3.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
26
- marsilea-0.3.3.dist-info/METADATA,sha256=3ey_r3Hu6oNLTT1RvARf5aGE-oDQcIckaoeO3nkTE34,3971
27
- marsilea-0.3.3.dist-info/RECORD,,
24
+ marsilea-0.3.5.dist-info/LICENSE,sha256=2TLD8FnLJqXzg8YBRs7W3VZBwfWfp4ArDfBl-rn96Qc,1074
25
+ marsilea-0.3.5.dist-info/WHEEL,sha256=EZbGkh7Ie4PoZfRQ8I0ZuP9VklN_TvcZ6DSE5Uar4z4,81
26
+ marsilea-0.3.5.dist-info/METADATA,sha256=WNby0TTARbfq5zrKSbelRLRchsPRURRraukRSnZYO64,4055
27
+ marsilea-0.3.5.dist-info/RECORD,,