python怎么在一张图上画多条折线_pandas 在同一个图中画多条折线图

import pandas as pd

import xlwt

import os

import matplotlib.pyplot as plt

import numpy as np

workbook = xlwt.Workbook()

#name_list = ['V_YDJT_MHXT_DB_01_USED .xls', 'V_YDJT_HRXT_DB_01_USED.xls', 'V_YDJT_DS_DB_01_USED.xls']

name_list = ['V_YDJT_MHXT_DB_01_USED']

files = os.listdir(r'.')

for txt_file in files:

for name in name_list:

if name in txt_file:

# print(txt_file)

df = pd.DataFrame(pd.read_excel(txt_file))

istackList = df[['istack']].values.T.tolist()[:][0]

computeList = df[['compute01']].values.T.tolist()[:][0]

ipList = df[['ip']].values.T.tolist()[:][0]

instanceList = df[['instance-name']].values.T.tolist()[:][0]

# print (instanceList [0] )

# print("all istack")

# print(istackList)

istackList = list(set(istackList))

# print("NO repetition")

# print(istackList)

for name in istackList:

istack = df.loc[df['istack'] == name]

# print('\r\n')

# print(istack)

# data

a = istack["cpu_used"].describe()

print(a)

dfc = pd.DataFrame(istack ['cpu_used'],index= istack ['date'])

#dfc.plot(kind='line', rot=0)

dfm = pd.DataFrame(istack['mem_used'], index=istack['date'])

#dfm.plot(kind='line', rot=0)

dfd = pd.DataFrame(istack['disk_used'], index=istack['date'])

#dfd.plot(kind='line', rot=0)

ax = dfc.plot()

dx=dfm.plot( legend='w1', title=name, ax=ax)

dfd.plot(legend='w1', title=name, ax=dx)

plt.show()

# # plot

# data = istack.ix[0:, 4:7]

# #print(data)

# comp1=istack["cpu_used"]

# comp2=istack["mem_used"]

# comp3=istack["disk_used"]

# values = pd.Series(np.concatenate([comp1, comp2,comp3]))

# print (values)

# import matplotlib.pyplot as plt

#

# values.hist( color='k', normed=True)

# values.plot(kind='kde', style='k--')

#

# plt.show()

# cmean = '%.2f' % (istack["cpu_used"].mean())

# cmin = '%.2f' % (istack["cpu_used"].min())

# cmax = '%.2f' % (istack["cpu_used"].max())

#

# mmean = '%.1f' % (istack["mem_used"].mean())

# mmin = '%.1f' % (istack["mem_used"].min())

# mmax = '%.1f' % (istack["mem_used"].max())

#

# dmean = '%.1f' % (istack["disk_used"].mean())

# dmin = '%.1f' % (istack["disk_used"].min())

# dmax = '%.1f' % (istack["disk_used"].max())

# # print(type(dmin)) str

#

# # print("istack %s cmean %s cmin "

# # "%s cmax %s mmean %s mmin %s mmax %s dmean %s dmin %s dmax %s "

# # ""%(istackList[i],cmean,cmin,cmax,mmean,mmin,mmax,dmean,dmin,dmax))

# advisec = "0"

# advisem = "0"

# advised = "0"

# if float(cmin) < 10:

# advisec = "Reduce cpu"

# # print (advisec)

# elif float(cmax) >= 50:

# advisec = "Expand cpu"

# # print (advisec)

# else:

# advisec = "No change cpu"

# # print (advisec)

#

# if float(mmin) < 10:

# advisem = "Reduce mem"

# # print (advisem)

# elif float(mmax) >= 50:

# advisem = "Expand mem"

# # print (advisem)

# else:

# advisem = "No change mem"

# # print (advisem)

# # disk

# if float(dmax) > 50.0:

#

# advised = "Expand disk"

# # print (advised)

# else:

# advised = "No change disk"

# # print (advised)

#

# adv = "%s %s %s %s %s " \

# " %s %s %s %s %s %s %s %s %s %s %s" \

# % (

# istackList[0], computeList[0], ipList[0], instanceList[0], cmax, cmin, cmean, mmax, mmin,

# mmean,

# dmax, dmin, dmean, advisec, advisem, advised)

# print(adv)

# # writer

# st = str(name)

# sheet = workbook.add_sheet(st, cell_overwrite_ok=False)

# sheet.write(0, 0, adv) # row, column, value

# workbook.save(str(name) + "advise.xls")

你可能感兴趣的:(python怎么在一张图上画多条折线_pandas 在同一个图中画多条折线图)