How to show figures independent of screen resolution in python tkinter using matplotlib?

When I run this python code to plot on an Ultra HD screen, the icons and texts in the picture seem too small (if you can see it 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()

      

This is how it can be seen: enter image description here

I would like my application to be independent of screen resolution i.e. icons, texts, etc. displayed as an acceptable size (for example, equal screen percentage for all resolutions).

How could I do this? Thank.

+3


source to share


1 answer


The dpi resolution of the saved shape can be controlled using the dpi argument to savefig . Maybe it helps with lower 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)

      

Def argument:



dpi: [ None | scalar > 0 | β€˜figure’]

      

Resolution in dots per inch. If None, the default value for the savefig.dpi file will be set in the matplotlibrc file. If "digit" means the dpi value will be displayed as value.

0


source







All Articles