Skip to content

Commit

Permalink
update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Milk committed Oct 12, 2022
1 parent 2c9df6d commit 21debc1
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 27 deletions.
3 changes: 2 additions & 1 deletion examples/plot_bubble.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@
# Create the dot heatmap
# ----------------------------
#
mv.bubble(x=x, y=y, size=size, hue=color, legend_kw={"title": "Size"}, cbar_kw={"title": "Value"})
mv.bubble(x=x, y=y, size=size, hue=color,
legend_kw={"title": "Size"}, cbar_kw={"title": "Value"})

3 changes: 2 additions & 1 deletion examples/plot_dot.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
# Create the dot heatmap
# ----------------------------
#
mv.dot(sizes, colors, yticklabels=labels, legend_kw={"title": "Size"})
mv.dot_heatmap(sizes, colors, yticklabels=labels,
dot_size_legend_kw={"title": "Size"})

2 changes: 1 addition & 1 deletion examples/plot_dot_heatmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@
#
mv.dot_heatmap(sizes, colors, xticklabels=labels,
dot_size_legend_kw={"title": "Dot Size"},
dot_hue_cbar_kw={"title": "Dot Color"},
dot_hue_cbar_kw={"title": "Dot Color", "alignment": "left"},
)

9 changes: 5 additions & 4 deletions examples/plot_dot_heatmap_matrix_masked.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"""
import numpy as np
import milkviz as mv
from milkviz import mask_triu

# %%
# First let's create some random data
Expand All @@ -26,9 +25,11 @@
# ----------------------------------------
# You can replace all unwanted values into `NaN`
#
sizes = mask_triu(sizes)
matrix = mask_triu(matrix)
mv.dot_heatmap(sizes, colors, matrix, xticklabels=labels, dot_patch="pie",
sizes = np.ma.masked_values(np.tril(sizes), 0)
colors = np.ma.masked_values(np.tril(colors), 0)
matrix = np.ma.masked_values(np.tril(matrix), 0)
mv.dot_heatmap(sizes, colors, matrix,
xticklabels=labels, dot_patch="pie",
dot_hue_cbar_kw={"title": "Dot Color"},
matrix_cbar_kw={"title": "Matrix Color"}
)
6 changes: 2 additions & 4 deletions examples/plot_point_map3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@
# -------------------------------------
#
np.random.seed(0)
x = np.random.randint(0, 100, 1000)
y = np.random.randint(0, 100, 1000)
z = np.random.randint(0, 100, 1000)
xyz = np.random.randint(0, 100, (1000, 3))
types = np.random.choice(list("abcdef"), 1000)

# %%
# Create the point map
# ----------------------------
#
mv.point_map3d(x, y, z, types=types, legend_kw={"title": "Type"})
mv.point_map(xyz, types=types, legend_kw={"title": "Type"})

13 changes: 6 additions & 7 deletions examples/plot_point_map_cat.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,21 @@
# -------------------------------------
#
np.random.seed(0)
x = np.random.randint(0, 100, 1000)
y = np.random.randint(0, 100, 1000)
types = np.random.choice(list("abcdefghijklmnopqrstux"), 1000)
xy = np.random.randint(0, 100, (1000, 2))
types = np.random.choice(list("abcdefg"), 1000)

# %%
# Create the point map
# ----------------------------
#
mv.point_map(x, y, types=types,
legend_kw={"title": "Type", "title_align": "center", "ncol": 2})
mv.point_map(xy, types=types,
legend_kw={"title": "Type", "ncol": 2})

# %%
# It's possible to add some links
# ---------------------------------
#
links = [np.random.choice([i for i in range(1000)], 2) for _ in range(50)]
mv.point_map(x, y, types, links=links,
legend_kw={"title": "Type", "title_align": "center", "ncol": 2})
mv.point_map(xy, types=types, links=links,
legend_kw={"title": "Type", "ncol": 2})

5 changes: 2 additions & 3 deletions examples/plot_point_map_value.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@
# -------------------------------------
#
np.random.seed(0)
x = np.random.randint(0, 100, 1000)
y = np.random.randint(0, 100, 1000)
xy = np.random.randint(0, 100, (1000, 2))
values = np.random.randint(0, 100, 1000)


# %%
# Create the cell map
# ----------------------------
#
mv.point_map(x, y, values=values, cbar_kw={"title": "Value"})
mv.point_map(xy, values=values, cbar_kw={"title": "Value"})
6 changes: 4 additions & 2 deletions examples/plot_stacked_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@
# Create the stacked_bar
# ----------------------------
#
mv.stacked_bar(data, x="storage", y="sales", stacked="product", show_values=True)
mv.stacked_bar(data, group="storage", value="sales", stacked="product",
show_values=True)


# %%
# Normalize the data to 1
# ----------------------------
#
mv.stacked_bar(data, x="storage", y="sales", stacked="product", percentage=True)
mv.stacked_bar(data, group="storage", value="sales", stacked="product",
percentage=True)
16 changes: 12 additions & 4 deletions examples/plot_venn.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,21 @@
#
# 1. Specific a list of sets
#
# 2. Specific a list of list, intersections between lists will be computed for you, duplicates will considred
# 2. Specific a list of list,
# intersections between lists will be computed for you,
# duplicates will considred
#
# 3. A list of number denotes the regions in venn diagram in the following order: venn2 used (10, 01, 11) or venn3 used (100, 010, 110, 001, 101, 011, 111)
# 3. A list of number denotes the regions in venn diagram
# in the following order: venn2 used (10, 01, 11)
# or venn3 used (100, 010, 110, 001, 101, 011, 111)
#
np.random.seed(0)
list_sets = [set([1,2,3,4,5,13,100]), set([4,5,6,7,8,100,101]), set([4,5,10,11,12,13,101])]
list_list = [np.random.randint(0, 20, 10), np.random.randint(0, 20, 30), np.random.randint(0, 20, 15)]
list_sets = [set([1,2,3,4,5,13,100]),
set([4,5,6,7,8,100,101]),
set([4,5,10,11,12,13,101])]
list_list = [np.random.randint(0, 20, 10),
np.random.randint(0, 20, 30),
np.random.randint(0, 20, 15)]
list_area = (1, 1, 1, 2, 1, 2, 2)


Expand Down

0 comments on commit 21debc1

Please sign in to comment.