Comments (15)
It shouldn't be a problem, but it is :)
The way that the high-dpi displays are handled is by adding a layer of 'virtual pixels' that unless you opt-out just 'zooms' your bitmaps by 2x. What looks like is happening here is that the js side is correctly opting out, but it is not being threaded through to matplotlib to render the image and double the 'virtual' dpi until after the cell is finished executing.
Until we sort this out splitting everything after plt.show()
into a second cell may help.
from ipympl.
Any updates on this front?
from ipympl.
This bug is now 3 years old and I still have this issue. Are there any plans how this can be fixed?
from ipympl.
Do you have high-dpi display?
from ipympl.
I do, is that the problem?
from ipympl.
thanks for the comment @tacaswell. What do you mean exactly by "splitting evething (...) into a second cell"?
from ipympl.
I mean put it in a second cell so the first cell creates and show the figure, the second updates it.
from ipympl.
I am also running into this issue -- exactly the same plotting mechanism and symptoms (on the latest Anaconda). It would be nice if it wasn't necessary to split the plots in this way when using Retina displays (which is basically all macs nowadays).
from ipympl.
@wjakob The parameter that controls this is https://github.com/matplotlib/jupyter-matplotlib/blob/master/ipympl/backend_nbagg.py#L141 .
I suspect what is happening is:
- you call show which creates the figure
- the js side sends a message back to adjust the DPI
- but the event loop is blocked running your code which loops through and and updates the plot
- after you loop is done the tornado event loop processes the message to update the DPI ratio which triggers a re-draw which shows you the full size figure.
One (very hackish) solution is to do fig.canvas._dpi_ratio = 2
and just hard-code you are in a hi-dpi enviroment. The more proper solution is to find a way to let the underlying event loop spin, but I do not know how to do that...
from ipympl.
any solution to this problem? fig.canvas._dpi_ratio = 2
doesn't change anything to me
from ipympl.
@tiehfood I think someone needs to look into the communications between the js front end and the python side to sort out when the dpi is negotiated, would you be interested in trying?
The revelant code is likely in https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/backends/backend_webagg_core.py and https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/backends/backend_nbagg.py
from ipympl.
I am no code expert and I have just access to the jupyter front end in this case...
from ipympl.
I tried to find the reason for this issue. I added print statements to the messages handling Python side, and it appears that all the messages (i.e. initialized
message, set_dpi_ratio
message, resize
message) are received/handled only at the end of the animation... I don't know what is the reason for that. Maybe you have an idea @tacaswell ?
from ipympl.
As we are not using the tornado application with ipympl, I suspect the way to fix it would be to get rid of it on the backend
from ipympl.
Hi Guys,
I was facing the same issue, I was creating different plots into the same cell using a loop, the way I fixed it was putting the fig = plt.figure(figsize=(20, 10)) inside the loop. Now all the plots has the same size into the execution of the same cell. I had it out of the loop before.
Check the example below:
from ipympl.
Related Issues (20)
- Question: should I use `%matplotlib widget` or `%matplotlib ipympl` HOT 4
- DepreciationWarning in toolbar causes AttributeError
- ipympl crashes when panning/zooming
- JupyterLab 4.x support HOT 4
- [FR] Cursor Control HOT 1
- Latest version of everything still causes the dreaded Error displaying widget: model not found HOT 11
- An error in use of inset_axes of mpl_toolkits in Jupyter Notebook HOT 2
- [email protected]
- Comptability with mpl cursors
- Failed to load model class 'MPLCanvasModel' from module 'jupyter-matplotlib' Error: No version of module jupyter-matplotlib is registered. HOT 6
- Please remove jupyterlab==3.* requirement so as to allow 4.x to work. HOT 3
- Ability to configure defaults for `Canvas`
- Interactive graph - Saving
- Error: No version of module jupyter-matplotlib is registered HOT 5
- [test-bot] Scheduled Tests are failing
- Matplotlib Fails to Update Axis Limits with ipywidgets in Jupyter Lab HOT 1
- Question: how to use ipympl to simply include axes in ipywidets layout? HOT 1
- Large top/bottom padding for imshow images HOT 5
- Blank figures in Jupyter notebook HOT 13
- Cannot install with pip HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ipympl.