You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
qt5agg image quality changes when window is out of focus #13012
At this stage, calling plt.draw() fixes it till the window goes out of focus. Zooming in on the figure also returns it to the earlier quality. Note that transparency is lost.
Does this happen with any other backend? I wonder if this might be
something Ubuntu's window manager might be doing. You wouldn't happen to be
using something custom like Mint or Cinnamon? Which desktop manager are you
using?
On Mon, Dec 17, 2018 at 5:02 PM Deepak Cherian ***@***.***> wrote:
Bug report
*Bug summary*
Quality of qt rendered figures is drastically reduced when window is moved
out of focus and then back in focus.
*Code for reproduction*
import matplotlib.pypot as plt
plt.plot([1, 2, 3, 4], [5, 5.5, 6.5, 8.5], alpha=0.5)
*Actual outcome*
[image: mpl-before]
<https://user-images.githubusercontent.com/2448579/50118171-c4b71100-0203-11e9-9bbf-1cc763aa1525.png>
Switch to different window and back:
[image: mpl-after]
<https://user-images.githubusercontent.com/2448579/50118177-c7b20180-0203-11e9-9e72-f26dbbfed192.png>
At this stage, calling plt.draw() fixes it till the window goes out of
focus. Zooming in on the figure also returns it to the earlier quality.
Note that transparency is lost.
*Expected outcome*
Rendering doesn't change.
*Matplotlib version*
- Operating system: Ubuntu 16.04
- Matplotlib version: 3.0.2
- Matplotlib backend (print(matplotlib.get_backend())): Qt5Agg
- Python version: 3.6.7
- Jupyter version (if applicable): console 6.0.0
- Other libraries: pyqt 5.6.0 py36h8210e8a_7 conda-forge
everything installed from conda-forge using conda.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#13012>, or mute the
thread
<https://github.com/notifications/unsubscribe-auth/AARy-AIeOjNuRgj2ww9jke3Nh45WBVwsks5u6BRtgaJpZM4ZXNbe>
.
Yes, that is likely the critical detail! If you repeatedly focus / defocus does it get worse?
I think what is going on is that for GUI backends we use Agg to render and RGBA buffer and then use the GUI frameworks drawImage or equivalent to paint the figure onto your screen (see https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/backends/backend_qt5agg.py#L23) for details. If you set the Figure and Axes color to None the alpha on most of the rendered figure is 0. Unfortunately, we only clear the Qt painter right after triggering a draw (
). On a repaint where we did re-draw we just re-use the same buffer and draw to the screen. If you have an opaque background, this is OK as when Qt does the compositing the opaque layer is the only thing that survives, however all of your pixels have non-zero alpha so we are repeatedly compositing it with its self.
If you delete the 3 lines above does the problem go away?
Activity
WeatherGod commentedon Dec 17, 2018
dcherian commentedon Dec 17, 2018
I'm using Xfce and the Tk backend works fine.
tacaswell commentedon Dec 18, 2018
Do you have other transparency than the alpha on the line?
dcherian commentedon Dec 18, 2018
No, but
axes.facecolor=Noneandfigure.facecolor=None. Does that count?tacaswell commentedon Dec 18, 2018
Yes, that is likely the critical detail! If you repeatedly focus / defocus does it get worse?
I think what is going on is that for GUI backends we use Agg to render and RGBA buffer and then use the GUI frameworks
drawImageor equivalent to paint the figure onto your screen (see https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/backends/backend_qt5agg.py#L23) for details. If you set the Figure and Axes color toNonethe alpha on most of the rendered figure is 0. Unfortunately, we only clear the Qt painter right after triggering a draw (matplotlib/lib/matplotlib/backends/backend_qt5agg.py
Lines 41 to 43 in 529410f
If you delete the 3 lines above does the problem go away?
dcherian commentedon Dec 18, 2018
Yes!
When I remove those three lines my figure background is black.
tacaswell commentedon Dec 18, 2018
How about leaving just
painter.eraseRect(self.rect())?dcherian commentedon Dec 19, 2018
Yup, commenting out this line fixes things:
matplotlib/lib/matplotlib/backends/backend_qt5agg.py
Line 43 in 529410f
FIX: always eraseRect in Qt widget
FIX: always eraseRect in Qt widget
FIX: always eraseRect in Qt widget (#13050)