Using Matplotlib with TKAgg or Qt5Agg backend on 4K screen

杀马特。学长 韩版系。学妹 提交于 2020-02-01 04:37:05

问题


I'm using Matplotlib 2.0 with Python 3.6 on Ubuntu 16.04 to create plots of data. The computer monitor is 4k resolution at 3840x2160. Plot figures appear really small with tiny font:

I have tried the TKAgg and Qt5Agg backends for Matplotlib but the figure window still appears small on my 4K display.

Can the backend be configured to scale the figure windows for better viewing on high resolution displays?


回答1:


You can tell matplotlib to create a high dpi figure using

plt.figure(dpi=300)

before creating your plot. You can save your plot in higher dpi using:

plt.savefig("figurename.png", dpi=300)



回答2:


One thing you will want to do is set your tk scaling factor properly. Add a tk scaling command to your .wishrc file. The tk scaling wiki page has a couple of tools that can be used to determine the proper scaling factor.

This might help, but most likely, whoever wrote TkAgg will also need to put in some work to make their application work better on high resolution displays (it is mostly possible). In general, too many programs are written around pixel sizes (where the real size changes depending on resolution) and not points or mm.

And your display might turn out worse, as the plot canvas will not scale and other widgets and font might scale properly.

As this is a canvas display, getting the scaling to work properly will be a lot of hard work.

You may have to find a fast way to switch your monitor resolution back and forth so that you can get your work done.

References: tk scaling , tk scaling (wiki)



来源:https://stackoverflow.com/questions/41370779/using-matplotlib-with-tkagg-or-qt5agg-backend-on-4k-screen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!