У меня есть следующая функция для построения графика:
def plot_ATD(DataFrame):
#Initialise 225V ATD plot
fig = plt.figure()
ax = fig.add_subplot(111)
#take columns from data set and make to list which is passed to matplotlib to plot a graph
x = DataFrame['Arrival Time (ms)'].tolist()
y = DataFrame['Intensity'].tolist()
line, = ax.plot(x,y, 'r-')
#use numpy to get the max of Intensity, then determine the corresponding arrival time
ymax = np.max(y)
xpos = y.index(ymax)
xmax = x[xpos]
time = xmax
#add an annotation point at the maxima giving the arrival time at this position
# ax.annotate(s=text of annotation, xy=point to annotate, xytext=position to place text
# arrowprops=dict(facecolor=color of arrow))
ax.annotate(s=xmax, xy=(xmax, ymax), xytext=(xmax+5, ymax+5),
arrowprops=dict(facecolor='orange'),
)
#ax.set_ylim(0,600000)
ax.set_xlim(0,20)
plt.xlabel('Arrival time (ms)')
plt.title(DataFrame.name)
return plt.show()
Я использую его на следующих пандах DataFrames:
V100 = pd.read_csv('Documents/spreadsheets/Data/100V_9z.csv', names=['Arrival Time (ms)', 'Intensity'])
V125 = pd.read_csv('Documents/spreadsheets/Data/125V_9z.csv', names=['Arrival Time (ms)', 'Intensity'])
V150 = pd.read_csv('Documents/spreadsheets/Data/150V_9z.csv', names=['Arrival Time (ms)', 'Intensity'])
V175 = pd.read_csv('Documents/spreadsheets/Data/175V_9z.csv', names=['Arrival Time (ms)', 'Intensity'])
V200 = pd.read_csv('Documents/spreadsheets/Data/200V_9z.csv', names=['Arrival Time (ms)', 'Intensity'])
V225 = pd.read_csv('Documents/spreadsheets/Data/225V_9z.csv', names=['Arrival Time (ms)', 'Intensity'])
Я хочу иметь название графикабыть именем DataFrame, т. е. V100, V125 и т. д.
Я не уверен в правильном синтаксисе или как это сделать?Пожалуйста, помогите!