8000 Remove default '%matplotlib inline' line by ArturoAmorQ · Pull Request #1099 · sphinx-gallery/sphinx-gallery · GitHub
[go: up one dir, main page]

Skip to content

Remove default '%matplotlib inline' line #1099

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions doc/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -745,32 +745,27 @@ Add your own first and last notebook cell
Sphinx-Gallery allows you to add your own first and/or last cell to *every*
generated notebook. Adding a first cell can be useful for including code that
is required to run properly in the notebook, but not in a ``.py`` file. By
default, the following first cell is added to each notebook:

.. code-block:: ipython

%matplotlib inline
default, no first cell is added.

Adding a last cell can be useful for performing a desired action such as
reporting on the user's environment. By default no last cell is added.

You can choose whatever text you like by modifying the ``first_notebook_cell``
and ``last_notebook_cell`` configuration parameters. For example, the gallery
of this documentation adds the following first cell:
and ``last_notebook_cell`` configuration parameters. For example, you can add
the following first cell:

.. code-block:: ipython

# This cell is added by sphinx-gallery
# It can be customized to whatever you like
%matplotlib inline

Which is achieved by the following configuration::

sphinx_gallery_conf = {
...
'first_notebook_cell': ("# This cell is added by sphinx-gallery\n"
"# It can be customized to whatever you like\n"
"%matplotlib inline")
)
}

A last cell may be added similarly by setting the ``last_notebook_cell``
Expand All @@ -780,7 +775,7 @@ parameter::
...
'first_notebook_cell': ("# This cell is added by sphinx-gallery\n"
"# It can be customized to whatever you like\n"
"%matplotlib inline"),
),
'last_notebook_cell': "# This is the last cell",
}

Expand Down
2 changes: 1 addition & 1 deletion sphinx_gallery/gen_gallery.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def __call__(self, gallery_conf, script_vars):
'compress_images': (),
'reset_modules': ('matplotlib', 'seaborn'),
'reset_modules_order': 'before',
'first_notebook_cell': '%matplotlib inline',
'first_notebook_cell': None,
'last_notebook_cell': None,
'notebook_images': False,
'pypandoc': False,
Expand Down
1 change: 0 additions & 1 deletion sphinx_gallery/tests/test_notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,6 @@ def test_jupyter_notebook(gallery_conf):
assert json.load(fname) == example_nb
finally:
os.remove(f.name)
assert example_nb.get('cells')[0]['source'][0] == "%matplotlib inline"

# Test custom first cell text
test_text = '# testing\n%matplotlib notebook'
Expand Down
0