This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bashgit clone --bare git@github.com:cvanelteren/dots.git $HOME/.dotfiles# define config alias locally since the dotfiles | |
# aren't installed on the system yet | |
function config { | |
git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME $@ | |
}# create a directory to backup existing dotfiles to | |
mkdir -p .dotfiles-backup | |
config checkout | |
if [ $? = 0 ]; then | |
echo "Checked out dotfiles from git@github.com:cvanelteren/dotfiles.git"; | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
from matplotlib.offsetbox import OffsetImage, AnnotationBbox | |
g = nx.krackhardt_kite_graph() | |
pos = nx.kamada_kawai_layout(g) | |
example = "unknown.jpg" | |
fig, ax = plt.subplots() | |
output_size = 25 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import proplot as plt, cmasher as cmr, pandas as pd,\ | |
numpy as np, os, sys, networkx as nx, warnings,\ | |
re | |
from pathlib import Path | |
warnings.simplefilter("ignore") | |
g = nx.krackhardt_kite_graph() | |
pos = nx.kamada_kawai_layout(g) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import proplot as plt, networkx as nx, pandas as pd | |
def bundle(g: nx.Graph, pos: dict): | |
from datashader.bundling import hammer_bundle | |
edges = [] | |
for u, v in g.edges(): | |
row = dict(source=u, target=v) | |
edges.append(row) | |
edges = pd.DataFrame(edges) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from mpl_toolkits.mplot3d import Axes3D | |
from mpl_toolkits.mplot3d.art3d import Poly3DCollection | |
def fill_between_3d(ax,x1,y1,z1,x2,y2,z2,mode=1,c='steelblue',alpha=0.6): | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def arc_layout( | |
G: nx.Graph, subset_key="subset", radius=1, rotation=0, offset=0 | |
) -> dict: | |
"""Arc layout for networkx | |
Provides a layout where a multipartite graph is | |
displayed on a unit circle. This could provide clear | |
visuals for data that is highly clustered. | |
Parameters |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import proplot as plt, cmasher as cmr, pandas as pd, numpy as np, os, sys, networkx as nx, warnings | |
def multilayer_layout( | |
G: nx.Graph, | |
subset_key="layer", | |
layout=nx.spring_layout, | |
separation: float = 10.0, | |
) -> dict: | |
# set positions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"directed": false, "multigraph": false, "graph": {"name": "Krackhardt Kite Social Network"}, "nodes": [{"id": 0}, {"id": 1}, {"id": 2}, {"id": 3}, {"id": 4}, {"id": 5}, {"id": 6}, {"id": 7}, {"id": 8}, {"id": 9}], "links": [{"source": 0, "target": 1}, {"source": 0, "target": 2}, {"source": 0, "target": 3}, {"source": 0, "target": 5}, {"source": 1, "target": 3}, {"source": 1, "target": 4}, {"source": 1, "target": 6}, {"source": 2, "target": 3}, {"source": 2, "target": 5}, {"source": 3, "target": 4}, {"source": 3, "target": 5}, {"source": 3, "target": 6}, {"source": 4, "target": 6}, {"source": 5, "target": 6}, {"source": 5, "target": 7}, {"source": 6, "target": 7}, {"source": 7, "target": 8}, {"source": 8, "target": 9}]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
here is a gif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import networkx as nx, numpy as np, matplotlib.pyplot as plt | |
np.random.seed(0) | |
g = nx.florentine_families_graph() | |
# g = nx.krackhardt_kite_graph() | |
pos = nx.random_layout(g) | |
x = {node: p[0] for node, p in pos.items()} | |
y = {node: p[1] for node, p in pos.items()} | |
l = {node: node for node in g.nodes()} |
NewerOlder