5

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:

enter image description here

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?

wigging
  • 8,492
  • 12
  • 75
  • 117

2 Answers2

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)
Jens Timmerman
  • 9,316
  • 1
  • 42
  • 48
  • One addition: To have this work automatically, you can just add the `dpi` setting to your `rcParams`: `plt.rcParams["figure.dpi"] = 300`. But I think, in new mpl versions, the Qt5 backend automatically detects the pixel scaling – user8408080 Feb 12 '19 at 13:40
0

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)

Brad Lanam
  • 5,192
  • 2
  • 19
  • 29
  • Where is the `.wishrc` file located on Ubuntu? – wigging Dec 29 '16 at 18:18
  • You will need to create it in your $HOME directory. – Brad Lanam Dec 29 '16 at 19:58
  • I entered `tk scaling -displayof . 2` into the `.wishrc` file but it does nothing to the figure size. – wigging Dec 30 '16 at 19:58
  • To be expected. Plots canvases do not automatically scale. You will need to push this back to the TkAgg author and have him honor `tk scaling`. You really only have two choices at this point: Use a magnifier tool or change your monitor resolution. – Brad Lanam Dec 30 '16 at 20:20
  • Can I make Matplotlib use a different backend that supports 4K displays? – wigging Jan 17 '17 at 01:45