├── README.md ├── base16-mplrc-themes ├── 3024.json ├── atelierdune.json ├── atelierforest.json ├── atelierheath.json ├── atelierlakeside.json ├── atelierseaside.json ├── bespin.json ├── bright.json ├── chalk.json ├── default.json ├── eighties.json ├── flat.json ├── grayscale.json ├── greenscreen.json ├── isotope.json ├── londontube.json ├── marrakesh.json ├── mocha.json ├── monokai.json ├── ocean.json ├── paraiso.json ├── pop.json ├── railscasts.json ├── shapeshifter.json ├── solarized.json ├── test.json ├── tomorrow.json └── twilight.json ├── base16_mplrc.py ├── color_preview.ipynb ├── eighties_dark.png ├── eighties_dark_cmaps.png ├── sddl.png ├── solarized_dark.png └── solarized_dark_cmaps.png /README.md: -------------------------------------------------------------------------------- 1 | # Base 16 Inline Backend Themes for IPython Notebook 2 | 3 | An ipython extension to load custom matplotlibrcs to accompany Nikhil Sonnad's [style sheets][0] for [IPython Notebook][1], using Chris Kempson's [Base16][2] color scheme generator 4 | 5 | *There was a bug in IPython2.0 that resulted in the figure backgrounds always being white. If you experience this issue, pull the lastest version of IPython and it should be fixed* 6 | 7 | ## Screenshots 8 | 9 | ####Eighties Dark with Eighties Dark notebook 10 | ![sdsd](eighties_dark.png) 11 | ![sdsd](eighties_dark_cmaps.png) 12 | 13 | ####Solarized Dark with Solarized Dark notebook 14 | ![sdsd](solarized_dark.png) 15 | ![sdsd](solarized_dark_cmaps.png) 16 | 17 | ####Default Light with Solarized Dark notebook 18 | ![sddl](sddl.png) 19 | 20 | 21 | 22 | ## Installation 23 | 24 | To use these color schemes, you'll install this extension in the extensions folder of your ipython. You can find where your ipython directory is, run 25 | `ipython locate` 26 | 27 | You can copy the contents of this directory into your `extensions` directory in your base ipython directory. 28 | 29 | ``` 30 | cp -r base16* ~/.ipython/extensions/. 31 | ``` 32 | 33 | Once installed, this extension can be loaded as any other ipython extension 34 | 35 | Using the `%load_ext` magic: 36 | 37 | ``` 38 | In [1]: %load_ext base16_mplrc 39 | ``` 40 | 41 | or by modifying `ipython_notebook_config.py` in your profile directory 42 | 43 | ``c.InteractiveShellApp.extensions = [ 44 | 'base16_mplrc' 45 | ]`` 46 | 47 | If you don't have a custom profile, run: 48 | 49 | `ipython profile create ` 50 | 51 | To locate the directory of your profile, do: 52 | 53 | `ipython locate profile ` 54 | 55 | 56 | once loaded, you can invoke it via line magic 57 | 58 | ``` 59 | In [1]: %base16_mplrc 60 | %pylab inline 61 | ``` 62 | 63 | `shade` and `theme` are both optional positional arguments. If both are absent, then this extension 64 | attempts to find the one matching the base16 theme you have installed in profile directory's `static/custom/custom.css`. 65 | 66 | ``` 67 | Type: Magic function 68 | String Form:> 69 | Namespace: IPython internal 70 | File: /home/benjib0t/.ipython/extensions/base16_mplrc.py 71 | Definition: %base16_mplrc(self, args) 72 | Docstring: 73 | :: 74 | 75 | %base16_mplrc [shade] [theme] 76 | 77 | positional arguments: 78 | shade shade of theme, light or dark 79 | theme base16 theme 80 | ``` 81 | 82 | 83 | This extension will only modify the colors of your matplotlibrc for the use in the ipython notebooks; it will respect any other settings in your default matplotlibrc 84 | 85 | It also pushes an object `b16_colors` to your shell, which contains colors and colormaps. 86 | 87 | ``` 88 | #colors 89 | b16_colors.r = b16_colors.red 90 | b16_colors.o = b16_colors.orange 91 | b16_colors.y = b16_colors.yellow 92 | b16_colors.g = b16_colors.green 93 | b16_colors.c = b16_colors.cyan 94 | b16_colors.b = b16_colors.blue 95 | b16_colors.m = b16_colors.magenta 96 | b16_colors.n = b16_colors.brown 97 | b16_colors.w = b16_colors.white 98 | b16_colors.k = b16_colors.black 99 | 100 | #colormaps 101 | b16_colors.jet registered as 'b16_jet' 102 | b16_colors.gray registered as 'b16_gray' 103 | b16_colors.blues registered as 'b16_blues' 104 | b16_colors.greens registered as 'b16_greens' 105 | b16_colors.reds registered as 'b16_reds' 106 | b16_colors.oranges registered as 'b16_oranges' 107 | b16_colors.flame registered as 'b16_flame' 108 | b16_colors.brbg registered as 'b16_brbg' 109 | ``` 110 | 111 | ## Custom fonts 112 | You can set the default fonts by modifying your `ipython_notebook_config.py`: 113 | 114 | ``` 115 | c.InlineBackend.rc = {'font.family':'Inconsolata'} 116 | ``` 117 | ## Credits 118 | 119 | * Uses Base16 builder by [Chris Kempson][3]. 120 | * Based off of base16-ipython-notebook by [Nikhil Sonnad][0]. 121 | 122 | [0]: https://github.com/nsonnad/base16-ipython-notebook 123 | [1]: http://ipython.org/notebook.html 124 | [2]: https://github.com/chriskempson/base16 125 | [3]: https://github.com/chriskempson 126 | [4]: https://github.com/idleberg/base16-codemirror 127 | [5]: https://github.com/idleberg 128 | -------------------------------------------------------------------------------- /base16-mplrc-themes/3024.json: -------------------------------------------------------------------------------- 1 | {"base09": "#e8bbd0", "base08": "#db2d20", "base01": "#3a3432", "base00": "#090300", "base03": "#5c5855", "base02": "#4a4543", "base05": "#a5a2a2", "base04": "#807d7c", "base07": "#f7f7f7", "base06": "#d6d5d4", "base0A": "#fded02", "base0C": "#b5e4f4", "base0B": "#01a252", "base0E": "#a16a94", "base0D": "#01a0e4", "base0F": "#cdab53"} -------------------------------------------------------------------------------- /base16-mplrc-themes/atelierdune.json: -------------------------------------------------------------------------------- 1 | {"base09": "#b65611", "base08": "#d73737", "base01": "#292824", "base00": "#20201d", "base03": "#7d7a68", "base02": "#6e6b5e", "base05": "#a6a28c", "base04": "#999580", "base07": "#fefbec", "base06": "#e8e4cf", "base0A": "#cfb017", "base0C": "#1fad83", "base0B": "#60ac39", "base0E": "#b854d4", "base0D": "#6684e1", "base0F": "#d43552"} -------------------------------------------------------------------------------- /base16-mplrc-themes/atelierforest.json: -------------------------------------------------------------------------------- 1 | {"base09": "#df5320", "base08": "#f22c40", "base01": "#2c2421", "base00": "#1b1918", "base03": "#766e6b", "base02": "#68615e", "base05": "#a8a19f", "base04": "#9c9491", "base07": "#f1efee", "base06": "#e6e2e0", "base0A": "#d5911a", "base0C": "#00ad9c", "base0B": "#5ab738", "base0E": "#6666ea", "base0D": "#407ee7", "base0F": "#c33ff3"} -------------------------------------------------------------------------------- /base16-mplrc-themes/atelierheath.json: -------------------------------------------------------------------------------- 1 | {"base09": "#a65926", "base08": "#ca402b", "base01": "#292329", "base00": "#1b181b", "base03": "#776977", "base02": "#695d69", "base05": "#ab9bab", "base04": "#9e8f9e", "base07": "#f7f3f7", "base06": "#d8cad8", "base0A": "#bb8a35", "base0C": "#159393", "base0B": "#379a37", "base0E": "#7b59c0", "base0D": "#516aec", "base0F": "#cc33cc"} -------------------------------------------------------------------------------- /base16-mplrc-themes/atelierlakeside.json: -------------------------------------------------------------------------------- 1 | {"base09": "#935c25", "base08": "#d22d72", "base01": "#1f292e", "base00": "#161b1d", "base03": "#5a7b8c", "base02": "#516d7b", "base05": "#7ea2b4", "base04": "#7195a8", "base07": "#ebf8ff", "base06": "#c1e4f6", "base0A": "#8a8a0f", "base0C": "#2d8f6f", "base0B": "#568c3b", "base0E": "#5d5db1", "base0D": "#257fad", "base0F": "#b72dd2"} -------------------------------------------------------------------------------- /base16-mplrc-themes/atelierseaside.json: -------------------------------------------------------------------------------- 1 | {"base09": "#87711d", "base08": "#e6193c", "base01": "#242924", "base00": "#131513", "base03": "#687d68", "base02": "#5e6e5e", "base05": "#8ca68c", "base04": "#809980", "base07": "#f0fff0", "base06": "#cfe8cf", "base0A": "#c3c322", "base0C": "#1999b3", "base0B": "#29a329", "base0E": "#ad2bee", "base0D": "#3d62f5", "base0F": "#e619c3"} -------------------------------------------------------------------------------- /base16-mplrc-themes/bespin.json: -------------------------------------------------------------------------------- 1 | {"base09": "#cf7d34", "base08": "#cf6a4c", "base01": "#36312e", "base00": "#28211c", "base03": "#666666", "base02": "#5e5d5c", "base05": "#8a8986", "base04": "#797977", "base07": "#baae9e", "base06": "#9d9b97", "base0A": "#f9ee98", "base0C": "#afc4db", "base0B": "#54be0d", "base0E": "#9b859d", "base0D": "#5ea6ea", "base0F": "#937121"} -------------------------------------------------------------------------------- /base16-mplrc-themes/bright.json: -------------------------------------------------------------------------------- 1 | {"base09": "#fc6d24", "base08": "#fb0120", "base01": "#303030", "base00": "#000000", "base03": "#b0b0b0", "base02": "#505050", "base05": "#e0e0e0", "base04": "#d0d0d0", "base07": "#ffffff", "base06": "#f5f5f5", "base0A": "#fda331", "base0C": "#76c7b7", "base0B": "#a1c659", "base0E": "#d381c3", "base0D": "#6fb3d2", "base0F": "#be643c"} -------------------------------------------------------------------------------- /base16-mplrc-themes/chalk.json: -------------------------------------------------------------------------------- 1 | {"base09": "#eda987", "base08": "#fb9fb1", "base01": "#202020", "base00": "#151515", "base03": "#505050", "base02": "#303030", "base05": "#d0d0d0", "base04": "#b0b0b0", "base07": "#f5f5f5", "base06": "#e0e0e0", "base0A": "#ddb26f", "base0C": "#12cfc0", "base0B": "#acc267", "base0E": "#e1a3ee", "base0D": "#6fc2ef", "base0F": "#deaf8f"} -------------------------------------------------------------------------------- /base16-mplrc-themes/default.json: -------------------------------------------------------------------------------- 1 | {"base09": "#d28445", "base08": "#ac4142", "base01": "#202020", "base00": "#151515", "base03": "#505050", "base02": "#303030", "base05": "#d0d0d0", "base04": "#b0b0b0", "base07": "#f5f5f5", "base06": "#e0e0e0", "base0A": "#f4bf75", "base0C": "#75b5aa", "base0B": "#90a959", "base0E": "#aa759f", "base0D": "#6a9fb5", "base0F": "#8f5536"} -------------------------------------------------------------------------------- /base16-mplrc-themes/eighties.json: -------------------------------------------------------------------------------- 1 | {"base09": "#f99157", "base08": "#f2777a", "base01": "#393939", "base00": "#2d2d2d", "base03": "#747369", "base02": "#515151", "base05": "#d3d0c8", "base04": "#a09f93", "base07": "#f2f0ec", "base06": "#e8e6df", "base0A": "#ffcc66", "base0C": "#66cccc", "base0B": "#99cc99", "base0E": "#cc99cc", "base0D": "#6699cc", "base0F": "#d27b53"} -------------------------------------------------------------------------------- /base16-mplrc-themes/flat.json: -------------------------------------------------------------------------------- 1 | {"base09": "#E67E22", "base08": "#E74C3C", "base01": "#34495E", "base00": "#2C3E50", "base03": "#95A5A6", "base02": "#7F8C8D", "base05": "#e0e0e0", "base04": "#BDC3C7", "base07": "#ECF0F1", "base06": "#f5f5f5", "base0A": "#F1C40F", "base0C": "#1ABC9C", "base0B": "#2ECC71", "base0E": "#9B59B6", "base0D": "#3498DB", "base0F": "#be643c"} -------------------------------------------------------------------------------- /base16-mplrc-themes/grayscale.json: -------------------------------------------------------------------------------- 1 | {"base09": "#999999", "base08": "#7c7c7c", "base01": "#252525", "base00": "#101010", "base03": "#525252", "base02": "#464646", "base05": "#b9b9b9", "base04": "#ababab", "base07": "#f7f7f7", "base06": "#e3e3e3", "base0A": "#a0a0a0", "base0C": "#868686", "base0B": "#8e8e8e", "base0E": "#747474", "base0D": "#686868", "base0F": "#5e5e5e"} -------------------------------------------------------------------------------- /base16-mplrc-themes/greenscreen.json: -------------------------------------------------------------------------------- 1 | {"base09": "#009900", "base08": "#007700", "base01": "#003300", "base00": "#001100", "base03": "#007700", "base02": "#005500", "base05": "#00bb00", "base04": "#009900", "base07": "#00ff00", "base06": "#00dd00", "base0A": "#007700", "base0C": "#005500", "base0B": "#00bb00", "base0E": "#00bb00", "base0D": "#009900", "base0F": "#005500"} -------------------------------------------------------------------------------- /base16-mplrc-themes/isotope.json: -------------------------------------------------------------------------------- 1 | {"base09": "#ff9900", "base08": "#ff0000", "base01": "#404040", "base00": "#000000", "base03": "#808080", "base02": "#606060", "base05": "#d0d0d0", "base04": "#c0c0c0", "base07": "#ffffff", "base06": "#e0e0e0", "base0A": "#ff0099", "base0C": "#00ffff", "base0B": "#33ff00", "base0E": "#cc00ff", "base0D": "#0066ff", "base0F": "#3300ff"} -------------------------------------------------------------------------------- /base16-mplrc-themes/londontube.json: -------------------------------------------------------------------------------- 1 | {"base09": "#f386a1", "base08": "#ee2e24", "base01": "#1c3f95", "base00": "#231f20", "base03": "#737171", "base02": "#5a5758", "base05": "#d9d8d8", "base04": "#959ca1", "base07": "#ffffff", "base06": "#e7e7e8", "base0A": "#ffd204", "base0C": "#85cebc", "base0B": "#00853e", "base0E": "#98005d", "base0D": "#009ddc", "base0F": "#b06110"} -------------------------------------------------------------------------------- /base16-mplrc-themes/marrakesh.json: -------------------------------------------------------------------------------- 1 | {"base09": "#b36144", "base08": "#c35359", "base01": "#302e00", "base00": "#201602", "base03": "#6c6823", "base02": "#5f5b17", "base05": "#948e48", "base04": "#86813b", "base07": "#faf0a5", "base06": "#ccc37a", "base0A": "#a88339", "base0C": "#75a738", "base0B": "#18974e", "base0E": "#8868b3", "base0D": "#477ca1", "base0F": "#b3588e"} -------------------------------------------------------------------------------- /base16-mplrc-themes/mocha.json: -------------------------------------------------------------------------------- 1 | {"base09": "#d28b71", "base08": "#cb6077", "base01": "#534636", "base00": "#3B3228", "base03": "#7e705a", "base02": "#645240", "base05": "#d0c8c6", "base04": "#b8afad", "base07": "#f5eeeb", "base06": "#e9e1dd", "base0A": "#f4bc87", "base0C": "#7bbda4", "base0B": "#beb55b", "base0E": "#a89bb9", "base0D": "#8ab3b5", "base0F": "#bb9584"} -------------------------------------------------------------------------------- /base16-mplrc-themes/monokai.json: -------------------------------------------------------------------------------- 1 | {"base09": "#fd971f", "base08": "#f92672", "base01": "#383830", "base00": "#272822", "base03": "#75715e", "base02": "#49483e", "base05": "#f8f8f2", "base04": "#a59f85", "base07": "#f9f8f5", "base06": "#f5f4f1", "base0A": "#f4bf75", "base0C": "#a1efe4", "base0B": "#a6e22e", "base0E": "#ae81ff", "base0D": "#66d9ef", "base0F": "#cc6633"} -------------------------------------------------------------------------------- /base16-mplrc-themes/ocean.json: -------------------------------------------------------------------------------- 1 | {"base09": "#d08770", "base08": "#bf616a", "base01": "#343d46", "base00": "#2b303b", "base03": "#65737e", "base02": "#4f5b66", "base05": "#c0c5ce", "base04": "#a7adba", "base07": "#eff1f5", "base06": "#dfe1e8", "base0A": "#ebcb8b", "base0C": "#96b5b4", "base0B": "#a3be8c", "base0E": "#b48ead", "base0D": "#8fa1b3", "base0F": "#ab7967"} -------------------------------------------------------------------------------- /base16-mplrc-themes/paraiso.json: -------------------------------------------------------------------------------- 1 | {"base09": "#f99b15", "base08": "#ef6155", "base01": "#41323f", "base00": "#2f1e2e", "base03": "#776e71", "base02": "#4f424c", "base05": "#a39e9b", "base04": "#8d8687", "base07": "#e7e9db", "base06": "#b9b6b0", "base0A": "#fec418", "base0C": "#5bc4bf", "base0B": "#48b685", "base0E": "#815ba4", "base0D": "#06b6ef", "base0F": "#e96ba8"} -------------------------------------------------------------------------------- /base16-mplrc-themes/pop.json: -------------------------------------------------------------------------------- 1 | {"base09": "#f29333", "base08": "#eb008a", "base01": "#202020", "base00": "#000000", "base03": "#505050", "base02": "#303030", "base05": "#d0d0d0", "base04": "#b0b0b0", "base07": "#ffffff", "base06": "#e0e0e0", "base0A": "#f8ca12", "base0C": "#00aabb", "base0B": "#37b349", "base0E": "#b31e8d", "base0D": "#0e5a94", "base0F": "#7a2d00"} -------------------------------------------------------------------------------- /base16-mplrc-themes/railscasts.json: -------------------------------------------------------------------------------- 1 | {"base09": "#cc7833", "base08": "#da4939", "base01": "#272935", "base00": "#2b2b2b", "base03": "#5a647e", "base02": "#3a4055", "base05": "#e6e1dc", "base04": "#d4cfc9", "base07": "#f9f7f3", "base06": "#f4f1ed", "base0A": "#ffc66d", "base0C": "#519f50", "base0B": "#a5c261", "base0E": "#b6b3eb", "base0D": "#6d9cbe", "base0F": "#bc9458"} -------------------------------------------------------------------------------- /base16-mplrc-themes/shapeshifter.json: -------------------------------------------------------------------------------- 1 | {"base09": "#e09448", "base08": "#e92f2f", "base01": "#040404", "base00": "#000000", "base03": "#343434", "base02": "#102015", "base05": "#ababab", "base04": "#555555", "base07": "#f9f9f9", "base06": "#e0e0e0", "base0A": "#dddd13", "base0C": "#23edda", "base0B": "#0ed839", "base0E": "#f996e2", "base0D": "#3b48e3", "base0F": "#69542d"} -------------------------------------------------------------------------------- /base16-mplrc-themes/solarized.json: -------------------------------------------------------------------------------- 1 | {"base09": "#cb4b16", "base08": "#dc322f", "base01": "#073642", "base00": "#002b36", "base03": "#657b83", "base02": "#586e75", "base05": "#93a1a1", "base04": "#839496", "base07": "#fdf6e3", "base06": "#eee8d5", "base0A": "#b58900", "base0C": "#2aa198", "base0B": "#859900", "base0E": "#6c71c4", "base0D": "#268bd2", "base0F": "#d33682"} -------------------------------------------------------------------------------- /base16-mplrc-themes/test.json: -------------------------------------------------------------------------------- 1 | {"\"base02\"": "\"#505050\"", "\"base04\"": "\"#d0d0d0\"", "\"base05\"": "\"#e0e0e0\"", "\"base00\"": "\"#000000\"", "\"base01\"": "\"#303030\"", "\"base03\"": "\"#b0b0b0\"", "\"base0F\"": "\"#be643c\"", "\"base08\"": "\"#fb0120\"", "\"base09\"": "\"#fc6d24\"", "\"base0B\"": "\"#a1c659\"", "\"base0D\"": "\"#6fb3d2\"", "\"base0E\"": "\"#d381c3\"", "\"base07\"": "\"#ffffff\"", "\"base0A\"": "\"#fda331\"", "\"base0C\"": "\"#76c7b7\"", "\"base06\"": "\"#f5f5f5\""} 2 | -------------------------------------------------------------------------------- /base16-mplrc-themes/tomorrow.json: -------------------------------------------------------------------------------- 1 | {"base09": "#de935f", "base08": "#cc6666", "base01": "#282a2e", "base00": "#1d1f21", "base03": "#969896", "base02": "#373b41", "base05": "#c5c8c6", "base04": "#b4b7b4", "base07": "#ffffff", "base06": "#e0e0e0", "base0A": "#f0c674", "base0C": "#8abeb7", "base0B": "#b5bd68", "base0E": "#b294bb", "base0D": "#81a2be", "base0F": "#a3685a"} -------------------------------------------------------------------------------- /base16-mplrc-themes/twilight.json: -------------------------------------------------------------------------------- 1 | {"base09": "#cda869", "base08": "#cf6a4c", "base01": "#323537", "base00": "#1e1e1e", "base03": "#5f5a60", "base02": "#464b50", "base05": "#a7a7a7", "base04": "#838184", "base07": "#ffffff", "base06": "#c3c3c3", "base0A": "#f9ee98", "base0C": "#afc4db", "base0B": "#8f9d6a", "base0E": "#9b859d", "base0D": "#7587a6", "base0F": "#9b703f"} -------------------------------------------------------------------------------- /base16_mplrc.py: -------------------------------------------------------------------------------- 1 | ''' 2 | This will theme the inline backend of maptlotlib using base16 fonts 3 | 4 | It integrates with Nikhil Sonnad's base16-ipython-notebook themes, 5 | available here: https://github.com/nsonnad/base16-ipython-notebook 6 | 7 | Invoke this via inline magic 8 | 9 | `%base16_mplrc` 10 | 11 | will try to determine the base16 theme if you have used one of Nikhil's 12 | 13 | otherwisr 14 | 15 | `%base16_mplrc ` 16 | 17 | will load the theme in . e.g., 18 | 19 | `%base16_mplrc dark solarized` 20 | ''' 21 | #------------------------------------------------------- 22 | # This extension defines a magic that will configure 23 | # InlineBackend.rc to match the active base16 custom.css 24 | # file, if present 25 | #------------------------------------------------------- 26 | 27 | #------------------------------------------------------- 28 | # imports 29 | #------------------------------------------------------- 30 | 31 | #stdlib 32 | import os 33 | import re 34 | import json 35 | import glob 36 | 37 | #ipython 38 | from IPython.core.magic import Magics, magics_class, line_magic 39 | from IPython.utils.warn import error 40 | from IPython.core.magic_arguments import (argument, magic_arguments, parse_argstring) 41 | 42 | @magics_class 43 | class MPLRCMagics(Magics): 44 | def __init__(self,shell): 45 | super(MPLRCMagics,self).__init__(shell) 46 | 47 | @line_magic 48 | @magic_arguments() 49 | @argument('shade', nargs='?', default = None,help='shade of theme, light or dark') 50 | @argument('theme', nargs='?', default=None, help='base16 theme') 51 | def base16_mplrc(self,args): 52 | #parse the magick arguments 53 | args = parse_argstring(self.base16_mplrc,args) 54 | shade = args.shade 55 | theme = args.theme 56 | 57 | #detect the base16 ipython notebook theme, setup the matplotlib rc 58 | css_theme = None 59 | css_shade = None 60 | custom_css_fname = self.shell.profile_dir.location+'/static/custom/custom.css' 61 | if os.path.exists(custom_css_fname): 62 | with open(custom_css_fname) as css_file: 63 | for line in css_file: 64 | if(re.match('^\s*Name: ',line)): 65 | css_theme = line.split()[2].lower() 66 | css_shade = line.split()[-1].lower() 67 | 68 | #fall back on sensible defaults 69 | if theme is None: 70 | theme = css_theme 71 | if shade is None: 72 | shade = css_shade 73 | if theme is None: 74 | print(''' 75 | Could not detect base-16 ipython notebook theme. Download base16 theme notebook theme 76 | from https://github.com/nsonnad/base16-ipython-notebook . Using \'default\' theme.''') 77 | theme='default' 78 | 79 | if shade is None: 80 | print(''' 81 | Could not detect base-16 ipython notebook theme shade. Download base16 theme notebook themes 82 | from https://github.com/nsonnad/base16-ipython-notebook . Using \'default\' theme.''') 83 | shade = 'light' 84 | 85 | avail_themes = [os.path.split(f)[-1].split('.')[0] for f in glob.glob(self.shell.ipython_dir+'/extensions/base16-mplrc-themes/*.json')] 86 | #validate input 87 | if shade not in ['dark','light']: 88 | print("shade must be either dark or light, defaulting to light") 89 | shade = 'light' 90 | if theme not in avail_themes: 91 | print("theme must be present in base16-mplrc-themes dir, defaulting to 'default'") 92 | print("Available themes:") 93 | for t in avail_themes: 94 | print("\t{}".format(t)) 95 | theme = 'default' 96 | 97 | print("Setting plotting theme to {}-{}. Palette available in b16_colors".format(theme,shade)) 98 | 99 | theme_colors = json.load(open(self.shell.ipython_dir+'/extensions/base16-mplrc-themes/'+theme+'.json')) 100 | 101 | #snag the matplotlibrc configuration from the ipython config 102 | from IPython.kernel.zmq.pylab.backend_inline import InlineBackend 103 | cfg = InlineBackend.instance(parent=self.shell) 104 | cfg.shell=self.shell 105 | if cfg not in self.shell.configurables: 106 | self.shell.configurables.append(cfg) 107 | if shade=="dark": 108 | cfg.rc = {'figure.facecolor':theme_colors['base00'], 109 | 'savefig.facecolor':theme_colors['base00'], 110 | 'text.color':theme_colors['base07'], 111 | 'axes.color_cycle':[theme_colors['base{:02X}'.format(i)] for i in [13,8,11,9,12,14,10,15]], 112 | 'axes.facecolor': theme_colors['base01'], 113 | 'axes.edgecolor': theme_colors['base01'], 114 | 'axes.labelcolor': theme_colors['base07'], 115 | 'lines.color': theme_colors['base09'], 116 | 'lines.markeredgewidth': 0, 117 | 'patch.facecolor': theme_colors['base09'], 118 | 'patch.edgecolor': theme_colors['base02'], 119 | 'xtick.color': theme_colors['base07'], 120 | 'ytick.color': theme_colors['base07'], 121 | 'grid.color': theme_colors['base02']} 122 | elif shade=="light": 123 | cfg.rc = {'figure.facecolor':theme_colors['base07'], 124 | 'savefig.facecolor':theme_colors['base07'], 125 | 'text.color':theme_colors['base00'], 126 | 'axes.color_cycle':[theme_colors['base{:02X}'.format(i)] for i in [13,8,11,9,12,14,10,15]], 127 | 'axes.facecolor': theme_colors['base07'], 128 | 'axes.edgecolor': theme_colors['base00'], 129 | 'axes.labelcolor': theme_colors['base00'], 130 | 'lines.color': theme_colors['base0D'], 131 | 'lines.markeredgewidth': 0, 132 | 'patch.facecolor': theme_colors['base0D'], 133 | 'patch.edgecolor': theme_colors['base02'], 134 | 'xtick.color': theme_colors['base00'], 135 | 'ytick.color': theme_colors['base00'], 136 | 'grid.color': theme_colors['base06']} 137 | #If pyplot is already using the InlineBackend, this will force an update to the rcParams 138 | 139 | from matplotlib import pyplot, cm 140 | from matplotlib.colors import ColorConverter, ListedColormap 141 | import numpy as np 142 | 143 | conv = ColorConverter() 144 | if pyplot.rcParams['backend'] == 'module://IPython.kernel.zmq.pylab.backend_inline': 145 | 146 | #push the color pallete into scope for the user 147 | full=['red','orange','yellow','green','cyan','blue','magenta','brown'] 148 | abbr=['r','o','y','g','c','b','m','n'] 149 | #create a color palette class 150 | class Palette(object): pass 151 | b16_colors=Palette() 152 | for f,a,i in zip(full,abbr,range(8,16)): 153 | setattr(b16_colors,f,conv.to_rgb(theme_colors['base{:02X}'.format(i)])) 154 | setattr(b16_colors,a,conv.to_rgb(theme_colors['base{:02X}'.format(i)])) 155 | 156 | setattr(b16_colors,'white',conv.to_rgb(theme_colors['base07'])) 157 | setattr(b16_colors,'w',conv.to_rgb(theme_colors['base07'])) 158 | setattr(b16_colors,'black',conv.to_rgb(theme_colors['base00'])) 159 | setattr(b16_colors,'k',conv.to_rgb(theme_colors['base00'])) 160 | 161 | #----------------- Color maps ---------------------# 162 | def make_gradient(cols): 163 | N=255 164 | M=int(np.ceil(N/len(cols))) 165 | reds = np.empty((0),dtype=np.float) 166 | blues = np.empty((0),dtype=np.float) 167 | greens = np.empty((0),dtype=np.float) 168 | for c0,c1 in zip(cols[:-1],cols[1:]): 169 | reds = np.concatenate((reds,np.linspace(c0[0],c1[0],M-1))) 170 | greens = np.concatenate((greens,np.linspace(c0[1],c1[1],M-1))) 171 | blues = np.concatenate((blues,np.linspace(c0[2],c1[2],M-1))) 172 | return np.array((reds,greens,blues)).transpose() 173 | 174 | #Make a "jet" colormap 175 | cols =[b16_colors.b, 176 | b16_colors.c, 177 | b16_colors.g, 178 | b16_colors.y, 179 | b16_colors.o, 180 | b16_colors.r] 181 | b16_colors.jet = ListedColormap(make_gradient(cols),name='b16_jet') 182 | cm.register_cmap('b16_jet',b16_colors.jet) 183 | 184 | #Make a "grayscale" colormap 185 | cols = [conv.to_rgb(theme_colors['base{:02X}'.format(i)]) for i in range(8)] 186 | b16_colors.gray = ListedColormap(make_gradient(cols),name='b16_gray') 187 | cm.register_cmap('b16_gray',b16_colors.gray) 188 | 189 | #Make a "blues" colormap 190 | cols = [b16_colors.w,b16_colors.c,b16_colors.b] 191 | b16_colors.blues = ListedColormap(make_gradient(cols),name='b16_blues') 192 | cm.register_cmap('b16_blues',b16_colors.blues) 193 | 194 | #Make a "greens" colormap 195 | cols = [b16_colors.w,b16_colors.c,b16_colors.g] 196 | b16_colors.greens = ListedColormap(make_gradient(cols),name='b16_greens') 197 | cm.register_cmap('b16_greens',b16_colors.greens) 198 | 199 | #Make a "oranges" colormap 200 | cols = [b16_colors.w,b16_colors.y,b16_colors.o] 201 | b16_colors.oranges = ListedColormap(make_gradient(cols),name='b16_oranges') 202 | cm.register_cmap('b16_oranges',b16_colors.oranges) 203 | 204 | #Make a "reds" colormap 205 | cols = [b16_colors.w,b16_colors.y,b16_colors.o,b16_colors.r] 206 | b16_colors.reds = ListedColormap(make_gradient(cols),name='b16_reds') 207 | cm.register_cmap('b16_reds',b16_colors.reds) 208 | 209 | #Make a "flame" colormap 210 | cols = [conv.to_rgb(theme_colors['base{:02X}'.format(i)]) for i in range(0,3,2)]+\ 211 | [b16_colors.y,b16_colors.o,b16_colors.r] 212 | b16_colors.flame = ListedColormap(make_gradient(cols),name='b16_flame') 213 | cm.register_cmap('b16_flame',b16_colors.flame) 214 | 215 | #Make a "brbg" colormap 216 | cols = [b16_colors.n,b16_colors.w,b16_colors.b,b16_colors.g] 217 | b16_colors.brbg = ListedColormap(make_gradient(cols),name='b16_brbg') 218 | cm.register_cmap('b16_brbg',b16_colors.brbg) 219 | 220 | self.shell.push({"b16_colors":b16_colors}) 221 | cfg.rc.update({'image.cmap':'b16_flame'}) 222 | 223 | pyplot.rcParams.update(cfg.rc) 224 | 225 | def load_ipython_extension(ipython): 226 | ipython.register_magics(MPLRCMagics) 227 | -------------------------------------------------------------------------------- /eighties_dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benjaminaschultz/base16-ipython-matplotlibrc/f7418fc925c82f0ae3149a5b45c4d331a1ff8276/eighties_dark.png -------------------------------------------------------------------------------- /eighties_dark_cmaps.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benjaminaschultz/base16-ipython-matplotlibrc/f7418fc925c82f0ae3149a5b45c4d331a1ff8276/eighties_dark_cmaps.png -------------------------------------------------------------------------------- /sddl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benjaminaschultz/base16-ipython-matplotlibrc/f7418fc925c82f0ae3149a5b45c4d331a1ff8276/sddl.png -------------------------------------------------------------------------------- /solarized_dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benjaminaschultz/base16-ipython-matplotlibrc/f7418fc925c82f0ae3149a5b45c4d331a1ff8276/solarized_dark.png -------------------------------------------------------------------------------- /solarized_dark_cmaps.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/benjaminaschultz/base16-ipython-matplotlibrc/f7418fc925c82f0ae3149a5b45c4d331a1ff8276/solarized_dark_cmaps.png --------------------------------------------------------------------------------