Skip to content
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

enable 2x (retina) display #3381

Merged
merged 4 commits into from Jun 28, 2013
Merged

enable 2x (retina) display #3381

merged 4 commits into from Jun 28, 2013

Conversation

minrk
Copy link
Member

@minrk minrk commented May 29, 2013

works for matplotlib figures with:

InlineBackend.figure_format = 'retina'

and (embedded) Image objects with:

Image(data,...retina=True)

ref #2234

@Carreau
Copy link
Member

Carreau commented Jun 1, 2013

Could the 2x factor be modifiable ? We're starting to see higher resolution that have bastard format that are not 2x (Chromebook pixel IIRC) .
I'm convince that their are only few users, but having a Bool would change the api in the future if we want multiple option.
If you think that unnecessary for now, that also fine with me.

@minrk
Copy link
Member Author

minrk commented Jun 1, 2013

could introduce an arbitrary scale factor, I guess.

@Carreau
Copy link
Member

Carreau commented Jun 2, 2013

could introduce an arbitrary scale factor, I guess.

Up to you, You probably have more devices with variable resolutions around you than I do.

@ellisonbg
Copy link
Member

I don't think we need to do the arbitrary scale factor yet. I don't have a retina screen to test, but the code looks good.

ivanov added a commit that referenced this pull request Jun 28, 2013
enable 2x (retina) display
@ivanov ivanov merged commit d820363 into ipython:master Jun 28, 2013
@ivanov
Copy link
Member

ivanov commented Jun 28, 2013

we figured that we can add the arbitrary factor later, so decided to merge as is.

@minrk minrk deleted the retina branch June 28, 2013 23:11
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014
@chuckdries
Copy link

The command %config InlineBackend.figure_format = 'retina' appears to work well in Jupiter Notebooks but not in qtconsole. Any ideas why?

@ccordoba12
Copy link
Member

@chuckdries, that's becauser qtconsole is not using Qt5, I think. According to Qt release notes, the first version that truly solves retina display problems is Qt 5.6 (released a couple of weeks ago :-)

@takluyver
Copy link
Member

Qtconsole can run on PyQt5, I believe. I suspect there's something the qtconsole code needs to do to display the image at double-resolution, though.

@ccordoba12
Copy link
Member

Yes, Qtconsole can run on PyQt5, but Anaconda (at least) is not using it. But I thought just setting retina for InlineBackend.figure_format was enough to have 2x images.

@minrk, is that not the case?

@minrk
Copy link
Member Author

minrk commented Apr 15, 2016

That's enough for the spec, but I'm not sure if the qtconsole handles it.

@wjakob
Copy link

wjakob commented Aug 19, 2016

Specifying

InlineBackend.figure_format = 'retina'

at the beginning of every notebook indeed does the job of providing images at the right resolution, but it's unfortunate that this is always necessary as High-DPI displays are fairly common nowadays.

It is possible to get a cross-platform pixel density value from the browser (javascript or CSS resolution query). To me, this seems like a much more robust and user-friendly way to do this automatically.

@dkasak
Copy link

dkasak commented Jun 24, 2017

Is there a reason this is not the default, at least for notebooks? The out-of-the-box experience for notebooks is pretty bad right now on a higher resolution screen, with both graphics and text very visibly blurry.

@Carreau
Copy link
Member

Carreau commented Jun 24, 2017

Is there a reason this is not the default, at least for notebooks? The out-of-the-box experience for notebooks is pretty bad right now on a higherG resolution screen, with both graphics and text very visibly blurry.

Yes: Because the kernel does not know it is controlled from a notebook. And even if it is controlled from a notebook it does not mean the notebook is on hi-DPI screen.

@dkasak
Copy link

dkasak commented Jun 24, 2017

Ah, the first part explains it. As was mentioned before, it would probably be possible to query the DPI value. Would it make more sense then to implement this in Jupyter by making it send this command when the python kernel is used?

@Carreau
Copy link
Member

Carreau commented Jun 24, 2017 via email

@dkasak
Copy link

dkasak commented Jun 24, 2017

You can't really do that either, as the frontend try to be as agnostic as possible WRT what language is implemented in the back end and sending that command would be an IPython specific thing. Also nothing guarantee that the kernel is connected to a single client ( which is even more true with RT collaboration comming soon) in which case "connected to Hi DPI" is not a binary choice.

That sounds reasonable and I realize the frontend is maximally agnostic of the backend by design. On the other hand, this particular situation is less than ideal and seems to point to a possible deficiency in the abstraction from a usability point of view. Perhaps there is a need for a way to specify some backend-specific configuration in Jupyter?

I'm also trying to consider what a higher-by-default figure resolution would imply for lower resolution screens. I'm not too familiar with the current architecture of Jupyter, but I suppose there isn't any scaling involved so the figure would simply appear larger than usual? I'm wondering whether this is perhaps a more graceful kind of failure than displaying blurry images. Then again, if there isn't any scaling involved, I'm not sure why I even saw blur as opposed to just a very small (but sharp) figure.

I guess a first reasonable step would be to at least make the syntax for this a bit less arcane and awkward, such as was suggested in #3982. %matplotlib inline retina or %matplotlib inline svg seem much cleaner than %config InlineBackend.figure_format = 'retina'

@ellisonbg
Copy link
Member

ellisonbg commented Jun 24, 2017 via email

@Carreau
Copy link
Member

Carreau commented Jun 24, 2017

I do probably agree that it is time to update the default on this. I agree
that kernels should be agnostic to frontends, but the current default is
biased towards particular frontends with low resolution rendering. I don't
know the numbers, but high resolution screens are extremely popular these
days. I have been embarrassed multiple times showing people matplotlib on
my laptop and having to explain to them why it looks bad. Defaulting to
something that looks good everywhere is a safe bet in my mind.

I am also +1 for making the API simpler to adjust. That way if folks have
large notebooks and need the lower resolution, it is easy to set it.

If/when we change, I would consider that close to breaking API so I would prefer to have it in a major version of IPython/IPykernel.

@ellisonbg
Copy link
Member

ellisonbg commented Jun 24, 2017 via email

@kencoken
Copy link

Running notebook server 5.4.0 and iPython 6.3.1, and using:

%matplotlib inline
import matplotlib
%config InlineBackend.figure_format = 'retina'
from matplotlib import pyplot as plt
plt.plot([1,2,3,4,5])

Seems to have no effect. I can set:

matplotlib.rcParams['figure.dpi'] = 144

When running matplotlib to get retina-resolution images, but these are then displayed double-size in my notebooks.

Has something changed recently to make this fix no longer function, or am I doing something stupid at my end?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants