ipython-notebook

Inline math mode on iPython notebook

南楼画角 提交于 2019-12-06 02:03:33
问题 In iPython notebook, how can I write a mathematic formula such as r^2 in a line (inline math mode in latex vocabulary). ie. Is it possible to not go on a new line when the formula is printed. If like in LaTeX, it should be \(r^2\) but it doesn't work... Thanks for your help ! 回答1: In a markdown cell you can use $s, e.g. $r^2$. This requires MathJax from CDN or a local MathJax installation. If you have an internet connection it should work right out of the box. see e.g. Typesetting Equations

Jupyter notebook autocomplete showing duplicate options

允我心安 提交于 2019-12-06 01:41:26
Jupyter notebook's autocomplete seems working, but somehow it will show duplicate options for the method. For example below: For each possible options, drop down menu will show 2 identical choices. Why this happen and how to fix it? Relevant Github issue: https://github.com/ipython/ipython/pull/10969 This should be fixed in Ipython 6.3 release (track milestone completion here: https://github.com/ipython/ipython/milestone/48 ) 来源: https://stackoverflow.com/questions/48009983/jupyter-notebook-autocomplete-showing-duplicate-options

IPython: How to show the same plot in different cells?

自作多情 提交于 2019-12-06 01:35:36
问题 I'm still new to IPython Notebooks, Jupyter, and Python in general. I'm creating a scatter plot in a Jupyter notebook using the following code: import numpy as np import matplotlib.pyplot as plt n = 1024 X = np.random.normal(0, 1, n) Y = np.random.normal(0, 1, n) plt.axes([0.025, 0.025, 0.95, 0.95]) plt.scatter(X, Y, s=50) plt.show() My question is, how can I get a reference to the plot object so I can use it in a different cell later on in the notebook? Additionally, I may need to modify the

How do I separate slides when exporting an IPython notebook to reveal.js?

无人久伴 提交于 2019-12-06 00:06:24
问题 When I execute an IPython notebook to a reveal.js presentation using ipython nbconvert mynotebook.ipynb --to slides --post serve I am getting all the content as a single slide. How do I separate my content into several slides? I tried using --- (hinted in this video), \n\n\n and === inside the notebook (as separate cells and before my titles), but it didn't change anything. I know that for a Markdown input file in reveal.js one can set the data-separator option, but the generated html file

IPython notebook ~ Using javascript to run python code?

此生再无相见时 提交于 2019-12-05 23:56:00
I am trying to execute python code through javascript directly: I fire up IPython Notebook on Chrome Using chrome developer tools I open up the javascript console. In the javascript consolde, I type: IPython.notebook.kernel.execute("2+2") But I get a strange output: "6CEA73CC644648DDA978FDD6A913E519" Is there any way to take advantage of all the IPython javascript functions available, to run python code from the javascript console as depicted in the image? I'm sure there's a way but I've been beating at it for way too long and thought I would post here. (I need this to build an app on top of

IPython notebook interactive function: how to save the updated function parameters

非 Y 不嫁゛ 提交于 2019-12-05 23:04:57
I wrote the code below in Ipython notebook to generate a sigmoid function controlled by parameters a which defines the position of the sigmoid center, and b which defines its width: %matplotlib inline import numpy as np import matplotlib.pyplot as plt def sigmoid(x,a,b): #sigmoid function with parameters a = center; b = width s= 1/(1+np.exp(-(x-a)/b)) return 100.0*(s-min(s))/(max(s)-min(s)) # normalize sigmoid to 0-100 x = np.linspace(0,10,256) sigm = sigmoid(x, a=5, b=1) fig = plt.figure(figsize=(24,6)) ax1 = fig.add_subplot(2, 1, 1) ax1.set_xticks([]) ax1.set_xticks([]) plt.plot(x,sigm,lw=2

bracket matching in ipython

放肆的年华 提交于 2019-12-05 20:47:05
Is there an option to automatically close brackets,quotes, parentheses etc in IPython? I hoped there was a feature similar to that in the gedit plugin. Pierz It is possible to get apps (including IPython) that use readline to automatically add a closing parenthesis when an open parenthesis is typed by tweaking your ~/.inputrc, as suggested here , e.g. by adding: "(": "\C-v()\e[D" Note that according to the creator of IPython automatic bracket matching can't be done in a plain readline-based application (i.e in a normal IPython terminal session). Though it's already part of the standard

Different font settings for editing code and markdown cells in the Jupyter Notebook

让人想犯罪 __ 提交于 2019-12-05 20:18:41
In the Jupyter notebook, I would like to use the regular Ubuntu font when editing markdown cells and UbuntuMono for code cells. I can change the fonts of both these cell types simultaneously by editing .jupyter/custom/custom.css like so: .CodeMirror pre { font-family: "Ubuntu Mono", monospace; font-size: 14pt; } I can also change the formatting of the headers in the markdown code cells: .cm-header { font-size: 110%; font-family: "Ubuntu"; } As well as how the text looks when rendered (after executing a markdown cell): div.text_cell_render { font-family: "Ubuntu"; font-size: 12pt; } However, I

Ipython Notebook: Default Initialization Python Code

China☆狼群 提交于 2019-12-05 18:25:27
I use iPython Notebook for scientific applications and I'm always plotting experimental data sets. The default image rendering and color cycling behavior of the combination of iPython Notebook and Matplotlib is pretty bad, but it's great after the following tweaks. # ipython notebook specific %pylab inline # imports from matplotlib import pyplot as plt import matplotlib as mpl from seaborn.apionly import set_palette from IPython.display import set_matplotlib_formats # configure plotting set_matplotlib_formats('pdf', 'svg') set_palette('Set1', n_colors=15, desat=None) mpl.rcParams['figure

How to enable timing magics for every cell in Jupyter notebook?

冷暖自知 提交于 2019-12-05 17:45:15
The %%time and %%timeit magics enable timing of a single cell in a Jupyter or iPython notebook. Is there similar functionality to turn timing on and off for every cell in a Jupyter notebook? This question is related but does not have an answer to the more general question posed of enabling a given magic automatically in every cell. A hacky way to do this is via a custom.js file (usually placed in ~/.jupyter/custom/custom.js ) The example of how to create buttons for the toolbar is located here and it's what I based this answer off of. It merely adds the string form of the magics you want to