0

I am using the following line of code in my python application.

df['Close'].plot()

The figure produced by this code is very small on my high resolution display (Microsoft Surface Studio). I have looked at the documentation for the pandas plot command and matplotlib but have not found any relevant settings. Any help appreciated.

  • change the figsize.... df['Close'].plot(figsize=(12,12)) – Scott Boston Jul 20 '17 at 19:47
  • Thanks. That and fontsize work for my purposes. However, the documentation seems to specify that figsize should be in inches which is definitely not happening. Wonder if the problems is in pandas, matplotlib, QT or Windows. Device Independent graphics are tricky. – Jose Oglesby Jul 20 '17 at 20:58

2 Answers2

3

I would guess that you want to leave the figure size constant but change the dpi (dots per inch).

Somewhere on top of your script or notebook add

import matplotlib.pyplot as plt
plt.rcParams["figure.dpi"] = 144

Change 144 to your liking. (Note that multiples of 72 usually give nice lines).

ImportanceOfBeingErnest
  • 321,279
  • 53
  • 665
  • 712
  • 1
    Thanks. This looks promising. Hopefully there is a query for the current natural device dpi instead of the hard coded value. I don't need it now but I can see wanting it in the future. – Jose Oglesby Jul 20 '17 at 22:11
  • I doubt that there is a device independent way of getting the pixel density of the monitor (like how would python know whether I have a 17 or 27 inch monitor connected?). – ImportanceOfBeingErnest Jul 20 '17 at 22:22
  • Surely there is some way to query something for the size of the monitor. E.g. https://askubuntu.com/questions/736113/how-can-i-get-my-laptops-monitor-size. Probably no easy platform independent way though. – Ben Farmer Feb 28 '18 at 11:44
0

The figsize parameter is what you're after.

df['Close'].plot(figsize=(20,10))

If you are in a Jupyter Notebook, there may be an issue where the notebook shrinks figures to fit in the cell output as .plot(figsize=x,y) increases the size. You will notice the text getting smaller but the plot seems to stay the same size, as you increase the figsize parameters.

memebrain
  • 403
  • 3
  • 9