Skip to content

Instantly share code, notes, and snippets.

View laurencee9's full-sized avatar

E. Laurence laurencee9

  • hectiq.ai
  • Québec, Canada
View GitHub Profile
@laurencee9
laurencee9 / gist:e0755ce0539c9a65a2f416dad28c42f3
Created December 2, 2020 19:25
Dark jupyter theme - Credit: M. Laprise
jt -t monokai -f fira -fs 10 -nf ptsans -nfs 12 -ofs 12 -tfs 11 -N -kl -cursw 5 -cursc r -cellw 95% -T
@laurencee9
laurencee9 / random_contour.py
Created August 22, 2018 00:59
Construct a contour plot from a random landscape.
import numpy as np
import matplotlib.pyplot as plt
import scipy.stats as stats
import random as rdm
def add_mountain(V, idx, idy, height):
w,h = V.shape
X = np.broadcast_to(range(w), (h,w))
Y = np.transpose(np.broadcast_to(range(h), (w,h)))
R = np.sqrt((X-idx)**2.0+(Y-idy)**2.0)
@laurencee9
laurencee9 / latextools.sublime-settings
Last active August 2, 2018 14:59
Place the auxiliary files of latex compilation into another directory.
{
"output_directory": "./aux"
}
@laurencee9
laurencee9 / network_in_circle.py
Created July 17, 2018 23:27
Plot a network using networkx and clip it into a circle
import networkx as nx
import matplotlib.pyplot as plt
import matplotlib.patches as patches
# Generate network
N = 20
p=0.2
G = nx.erdos_renyi_graph(N,p)
# Figure
@laurencee9
laurencee9 / convertToRGB.py
Created June 26, 2018 15:08
Convert an image to RGB file
from PIL import Image
def remove_alpha(image_path):
Image.open(image_path).convert('RGB').save(image_path+"rgb.jpg")
@laurencee9
laurencee9 / draw_curved_edges.py
Last active July 9, 2019 19:34
Draw curved network edges in python
import numpy as np
import matplotlib.patches as mpatches
import networkx as nx
from matplotlib.patches import FancyArrowPatch as ArrowPath
from matplotlib.font_manager import FontProperties
def draw_curved_edges(edges, pos, ax, mu=0.05, edge_color="black", edge_width=1.0, alpha=1.0, arrow_scale=20.0, loopsize=0):
"""