InlineBackend settings that affect the notebook but not qtconsole?

44 views
Skip to first unread message

Matthias Geier

unread,
Nov 18, 2018, 2:42:52 PM11/18/18
to jup...@googlegroups.com
Dear list.

I would like to specify some default settings for InlineBackend on my system.

It works fine when I put the settings in the file

~/.ipython/profile_default/ipython_kernel_config.py

However, I would like the settings only to apply to (kernels started
by) the Notebook app (and eventually JupyterLab), but not to
qtconsole.

I've read somewhere about a file named ipython_notebook_config.py, but
when I use such a file in the profile directory, it doesn't seem to
have an effect.

I've also tried ~/.jupyter/jupyter_notebook_config.py, but it didn't
seem to work, either.

The reason for the separate setting is that the default "figure.dpi"
of 72 is only correct for qtconsole, but the notebook needs a value of
96.

cheers,
Matthias

MinRK

unread,
Dec 5, 2018, 6:09:41 AM12/5/18
to Project Jupyter
The kernel is never told that it has been started by a notebook (indeed, a kernel can have a console and notebook connected to it at the same time), so there isn't any information that can be reliably interrogated to determine that the kernel is attached to a notebook (or may be in the future).

-Min

--
You received this message because you are subscribed to the Google Groups "Project Jupyter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jupyter+u...@googlegroups.com.
To post to this group, send email to jup...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/CAFesC-esZ38apF86i9xiKb_MM9xDbvNSaJvmo%3DAjknpUOu5xbA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Matthias Geier

unread,
Dec 6, 2018, 6:38:06 AM12/6/18
to jup...@googlegroups.com
On Wed, Dec 5, 2018 at 12:09 PM MinRK <benja...@gmail.com> wrote:
>
> The kernel is never told that it has been started by a notebook (indeed, a kernel can have a console and notebook connected to it at the same time),

I'm aware that a kernel can have multiple Jupyter clients connected at
the same time, but I was still hoping that some specific configuration
can be provided when starting the kernel (because there will only ever
be one entity that starts a kernel, right?).

> so there isn't any information that can be reliably interrogated to determine that the kernel is attached to a notebook (or may be in the future).

Sure, that's fine, but is it possible to provide a given piece of
configuration depending on who (Qt Console or Notebook/JupyterLab)
starts the kernel?

As I mentioned in my previous email, I'm talking about the "figure.dpi" setting.

The Notebook needs a setting like this to display PNG plots in the
right size (i.e. the same size that a SVG plot would have in the
browser or a PDF plot would have in LaTeX/PDF):

c.InlineBackend.rc = {'figure.dpi': 96}

The Qt Console, however, needs this (which is the default setting when
using ipykernel):

c.InlineBackend.rc = {'figure.dpi': 72}

I've created a notebook with a few more details:
http://nbviewer.jupyter.org/github/mgeier/python-audio/blob/master/plotting/matplotlib-inline-defaults.ipynb

The problem is that one setting will only be correct for either the Qt
Console or for the Notebook, never for both. So I thought it would be
at least helpful to use the right settings for Notebook in those cases
where the kernel was started by the Notebook app (or JupyterLab).

I've somewhere read about a file named
~/.jupyter/jupyter_notebook_config.py, which sounds like it would be
the right place to put such a configuration, but the
"c.InlineBackend.rc" setting didn't have any effect when I tried it
there.

I've also mentioned the problem there:
https://github.com/ipython/ipykernel/issues/267#issuecomment-441069321

cheers,
Matthias
> To view this discussion on the web visit https://groups.google.com/d/msgid/jupyter/CAHNn8BWBF%3DpfrUBzKs55YYobb3De%2BSqFxNz%2B0jq1pLfG8oeQ2A%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages