First I am going to try ob-ipython
, to see if that works better than using the normal python integration
- It seems I already had installed it from MELPA
- [2016-09-18 Sun 18:54] updated to the latest version
We turn this on so that the inline figs get updated immediately
(add-hook 'org-babel-after-execute-hook 'org-display-inline-images 'append)
First we import the packages we want and set up the plotting style.
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns
sns.set(context='notebook',
style='darkgrid',
palette='bright',
font_scale=1.5,
color_codes=True)
Use SVG files instead of PNG for resolution independence.
%config InlineBackend.figure_format = 'svg'
Inspect the style parameters that we got from the darkgrid
canned option.
sns.axes_style()
{'axes.axisbelow': True, 'axes.edgecolor': 'white', 'axes.facecolor': '#EAEAF2', 'axes.grid': True, 'axes.labelcolor': '.15', 'axes.linewidth': 0.0, 'figure.facecolor': 'white', 'font.family': [u'sans-serif'], 'font.sans-serif': [u'Arial', u'Liberation Sans', u'Bitstream Vera Sans', u'sans-serif'], 'grid.color': 'white', 'grid.linestyle': u'-', 'image.cmap': u'Greys', 'legend.frameon': False, 'legend.numpoints': 1, 'legend.scatterpoints': 1, 'lines.solid_capstyle': u'round', 'text.color': '.15', 'xtick.color': '.15', 'xtick.direction': u'out', 'xtick.major.size': 0.0, 'xtick.minor.size': 0.0, 'ytick.color': '.15', 'ytick.direction': u'out', 'ytick.major.size': 0.0, 'ytick.minor.size': 0.0}
Change the plot colours to be more suitable to a dark background.
black_style ={
'axes.edgecolor': '#3f3f3f',
'axes.facecolor': '#504040',
'axes.labelcolor': '.85',
'figure.facecolor': '#3f3f3f',
'grid.color': 'gray',
'xtick.color': '.85',
'ytick.color': '.85',
}
sns.set_style(rc=black_style)
plt.hist(np.random.randn(20000), bins=50)
fig, ax = plt.subplots(1, 1)
fig.set_size_inches(5, 3)
x = np.linspace(-20.0, 20.0, 100)
ax.plot(x, np.sin(x)/x)
So we can make a plot of \[ y = \frac{sin x}{x} \] if we want to. And we can change the size of the figure.
We should also look at this
- Note that we run
org-export
on the top-level section, so go to the top and typeC-c C-e C-s h o
- This is the only way of getting the export file name to be different from the org source file name
- We want it to export to
docs/index.html
so that it is served as a web page ongithub.io
- In order that the inline figures work in both the org file and in the exported web page, we use the following hack:
- Configuration of MathJax for equation display
- Use the
https
protocol - Try the Asana-Math font
- Use the
- The general export options are given below (invisible in HTML export)
- Only change from default is to remove section numbering
- On the whole, it works pretty well
- The main problem with using the github.io address is that the CDN takes a very long time to propagate changes. Like, several hours.
- I set up a dns forward from jupiter-org-integration.henney.org
- Notice the typo in the name!
- That updated faster
- There were some issues with mathjax
- I have switched it to https to be on the safe side.
- it worked perfectly on my iPad, but to begin with not on my iPhone
- This turned out to be because of content blocker Purify
- Once I white listed my site, all was fine
- On my laptop, the change of font is not respected
- But this may well be something I have configured