Skip to content

Commit a318de5

Browse files
committed
Add pre-commit hooks
1 parent d3ad0a7 commit a318de5

17 files changed

+141
-100
lines changed

docs/examples/Gallery/plot_oil_well.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
"150-199 °C (Light saute)",
9999
"<150 °C (Dressings)",
100100
]
101-
cb.hsplit(labels=oils["cooking conditions"], order=order)
101+
cb.group_rows(oils["cooking conditions"], order=order)
102102
cb.add_left(conditions, pad=0.1)
103103
cb.add_dendrogram(
104104
"left", add_meta=False, colors=colors, linewidth=1.5, size=0.5, pad=0.02

docs/examples/Gallery/plot_pbmc3k.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
h.add_left(cell_types)
7777
h.add_bottom(gene_names)
7878

79-
h.hsplit(labels=cell_cat, order=["Lymphoid", "Myeloid"])
79+
h.group_rows(cell_cat, order=["Lymphoid", "Myeloid"])
8080
h.add_left(mp.Chunk(["Lymphoid", "Myeloid"], ["#33A6B8", "#B481BB"]), pad=0.05)
8181
h.add_dendrogram("left", colors=["#33A6B8", "#B481BB"])
8282
h.add_dendrogram("bottom")

docs/examples/Gallery/plot_sc_multiomics.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
"title": "% expression in group",
5959
},
6060
)
61-
gene_profile.hsplit(labels=lineage_cells, order=lineage)
61+
gene_profile.group_rows(lineage_cells, order=lineage)
6262
gene_profile.add_left(ma.plotter.Chunk(lineage, lineage_colors, padding=10))
6363
gene_profile.add_dendrogram(
6464
"left",
@@ -103,7 +103,7 @@
103103
"title": "% expression in group",
104104
},
105105
)
106-
protein_profile.hsplit(labels=lineage_cells, order=lineage)
106+
protein_profile.group_rows(lineage_cells, order=lineage)
107107
protein_profile.add_bottom(
108108
ma.plotter.Labels(marker_names, color="#E36414", align="bottom", padding=10)
109109
)

docs/examples/Gallery/plot_tiobe_index.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,18 @@
2727
# ---------
2828

2929
data = {
30-
"Programming Language": ["Python", "C++", "C", "Java", "C#", "JavaScript",
31-
"Go", "Visual Basic", "Fortran", "SQL"],
30+
"Programming Language": [
31+
"Python",
32+
"C++",
33+
"C",
34+
"Java",
35+
"C#",
36+
"JavaScript",
37+
"Go",
38+
"Visual Basic",
39+
"Fortran",
40+
"SQL",
41+
],
3242
"Ratings": [16.12, 10.34, 9.48, 8.59, 6.72, 3.79, 2.19, 2.08, 2.05, 2.04],
3343
}
3444
data = pd.DataFrame(data).set_index("Programming Language")
@@ -50,8 +60,10 @@
5060
# Plot
5161
c = ma.ZeroWidth(5)
5262
c.add_right(mp.Image([images[lang] for lang in data.index]))
53-
c.add_left(mp.Labels(data.index, fontweight=600), pad=.1)
54-
c.add_right(mp.Numbers(data['Ratings'], color="#009FBD", label="Rating"), pad=.1)
55-
c.add_title("https://www.tiobe.com/tiobe-index/", align="left", fontsize=10, fontstyle="italic")
63+
c.add_left(mp.Labels(data.index, fontweight=600), pad=0.1)
64+
c.add_right(mp.Numbers(data["Ratings"], color="#009FBD", label="Rating"), pad=0.1)
65+
c.add_title(
66+
"https://www.tiobe.com/tiobe-index/", align="left", fontsize=10, fontstyle="italic"
67+
)
5668
c.add_title("TIOBE Index July 2024", align="left", fontweight=600)
5769
c.render()

docs/examples/Gallery/plot_tracks.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Track Plot
33
==========
44
"""
5+
56
import marsilea as ma
67
import marsilea.plotter as mp
78

@@ -42,8 +43,14 @@
4243
name = f"{cond}{enz}"
4344
color = colors[enz]
4445
canvas.add_bottom(
45-
mp.Area(track, color=color, add_outline=False, alpha=1,
46-
label=cond, label_loc="right"),
46+
mp.Area(
47+
track,
48+
color=color,
49+
add_outline=False,
50+
alpha=1,
51+
label=cond,
52+
label_loc="right",
53+
),
4754
size=TRACK_HEIGHT,
4855
pad=TRACK_PAD,
4956
name=name,

docs/examples/Plotters/plot_chunk.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
h = ma.Heatmap(matrix)
1515
chunk = ["C1", "C2", "C3", "C4"]
1616
labels = np.random.choice(chunk, size=20)
17-
h.hsplit(labels=labels, order=chunk)
17+
h.group_rows(labels, order=chunk)
1818
h.add_right(Chunk(chunk, bordercolor="gray"), pad=0.1)
1919
h.add_dendrogram("left")
2020
h.render()

docs/examples/Plotters/plot_emoji.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@
88

99
# %%
1010

11-
from marsilea.plotter import Emoji
12-
1311
# %%
14-
import numpy as np
1512
import matplotlib.pyplot as plt
1613

14+
from marsilea.plotter import Emoji
15+
1716
_, ax = plt.subplots()
1817
Emoji("😆😆🤣😂😉😇🐍🦀🦄").render(ax)

docs/examples/Plotters/plot_fixed_chunk.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
h = ma.Heatmap(matrix)
1616
chunk = ["C1", "C2-1", "C2-2", "C4"]
1717
labels = np.random.choice(chunk, size=20)
18-
h.hsplit(labels=labels, order=chunk)
18+
h.group_rows(labels, order=chunk)
1919
h.add_right(FixedChunk(chunk, bordercolor="gray"), pad=0.1)
2020
h.add_right(
2121
FixedChunk(

docs/examples/Plotters/plot_image.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,17 @@
88

99
# %%
1010

11-
from marsilea.plotter import Image
12-
1311
# %%
14-
import numpy as np
1512
import matplotlib.pyplot as plt
1613

14+
from marsilea.plotter import Image
15+
1716
_, ax = plt.subplots()
18-
Image([
19-
"https://www.iconfinder.com/icons/4375050/download/png/512",
20-
"https://www.iconfinder.com/icons/8666426/download/png/512",
21-
"https://www.iconfinder.com/icons/652581/download/png/512"
22-
], align="right").render(ax)
17+
Image(
18+
[
19+
"https://www.iconfinder.com/icons/4375050/download/png/512",
20+
"https://www.iconfinder.com/icons/8666426/download/png/512",
21+
"https://www.iconfinder.com/icons/652581/download/png/512",
22+
],
23+
align="right",
24+
).render(ax)

docs/examples/Plotters/plot_labels.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515

1616
_, ax = plt.subplots(figsize=(0.5, 6))
1717
data = np.random.randint(0, 10, 30)
18-
l = Labels(data)
19-
l.set_side("right")
20-
l.render(ax)
18+
labels = Labels(data)
19+
labels.set_side("right")
20+
labels.render(ax)

docs/how_to/legends/plot_custom_legend.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,21 @@
1010

1111
# %%
1212
import numpy as np
13+
1314
import marsilea as ma
14-
from marsilea.plotter import ColorMesh, Colors
1515

1616
data = np.random.randint(0, 10, (10, 10))
1717

1818

1919
# %%
2020
from legendkit import cat_legend
21-
def my_legend(): return cat_legend(labels=["my super legend"], colors=["lightblue"], title="My Legend")
21+
22+
23+
def my_legend():
24+
return cat_legend(
25+
labels=["my super legend"], colors=["lightblue"], title="My Legend"
26+
)
27+
2228

2329
h = ma.Heatmap(data, width=3, height=3)
2430
h.custom_legend(my_legend)

docs/source/api/index.rst

Lines changed: 70 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -9,124 +9,147 @@ Declarative API Cheat Sheet
99

1010
.. list-table::
1111
:header-rows: 1
12+
:widths: 10 50 50
1213

1314
* - Operator
14-
- Description
15+
- Showcase
1516
- Example
1617

17-
* - :meth:`~marsilea.base.WhiteBoard.add_layer`
18-
- Add a plotter to main canvas.
18+
19+
* - | :meth:`~marsilea.base.WhiteBoard.add_layer`
20+
| Add a plotter to main canvas.
21+
- .. image:: ../img/api_add_layer.png
1922
- .. code-block:: python
2023

2124
wb.add_layer(ColorMesh(data))
2225

23-
* - :meth:`~marsilea.base.WhiteBoard.add_left`
24-
- Add to the **left-side** of main canvas.
26+
* - | :meth:`~marsilea.base.WhiteBoard.add_left`
27+
| Add to the **left-side** of main canvas.
28+
- .. image:: ../img/api_add_left.png
2529
- .. code-block:: python
2630

2731
wb.add_left(Numbers(data),
2832
size=1, pad=.1,
2933
name='left-plot')
3034

31-
* - :meth:`~marsilea.base.WhiteBoard.add_right`
32-
- Add a plotter to the **right-side** of main canvas.
35+
* - | :meth:`~marsilea.base.WhiteBoard.add_right`
36+
| Add a plotter to the **right-side** of main canvas.
37+
- .. image:: ../img/api_add_right.png
3338
- .. code-block:: python
3439

3540
wb.add_right(Numbers(data))
3641

37-
* - :meth:`~marsilea.base.WhiteBoard.add_top`
38-
- Add a plotter to the **top-side** of main canvas.
42+
* - | :meth:`~marsilea.base.WhiteBoard.add_top`
43+
| Add a plotter to the **top-side** of main canvas.
44+
- .. image:: ../img/api_add_top.png
3945
- .. code-block:: python
4046

4147
wb.add_top(Numbers(data))
4248

43-
* - :meth:`~marsilea.base.WhiteBoard.add_bottom`
44-
- Add a plotter to the **bottom-side** of main canvas.
49+
* - | :meth:`~marsilea.base.WhiteBoard.add_bottom`
50+
| Add a plotter to the **bottom-side** of main canvas.
51+
- .. image:: ../img/api_add_bottom.png
4552
- .. code-block:: python
4653

4754
wb.add_bottom(Numbers(data))
4855

49-
* - :meth:`~marsilea.base.WhiteBoard.add_title`
50-
- Add titles to the plot.
56+
* - | :meth:`~marsilea.base.WhiteBoard.add_title`
57+
| Add titles to the plot.
58+
- .. image:: ../img/api_add_title.png
5159
- .. code-block:: python
5260

53-
wb.add_title(top='Top Title', bottom='Bottom Title'
54-
left='Left Title', right='Right Title')
61+
wb.add_title(top='Top', bottom='Bottom'
62+
left='Left', right='Right')
5563

56-
* - :meth:`~marsilea.base.ClusterBoard.add_dendrogram`
57-
- Add a dendrogram to the plot, only available to ClusterBoard.
64+
* - | :meth:`~marsilea.base.ClusterBoard.add_dendrogram`
65+
| Add a dendrogram to the plot, only available to ClusterBoard.
66+
- .. image:: ../img/api_add_dendrogram.png
5867
- .. code-block:: python
5968

60-
cb.add_dendrogram("left", data)
69+
cb.add_dendrogram("right")
6170

62-
* - :meth:`~marsilea.base.ClusterBoard.group_cols`
63-
- Split the main canvas horizontally, only available to ClusterBoard.
71+
* - | :meth:`~marsilea.base.ClusterBoard.group_cols`
72+
| Split the main canvas vertically by labeling columns, only available to ClusterBoard.
73+
- .. image:: ../img/api_group_cols.png
6474
- .. code-block:: python
6575

66-
cb.group_cols(labels=[1, 1, 2, 2], order=[2, 1])
76+
cb.group_cols(list("11223"))
6777

68-
* - :meth:`~marsilea.base.ClusterBoard.group_rows`
69-
- Split the main canvas vertically, only available to ClusterBoard.
78+
* - | :meth:`~marsilea.base.ClusterBoard.group_rows`
79+
| Split the main canvas horizontally by labeling rows, only available to ClusterBoard.
80+
- .. image:: ../img/api_group_rows.png
7081
- .. code-block:: python
7182

72-
cb.group_rows(labels=[1, 1, 2, 2], order=[2, 1])
83+
cb.group_rows(list("11223"))
7384

74-
* - :meth:`~marsilea.base.ClusterBoard.cut_cols`
75-
- Split the main canvas horizontally, only available to ClusterBoard.
85+
* - | :meth:`~marsilea.base.ClusterBoard.cut_cols`
86+
| Split the main canvas vertically by positions, only available to ClusterBoard.
87+
- .. image:: ../img/api_cut_cols.png
7688
- .. code-block:: python
7789

78-
cb.cut_cols([5])
90+
cb.cut_cols([2, 4])
7991

80-
* - :meth:`~marsilea.base.ClusterBoard.cut_rows`
81-
- Split the main canvas vertically, only available to ClusterBoard.
92+
* - | :meth:`~marsilea.base.ClusterBoard.cut_rows`
93+
| Split the main canvas horizontally by positions, only available to ClusterBoard.
94+
- .. image:: ../img/api_cut_rows.png
8295
- .. code-block:: python
8396

84-
cb.cut_rows([5])
97+
cb.cut_rows([2, 4])
8598

86-
* - :meth:`~marsilea.base.LegendMaker.add_legends`
87-
- Add legends to the plots.
99+
* - | :meth:`~marsilea.base.LegendMaker.add_legends`
100+
| Add legends to the plots.
101+
- .. image:: ../img/api_add_legends.png
88102
- .. code-block:: python
89103

90104
wb.add_legends()
91105

92-
* - :meth:`~marsilea.base.WhiteBoard.add_canvas`
93-
- Add a plotter to a chosen side of main plot.
106+
* - | :meth:`~marsilea.base.WhiteBoard.add_canvas`
107+
| Add a empty canvas to a chosen side of main plot.
108+
- .. image:: ../img/api_add_canvas.png
94109
- .. code-block:: python
95110

96-
wb.add_canvas("right", Numbers(data))
111+
wb.add_canvas("right")
97112

98-
* - :meth:`~marsilea.base.WhiteBoard.add_pad`
99-
- Add white space between plot.
113+
* - | :meth:`~marsilea.base.WhiteBoard.add_pad`
114+
| Add white space between plot.
115+
- ---
100116
- .. code-block:: python
101117

102118
wb.add_pad("right", 1)
103119

104-
* - :meth:`~marsilea.base.WhiteBoard.set_margin`
105-
- Add white space surrounding the figure.
120+
* - | :meth:`~marsilea.base.WhiteBoard.set_margin`
121+
| Add white space surrounding the figure.
122+
- ---
106123
- .. code-block:: python
107124

108125
wb.set_margin(1)
109126

110-
* - :meth:`~marsilea.base.WhiteBoard.render`
111-
- Render the plot.
127+
128+
* - | :meth:`~marsilea.base.WhiteBoard.render`
129+
| Render the plot.
130+
- ---
112131
- .. code-block:: python
113132

114133
wb.render()
115134

116-
* - :meth:`~marsilea.base.WhiteBoard.save`
117-
- Save the plot to a file.
135+
136+
* - | :meth:`~marsilea.base.WhiteBoard.save`
137+
| Save the plot to a file.
138+
- ---
118139
- .. code-block:: python
119140

120141
wb.save("output.png", dpi=300)
121142

122-
* - :code:`+`
123-
- Two canvas side by side, number will be added as white space
143+
* - | :code:`+`
144+
| Two canvas side by side, number will be added as white space
145+
- .. image:: ../img/api_concatenate_plus.png
124146
- .. code-block:: python
125147

126148
(wb1 + 1 + wb2).render()
127149

128-
* - :code:`/`
129-
- Two canvas top and bottom, number will be added as white space
150+
* - | :code:`/`
151+
| Two canvas top and bottom, number will be added as white space
152+
- .. image:: ../img/api_concatenate_divide.png
130153
- .. code-block:: python
131154

132155
(wb1 / 1 / wb2).render()

docs/source/tutorial/axes-level.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ to retrieve the named axes.
6060
:context: close-figs
6161

6262
>>> h = ma.Heatmap(data, linewidth=1)
63-
>>> h.hsplit(cut=[5])
63+
>>> h.cut_rows(cut=[5])
6464
>>> bar = ma.plotter.Numbers(np.arange(20))
6565
>>> h.add_right(bar, name="My Bar")
6666
>>> h.render()

0 commit comments

Comments
 (0)