Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pandas: plot Series on a new figure by default

Is there a way to force the .plot method of a pandas Series to generate a new figure, instead of trying to plot on the currently open figure?

I currently create a new figure using plt.figure() or using plt.subplots and passing the axis, but for quick plots from the interactive console it would be great to simply use the .plot method without extra lines of code.

I wonder if there are configs in pandas that can be changed to achieve this.

like image 344
FLab Avatar asked Nov 17 '22 02:11

FLab


1 Answers

I'm not aware of a config. Defining a wrapper around .plot() should do the trick, as suggested by Stop harming Monica.

def plot(s, **kwargs):
    s.plot(**kwargs)
    plt.show();
like image 77
fishmulch Avatar answered Dec 10 '22 14:12

fishmulch