简体   繁体   中英

How can I show figures independent of screen resolution in python tkinter with matplotlib?

When I run this code of python to plot on a Ultra HD screen, the icons and texts on figure seem too small (if you can see at all).

import matplotlib.pyplot as plt
import numpy as np
import scipy.signal
t = np.linspace(0, 1, 500, endpoint=False)
plt.plot(t, scipy.signal.square(2 * np.pi * 5 * t))
plt.ylim(-2, 2)
plt.show()

Here is how it is seen: 在此输入图像描述

I would like my app independent of screen resolution, ie, the icons, texts, etc. are shown as some acceptable size (equal percentage of screen on all resolutions, for example).

How could I do that? Thank you.

The resolution in dots per inch of a saved figure can be be controlled with the the dpi argument to savefig . Maybe it helps with less resolution monitors

savefig(fname, dpi=None, facecolor='w', edgecolor='w',
        orientation='portrait', papertype=None, format=None,
        transparent=False, bbox_inches=None, pad_inches=0.1,
        frameon=None)

The argument def:

dpi: [ None | scalar > 0 | ‘figure’]

The resolution in dots per inch. If None it will default to the value savefig.dpi in the matplotlibrc file. If 'figure' it will set the dpi to be the value of the figure.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM