Show More
@@ -175,15 +175,6 b' Raw cells' | |||
|
175 | 175 | Raw cells provide a place to put additional information which is not evaluated by the Notebook. This can be used, for example, for extra information to be used when the notebook is exported to a certain format. |
|
176 | 176 | |
|
177 | 177 | |
|
178 | Plotting | |
|
179 | -------- | |
|
180 | One major feature of the Notebook is the ability to capture the result of plots as inline output. | |
|
181 | `%matplotlib` and `%pylab` magics | |
|
182 | ||
|
183 | Inline versus non inline | |
|
184 | ||
|
185 | %config | |
|
186 | ||
|
187 | 178 | |
|
188 | 179 | Magic commands |
|
189 | 180 | -------------- |
@@ -193,10 +184,38 b' Magics control different elements of the way that the IPython notebook operates.' | |||
|
193 | 184 | |
|
194 | 185 | Some of the main magics are the following: |
|
195 | 186 | |
|
196 | ``%lsmagic`` | |
|
187 | * ``%lsmagic`` | |
|
197 | 188 | Lists all the magic commands available |
|
198 | 189 | |
|
199 | See CROSS-REF for a complete list of magics | |
|
190 | * ``%config`` | |
|
191 | Configuration of IPython | |
|
192 | ||
|
193 | ||
|
194 | Plotting | |
|
195 | -------- | |
|
196 | One major feature of the Notebook is the ability to capture the result of plots as inline output. IPython is designed to work seamlessly together with | |
|
197 | the ``%matplotlib`` plotting library. In order to set this up, the | |
|
198 | ``%matplotlib`` magic command must be run before any plotting takes place. | |
|
199 | ||
|
200 | Note that ``%matplotlib`` only sets up IPython to work correctly with ``matplotlib``; it does not actually execute any ``import`` commands and does not add anything to the namespace. | |
|
201 | ||
|
202 | There is an alternative magic, ``%pylab``, which, in addition, also executes a sequence of standard ``import`` statements required for working with the | |
|
203 | ``%matplotlib`` library. In particular, it automatically imports all names in the ``numpy`` and ``matplotlib`` packages to the namespace. A less invasive solution is ``%pylab --no-import-all``, which imports just the standard names | |
|
204 | ``np`` for the ``numpy`` module and ``plt`` for the ``matplotlib.pyplot`` module. | |
|
205 | ||
|
206 | When the default ``%matplotlib`` or ``%pylab`` magics are used, the output of a plotting command is captured in a *separate* window. An alternative is to use:: | |
|
207 | ``%matplotlib inline`` | |
|
208 | which captures the output inline within the notebook format. This has the benefit that the resulting plots will be stored in the notebook document. | |
|
209 | ||
|
210 | ||
|
211 | ||
|
212 | ||
|
213 | `%matplotlib` and `%pylab` magics | |
|
214 | ||
|
215 | Inline versus non inline | |
|
216 | ||
|
217 | %config | |
|
218 | ||
|
200 | 219 | |
|
201 | 220 | |
|
202 | 221 | Exporting a notebook and importing existing scripts |
General Comments 0
You need to be logged in to leave comments.
Login now