-1

I have written a code that looks something like this:

import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

T = np.array([10.03,100.348,1023.385])
power = np.array([44000,63000,89000])

df= pd.DataFrame(data = {'Size': T, 'Time': power})
    

fig_1= sns.lmplot(x='Size', y='Time', data=df, ci=None, lowess=True, truncate=False)
fig_2= sns.lmplot(x='Size', y='Time', data=df, ci=None, order=4, truncate=False)

plt.savefig_1('exp1.png')
plt.savefig_2('exp2.png')
plt.show()

But I am facing this error:

AttributeError                            Traceback (most recent call last)
<ipython-input-6-3d9485d7c609> in <module>
     13 fig_2= sns.lmplot(x='Size', y='Time', data=df, ci=None, order=4, truncate=False)
     14 
---> 15 plt.savefig_1('exp1.png')
     16 plt.savefig_2('exp2.png')
     17 plt.show()

AttributeError: module 'matplotlib.pyplot' has no attribute 'savefig_1'

What I wanted is to do make a graph of T vs Power, but since it's not a smooth graph, so I made fig_2, which is the smooth version of fig_1. But while saving both of the graphs, only one (fig_2) gets saved, and I got error at fig_1. Why is this? Can anybody help me with this?

1 Answers1

1

The way to save images is savefig(). You can do this for multiple plots. It works for me.

fig_1.savefig('exp1.png')
fig_2.savefig('exp2.png')
vnk
  • 1,060
  • 1
  • 6
  • 18