View git_submodule.sh
cd submodule_name
git checkout master
git pull
cd ..
git add submodule_name
git commit -m "Updating submodule to latest"
View hide_code_pdf.md
View fonts_matplotlib.md

Before fonts in matplotlib make you crazy again, remember:

  1. After installing a font in the system, you need to remove the cache:
~/.cache/matplotlib/fontList.cache
  1. If you using Ubuntu, you might need to install Vera
sudo apt-get install ttf-bitstream-vera 
View shade_color.md

Sometimes I want a color just brighter or darker:

def shade_color(hex_color, offset):
    new_color = hex_color
    if len(hex_color) in [6, 7]:
        if hex_color[0] == "#":
            hex_color = hex_color[1:]
        rgb_hex = np.array([float(int(hex_color[x:x+2], 16)) for x in [0, 2, 4]])
        rgb_hex /= 255.0
View bye_blurry.md

Removing the blurry effect on embedded images in .svg when exporting to .pdf

Open the pdf generated and:

  1. Remove /Interpolate true from the pdf.

  2. Change /SMask 63 0 R to /SMask 13 0 R

View colorblind_palette.md

Colorblind palette!

Colors from From: Wong, Bang. "Points of view: Color blindness." Nature methods 8.6 (2011): 441-441. in RGB:

color_names = ["Black", "Orange", "Sky blue", "Bluish green", "Yellow", "Blue", "Vermillion", "Reddish purple"]
colors_colorblind_safe = [(0, 0, 0), (230, 159, 0), (86, 180, 233), (0, 158, 115), (240, 228, 66), (0, 114, 178), (213, 94, 0), (204, 121, 167)]
colors_colorblind_safe = ['#%02x%02x%02x' % (c[0], c[1], c[2]) for c in colors_colorblind_safe]
colors = dict(zip(color_names, colors_colorblind_safe))
three_colors = colors['Blue'], colors['Vermillion'], colors['Bluish green']
View symbols.tex
%http://www.ctan.org/tex-archive/info/symbols/comprehensive/symbols-a4.pdf
\usepackage{latexsym} % needs this to have on latex2e
$\bullet$
View guerry_balbi_quetelet.bibtex
@BOOK{quetelet1833recherches,
address = {Brussels, Belgium},
author = {Quetelet, A},
pages = {87},
publisher = {M. Hayez},
title = {{Recherches sur le penchant au crime aux diff{\'{e}}rens {\^{a}}ges}},
url = {https://books.google.com/books?id=ZNEiAAAAMAAJ},
year = {1833}
}
View howto.md

Approach A

  1. Export the plot as SVG
   plt.savefig("plot.svg")
  1. Open plot.svg with an editor and include in the definitions the following:
<defs>
   <filter id="shadow">
      <feOffset dx="0" dy="0"/>
View get_projection.py
from osgeo import ogr, osr
driver = ogr.GetDriverByName('ESRI Shapefile')
dataset = driver.Open(r'tabblock2010_25_pophu.shp')
# from Layer
layer = dataset.GetLayer()
spatialRef = layer.GetSpatialRef()
print spatialRef
# from Geometry
feature = layer.GetNextFeature()
geom = feature.GetGeometryRef()