Ryan MacDicken
Ryan MacDicken

Reputation: 53

Matplotlib data points, lines, fonts get bigger when using a Command (CMD) terminal

I created a GUI using PyQT Designer and inserted matplotlib figures. I developed the program in Anaconda / Spyder, and sized the graphs the way I wanted.

However, when run from a windows Command Prompt, or Anaconda Prompt (Anaconda 3), or Anaconda Powershell Prompt (Anaconda 3), using the command "python snappy.py", all the features in matplotlib get bigger....the data points are bigger, the lines including the axes are thicker, all the fonts are bigger. This makes the data more difficult to see, and wreaks havoc with the layout (labels get pushed off the canvas). Spyder and Anaconda prompt are run on the same computer, using the same installation of Anaconda.

matplotlib Comparison

What causes the difference, and can I control what "size" or "resolution" my matplotlib figures are.

Upvotes: 1

Views: 49

Answers (1)

Ryan MacDicken
Ryan MacDicken

Reputation: 53

I "figured" this out (pardon the pun). I added this to the top of my code.

plt.rcParams['figure.dpi'] = 60

The default resolution is normally 100. When I hard-coded it to 100 in my script, it replicated the "fat" lines and "large" fonts that I was seeing when running from the command prompt. When I lowered this value in my code to about 70 it matched what I had previously seen in Spyder.

So the default resolution of matplotlib running in my Spyder installation is different somehow.

Upvotes: 1

Related Questions