Skip to content

Instantly share code, notes, and snippets.

@scholich
scholich / mpl_switch_style
Created May 28, 2015 14:36
Switch matplotlib style
from pylab import plt, rc
print plt.style.available
plt.style.use('ggplot')
rc('font', size=12)
@scholich
scholich / notebook_test
Created May 28, 2015 14:41
Notebook Test
This file has been truncated, but you can view the full file.
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Some examples of mpl-based plots rendered by Bokeh"
]
},
{
@scholich
scholich / mayavi_mpl_colorbar
Created June 19, 2015 10:07
Use Matplotlib colorbars in Mayavi
from mayavi import mlab
from pylab import plt
from numpy import array, linspace
def adjust_colorbar(pts, cb_title, vmin, vmax):
pts.glyph.glyph_source.glyph_source.center = [0, 0, 0]
pts.glyph.glyph.color_mode = 'color_by_scalar'
pts.glyph.color_mode = 'color_by_scalar'
pts.glyph.glyph.scale_mode = 'data_scaling_off'
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
// leave at least 2 line with only a star on it below, or doc generation fails
/**
*
*
* Placeholder for custom user javascript
* mainly to be overridden in profile/static/custom/custom.js
* This will always be an empty file in IPython
*
* User could add any javascript in the `profile/static/custom/custom.js` file
* (and should create it if it does not exist).
@scholich
scholich / bibtex_to_wiki.py
Created April 14, 2016 10:52
Convert a zotero exported bibtex file to wiki format.
"""Convert a zotero exported bibtex file to wiki format for the journal scan.
Take the first bibfile in the current directory and print the wikiformat.
"""
import glob
# open file
bibfiles = glob.glob('*.bib')
for name in bibfiles:
name = bibfiles[0]
@scholich
scholich / region_plot_test.nb
Last active April 29, 2016 16:22
Mathematica Code to test BoundaryStyle setting of RegionPlot
hexToRGB =
RGBColor @@ (IntegerDigits[#~StringDrop~1~FromDigits~16, 256, 3]/
255.) &
colors = Table[ColorData[1][x], {x, 0, 36, 1}];
colorsHex = {"#DA96D1", "#DC4AD4", "#97E43B", "#52C858", "#B36EE2",
"#B0429C", "#827CE0", "#CC3B4F", "#7BDA91", "#498727", "#E94292",
"#C3D676", "#59397F", "#3EC3A3", "#E24925", "#5999EB", "#E69F34",
"#506BB4", "#DC722A", "#48BAD3", "#C0D5B7", "#72244C", "#C1B535",
"#D77F84", "#557B49", "#642B23", "#C3BCCF", "#D5A974", "#3D3448",
"#A95531", "#536B90", "#53817B", "#9B5B87", "#323B24", "#93776C",
@scholich
scholich / closest_named_color.py
Created May 4, 2016 10:02
Get the closest named color to a hex or triple RGB value from the XKCD color naming survey, see http://xkcd.com/color/rgb/.
"""Get closest named color according to XKCD's color naming survey `http://xkcd.com/color/rgb/`.
rgb.tex from `http://xkcd.com/color/rgb.txt` must reside in working directory.
"""
from pylab import np
import csv
import struct
@scholich
scholich / letter_counting.html
Created October 5, 2016 14:43
Count phonetic letters in German alphabet for a given sentence. Make sure to save the file with utf-8 encoding for the Umlauts.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Letter counter</title>
<meta name="description" content="The HTML5 Herald">
<meta name="author" content="SitePoint">