kivy: Opening a matplotlib figure, causes kivy desktop app to shrink (size & font)
Software Versions
- Python: 3.8.5
- OS: win10
- Kivy: 2.0.0rc3
- Kivy installation method: pip
Describe the bug When I call any of the matplotlib plotting routines, as the matplotlib figure is displayed, the Kivy desktop application shrinks in size (window size and font)
Expected behavior The display of the matplotlib should not affect the size/font of the Kivy application.
To Reproduce Please find the code below.
Code and Logs and screenshots
import kivy
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
import matplotlib.pyplot as plt
kivy.lang.Builder.load_string('''
<DataView>:
orientation: 'vertical'
spacing: 5
padding: 5
Label:
text: 'HELLO WORLD'
''', filename='dataview.kv')
class DataView(BoxLayout):
def __init__(self, **kwargs):
super().__init__(**kwargs)
class TestApp(App):
def build(self):
DV = DataView()
# Commenting/uncommenting this line causes the kivy application
# font size / window size to change.
fig, ax = plt.subplots(2, 2)
return DV
if __name__ == '__main__':
TestApp().run()
Additional context
Kivy debugging dump:
[INFO ] [deps ] Successfully imported “kivy_deps.gstreamer” 0.2.0 [INFO ] [deps ] Successfully imported “kivy_deps.glew” 0.2.0 [INFO ] [deps ] Successfully imported “kivy_deps.sdl2” 0.2.0 [INFO ] [Kivy ] v2.0.0rc3, git-20c14b2, 20200615 [INFO ] [Kivy ] Installed at “C:\Users\abed\anaconda3\lib\site-packages\kivy_init_.py” [INFO ] [Python ] v3.8.5 | packaged by conda-forge | (default, Sep 16 2020, 17:19:16) [MSC v.1916 64 bit (AMD64)] [INFO ] [Python ] Interpreter at “C:\Users\abed\anaconda3\python.exe” [INFO ] [Factory ] 185 symbols loaded [INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_pil (img_ffpyplayer, img_gif ignored) [INFO ] [Window ] Provider: sdl2 [INFO ] [GL ] Using the “OpenGL” graphics system [INFO ] [GL ] GLEW initialization succeeded [INFO ] [GL ] Backend used <glew> [INFO ] [GL ] OpenGL version <b’4.6.0 - Build 26.20.100.7637’> [INFO ] [GL ] OpenGL vendor <b’Intel’> [INFO ] [GL ] OpenGL renderer <b’Intel® UHD Graphics 620’> [INFO ] [GL ] OpenGL parsed version: 4, 6 [INFO ] [GL ] Shading version <b’4.60 - Build 26.20.100.7637’> [INFO ] [GL ] Texture max size <16384> [INFO ] [GL ] Texture max units <32> [INFO ] [Window ] auto add sdl2 input provider [INFO ] [Window ] virtual keyboard not allowed, single mode, not docked [INFO ] [Text ] Provider: sdl2 [INFO ] [Base ] Start application main loop [INFO ] [GL ] NPOT texture support is available
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 20 (7 by maintainers)
Thanks, @matham. I tried some more, I will try to summarize so hopefully this could be of help to someone. First, it seems that the default matplotlib backend on windows and (Linux ubuntu 20.10) anaconda installation is Qt5Agg.
The application starts (but at a smaller size than step 1), however, the app doesn’t shrink when I use matplotlib to plot a graph. I will look if there is a way to ask kivy to start at a given dpi.
Thank you. I will close this issue, I appreciate your help @matham , @tshirtman , @probablyfine
Thank you again,
I added the following, and the problem solved - thank you!
So it seems that the issue is specific to the Qt5Agg backend.
I truly appreciate your help - this has been bugging me for some time, and now I have the fix thanks to your pointers. @tshirtman , @matham , @probablyfine thank you and best wishes for the new year!