精华内容
下载资源
问答
  • 如何在一个图中做多个折线图
    千次阅读
    2020-11-23 19:41:24

    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")

    更多相关内容
  • 这篇文章利用的是matplotlib.pyplot.plot的工具来绘制折线图,这里先给出一个段代码和结果图: # -*- coding: UTF-8 -*- import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt #这里导入...
  • K线图,趋势图,折线图,柱状图等多个demo,日K线是根据股价(指数)天的走势形成的四个价位即:开盘价,收盘价,最高价,最低价绘制而成的。
  • 主要为大家详细介绍了python使用matplotlib模块绘制折线图、散点图的方法,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
  • 效果 <template> <div> <div id="main" style="height:500px;"></div> </div> </template> <script> export default { mounted() { this.init() }, ...

    版本 "echarts": "^4.1.0",

    效果图

    <template>
      <div>
        <div id="main" style="height:500px;"></div>
      </div>
    </template>
    
    <script>
    
    export default {
      mounted() {
        this.init()
      },
      methods: {
         getMyLevel(data,flag){
          if(flag!=null){
            if(data==1){
              return "I";
            }else if(data==2){
              return "II";
            }else if(data==3){
              return "III";
            }else if(data==4){
              return "IV";
            }else if(data==5){
              return "V";
            }else if(data==6){
              return "VI";
            }
          }else {
            if (data == 1) {
              return "I类";
            } else if (data == 2) {
              return "II类";
            } else if (data == 3) {
              return "III类";
            } else if (data == 4) {
              return "IV类";
            } else if (data == 5) {
              return "V类";
            } else if (data == 6) {
              return "VI类";
            }
          }
        },
        init() {
          var myChart = this.$echarts.init(document.getElementById('main'));
          // var data = {
          //   "goal": 3,
          //   "levelList": null,
          //   "listAvgFlow": [],
          //   "list": [
          //       {
          //           "isiteid": 78,
          //           "ssitename": "养鹿渡口",
          //           "riverid": 136,
          //           "srivername": "小江",
          //           "idistrictid": 500235000000,
          //           "sdistrictname": "开州区",
          //           "waterLevel": 2,
          //           "watertemp": 24,
          //           "ph": 8,
          //           "do1": 6.6,
          //           "conductivity": 346.1,
          //           "turbidity": 32.5,
          //           "permanganate": null,
          //           "tp": null,
          //           "tn": null,
          //           "nh3n": null,
          //           "COD": null,
          //           "chlorophyll-a": null,
          //           "ph_level": 1,
          //           "do1_level": 2,
          //           "permanganate_level": 0,
          //           "tp_level": 0,
          //           "nh3n_level": 0,
          //           "COD_level": 0,
          //           "year": "2021",
          //           "month": "05",
          //           "day": "13",
          //           "monitoredtime": "2021-05-13T00:00:00.000+0800",
          //           "level": 2,
          //           "value": 2
          //       },
          //       {
          //           "isiteid": 78,
          //           "ssitename": "养鹿渡口",
          //           "riverid": 136,
          //           "srivername": "小江",
          //           "idistrictid": 500235000000,
          //           "sdistrictname": "开州区",
          //           "waterLevel": 1,
          //           "watertemp": 24.1,
          //           "ph": 8,
          //           "do1": 7.6,
          //           "conductivity": 335.6,
          //           "turbidity": 27.3,
          //           "permanganate": null,
          //           "tp": null,
          //           "tn": null,
          //           "nh3n": null,
          //           "COD": null,
          //           "chlorophyll-a": null,
          //           "ph_level": 1,
          //           "do1_level": 1,
          //           "permanganate_level": 0,
          //           "tp_level": 0,
          //           "nh3n_level": 0,
          //           "COD_level": 0,
          //           "year": "2021",
          //           "month": "05",
          //           "day": "12",
          //           "monitoredtime": "2021-05-12T00:00:00.000+0800",
          //           "level": 1,
          //           "value": 1
          //       },
          //       {
          //           "isiteid": 78,
          //           "ssitename": "养鹿渡口",
          //           "riverid": 136,
          //           "srivername": "小江",
          //           "idistrictid": 500235000000,
          //           "sdistrictname": "开州区",
          //           "waterLevel": 3,
          //           "watertemp": 23.8,
          //           "ph": 8,
          //           "do1": 8,
          //           "conductivity": 325.5,
          //           "turbidity": 23.9,
          //           "permanganate": 3.2,
          //           "tp": 0.107,
          //           "tn": 1.67,
          //           "nh3n": 0.44,
          //           "COD": null,
          //           "chlorophyll-a": null,
          //           "ph_level": 1,
          //           "do1_level": 1,
          //           "permanganate_level": 2,
          //           "tp_level": 3,
          //           "nh3n_level": 2,
          //           "COD_level": 0,
          //           "year": "2021",
          //           "month": "05",
          //           "day": "11",
          //           "monitoredtime": "2021-05-11T00:00:00.000+0800",
          //           "level": 3,
          //           "value": 3
          //       },
          //       {
          //           "isiteid": 78,
          //           "ssitename": "养鹿渡口",
          //           "riverid": 136,
          //           "srivername": "小江",
          //           "idistrictid": 500235000000,
          //           "sdistrictname": "开州区",
          //           "waterLevel": 3,
          //           "watertemp": 24,
          //           "ph": 8,
          //           "do1": 7.4,
          //           "conductivity": 317.9,
          //           "turbidity": 23.6,
          //           "permanganate": 3.8,
          //           "tp": 0.111,
          //           "tn": 1.76,
          //           "nh3n": 0.42,
          //           "COD": null,
          //           "chlorophyll-a": null,
          //           "ph_level": 1,
          //           "do1_level": 2,
          //           "permanganate_level": 2,
          //           "tp_level": 3,
          //           "nh3n_level": 2,
          //           "COD_level": 0,
          //           "year": "2021",
          //           "month": "05",
          //           "day": "10",
          //           "monitoredtime": "2021-05-10T00:00:00.000+0800",
          //           "level": 3,
          //           "value": 3
          //       },
          //       {
          //           "isiteid": 78,
          //           "ssitename": "养鹿渡口",
          //           "riverid": 136,
          //           "srivername": "小江",
          //           "idistrictid": 500235000000,
          //           "sdistrictname": "开州区",
          //           "waterLevel": 3,
          //           "watertemp": 24.5,
          //           "ph": 8,
          //           "do1": 7.2,
          //           "conductivity": 315.5,
          //           "turbidity": 22.3,
          //           "permanganate": 3.9,
          //           "tp": 0.11,
          //           "tn": 1.76,
          //           "nh3n": 0.43,
          //           "COD": null,
          //           "chlorophyll-a": null,
          //           "ph_level": 1,
          //           "do1_level": 2,
          //           "permanganate_level": 2,
          //           "tp_level": 3,
          //           "nh3n_level": 2,
          //           "COD_level": 0,
          //           "year": "2021",
          //           "month": "05",
          //           "day": "09",
          //           "monitoredtime": "2021-05-09T00:00:00.000+0800",
          //           "level": 3,
          //           "value": 3
          //       },
          //       {
          //           "isiteid": 78,
          //           "ssitename": "养鹿渡口",
          //           "riverid": 136,
          //           "srivername": "小江",
          //           "idistrictid": 500235000000,
          //           "sdistrictname": "开州区",
          //           "waterLevel": 3,
          //           "watertemp": 23.9,
          //           "ph": 8,
          //           "do1": 7.1,
          //           "conductivity": 320.7,
          //           "turbidity": 20.6,
          //           "permanganate": 3.6,
          //           "tp": 0.108,
          //           "tn": 1.7,
          //           "nh3n": 0.44,
          //           "COD": null,
          //           "chlorophyll-a": null,
          //           "ph_level": 1,
          //           "do1_level": 2,
          //           "permanganate_level": 2,
          //           "tp_level": 3,
          //           "nh3n_level": 2,
          //           "COD_level": 0,
          //           "year": "2021",
          //           "month": "05",
          //           "day": "08",
          //           "monitoredtime": "2021-05-08T00:00:00.000+0800",
          //           "level": 3,
          //           "value": 3
          //       },
          //       {
          //           "isiteid": 78,
          //           "ssitename": "养鹿渡口",
          //           "riverid": 136,
          //           "srivername": "小江",
          //           "idistrictid": 500235000000,
          //           "sdistrictname": "开州区",
          //           "waterLevel": 2,
          //           "watertemp": 23.2,
          //           "ph": 8,
          //           "do1": 7.2,
          //           "conductivity": 331.3,
          //           "turbidity": 16.5,
          //           "permanganate": 3,
          //           "tp": 0.092,
          //           "tn": 1.63,
          //           "nh3n": 0.37,
          //           "COD": null,
          //           "chlorophyll-a": null,
          //           "ph_level": 1,
          //           "do1_level": 2,
          //           "permanganate_level": 2,
          //           "tp_level": 2,
          //           "nh3n_level": 2,
          //           "COD_level": 0,
          //           "year": "2021",
          //           "month": "05",
          //           "day": "07",
          //           "monitoredtime": "2021-05-07T00:00:00.000+0800",
          //           "level": 2,
          //           "value": 2
          //       },
          //       {
          //           "isiteid": 78,
          //           "ssitename": "养鹿渡口",
          //           "riverid": 136,
          //           "srivername": "小江",
          //           "idistrictid": 500235000000,
          //           "sdistrictname": "开州区",
          //           "waterLevel": 2,
          //           "watertemp": 23.5,
          //           "ph": 8,
          //           "do1": 7.9,
          //           "conductivity": 331.1,
          //           "turbidity": 13.8,
          //           "permanganate": 3,
          //           "tp": 0.081,
          //           "tn": 1.61,
          //           "nh3n": 0.33,
          //           "COD": null,
          //           "chlorophyll-a": null,
          //           "ph_level": 1,
          //           "do1_level": 1,
          //           "permanganate_level": 2,
          //           "tp_level": 2,
          //           "nh3n_level": 2,
          //           "COD_level": 0,
          //           "year": "2021",
          //           "month": "05",
          //           "day": "06",
          //           "monitoredtime": "2021-05-06T00:00:00.000+0800",
          //           "level": 2,
          //           "value": 2
          //       },
          //       {
          //           "isiteid": 78,
          //           "ssitename": "养鹿渡口",
          //           "riverid": 136,
          //           "srivername": "小江",
          //           "idistrictid": 500235000000,
          //           "sdistrictname": "开州区",
          //           "waterLevel": 3,
          //           "watertemp": 23.7,
          //           "ph": 8,
          //           "do1": 9.3,
          //           "conductivity": 302.7,
          //           "turbidity": 10.4,
          //           "permanganate": 4.5,
          //           "tp": 0.071,
          //           "tn": 1.6,
          //           "nh3n": 0.27,
          //           "COD": null,
          //           "chlorophyll-a": null,
          //           "ph_level": 1,
          //           "do1_level": 1,
          //           "permanganate_level": 3,
          //           "tp_level": 2,
          //           "nh3n_level": 2,
          //           "COD_level": 0,
          //           "year": "2021",
          //           "month": "05",
          //           "day": "05",
          //           "monitoredtime": "2021-05-05T00:00:00.000+0800",
          //           "level": 3,
          //           "value": 3
          //       },
          //       {
          //           "isiteid": 78,
          //           "ssitename": "养鹿渡口",
          //           "riverid": 136,
          //           "srivername": "小江",
          //           "idistrictid": 500235000000,
          //           "sdistrictname": "开州区",
          //           "waterLevel": 3,
          //           "watertemp": 23.7,
          //           "ph": 8,
          //           "do1": 8.9,
          //           "conductivity": 286.3,
          //           "turbidity": 11.4,
          //           "permanganate": 5.3,
          //           "tp": 0.076,
          //           "tn": 1.71,
          //           "nh3n": 0.33,
          //           "COD": null,
          //           "chlorophyll-a": null,
          //           "ph_level": 1,
          //           "do1_level": 1,
          //           "permanganate_level": 3,
          //           "tp_level": 2,
          //           "nh3n_level": 2,
          //           "COD_level": 0,
          //           "year": "2021",
          //           "month": "05",
          //           "day": "04",
          //           "monitoredtime": "2021-05-04T00:00:00.000+0800",
          //           "level": 3,
          //           "value": 3
          //       },
          //       {
          //           "isiteid": 78,
          //           "ssitename": "养鹿渡口",
          //           "riverid": 136,
          //           "srivername": "小江",
          //           "idistrictid": 500235000000,
          //           "sdistrictname": "开州区",
          //           "waterLevel": 3,
          //           "watertemp": 23.8,
          //           "ph": 8,
          //           "do1": 9.3,
          //           "conductivity": 273.1,
          //           "turbidity": 15.2,
          //           "permanganate": 5.5,
          //           "tp": 0.084,
          //           "tn": 1.89,
          //           "nh3n": 0.41,
          //           "COD": null,
          //           "chlorophyll-a": null,
          //           "ph_level": 1,
          //           "do1_level": 1,
          //           "permanganate_level": 3,
          //           "tp_level": 2,
          //           "nh3n_level": 2,
          //           "COD_level": 0,
          //           "year": "2021",
          //           "month": "05",
          //           "day": "03",
          //           "monitoredtime": "2021-05-03T00:00:00.000+0800",
          //           "level": 3,
          //           "value": 3
          //       },
          //       {
          //           "isiteid": 78,
          //           "ssitename": "养鹿渡口",
          //           "riverid": 136,
          //           "srivername": "小江",
          //           "idistrictid": 500235000000,
          //           "sdistrictname": "开州区",
          //           "waterLevel": 3,
          //           "watertemp": 25,
          //           "ph": 9,
          //           "do1": 11.7,
          //           "conductivity": 256.3,
          //           "turbidity": 18.7,
          //           "permanganate": 5.9,
          //           "tp": 0.099,
          //           "tn": 2.03,
          //           "nh3n": 0.46,
          //           "COD": null,
          //           "chlorophyll-a": null,
          //           "ph_level": 1,
          //           "do1_level": 1,
          //           "permanganate_level": 3,
          //           "tp_level": 2,
          //           "nh3n_level": 2,
          //           "COD_level": 0,
          //           "year": "2021",
          //           "month": "05",
          //           "day": "02",
          //           "monitoredtime": "2021-05-02T00:00:00.000+0800",
          //           "level": 3,
          //           "value": 3
          //       },
          //       {
          //           "isiteid": 78,
          //           "ssitename": "养鹿渡口",
          //           "riverid": 136,
          //           "srivername": "小江",
          //           "idistrictid": 500235000000,
          //           "sdistrictname": "开州区",
          //           "waterLevel": 3,
          //           "watertemp": 24.4,
          //           "ph": 9,
          //           "do1": 10.2,
          //           "conductivity": 252.4,
          //           "turbidity": 30.5,
          //           "permanganate": 5.6,
          //           "tp": 0.117,
          //           "tn": 2.27,
          //           "nh3n": 0.6,
          //           "COD": null,
          //           "chlorophyll-a": null,
          //           "ph_level": 1,
          //           "do1_level": 1,
          //           "permanganate_level": 3,
          //           "tp_level": 3,
          //           "nh3n_level": 3,
          //           "COD_level": 0,
          //           "year": "2021",
          //           "month": "05",
          //           "day": "01",
          //           "monitoredtime": "2021-05-01T00:00:00.000+0800",
          //           "level": 3,
          //           "value": 3
          //       }
          //   ],
          //   "listAvgTemp": []
          // }
    
    
          var checkInfo = {
            showItem: [
                "level",
                "ph",
                "do1",
                "permanganate",
                "tp",
                "nh3n",
                "watertemp",
                "conductivity",
                "turbidity",
                "tn",
                "COD"
            ],
            showName: [
                "水质",
                "PH值(无量纲)",
                "溶解氧(mg/L)",
                "高锰酸盐指数(mg/L)",
                "总磷(mg/L)",
                "氨氮(mg/L)",
                "水温(℃)",
                "电导率(μS/cm)",
                "浊度(NTU)",
                "总氮(mg/L)",
                "化学需氧量(mg/L)"
            ]
          }
          
    			// y轴位置规划
    			var mycolor = ['#8B668B', '#659ab0', '#28FF28', '#EEAD0E', "#1d4bfe", "#08cbff", "#2ad795", "#edc504", "#fb8f3c", "#f96464","#2bd895"];
    			// var xWidth = 35;
    			// var offsetParam = 1;
    			// if (checkInfo.showItem.length < 3) {
    			// 	offsetParam = checkInfo.showItem.length - 2;
    			// }
          // var posions = [
    			// 	{offset: xWidth * (offsetParam + 1), position: "left"},
    			// 	{offset: xWidth * offsetParam, position: "left"},
    			// 	{position: "left"},
    			// 	{axisLine: {onZero: false}},
    			// 	{axisLine: {onZero: false}, offset: xWidth},
    			// 	{offset: xWidth * 2},
    			// 	{offset: xWidth * (offsetParam+2), position: "left"},
    			// 	{offset: xWidth * (offsetParam+3), position: "left"},
    			// 	{axisLine: {onZero: false},offset: xWidth * 3},
    			// 	{axisLine: {onZero: false},offset: xWidth * 4},
          //           {axisLine: {onZero: false},offset: xWidth * 4.8}
    			// ];
    			// var shuizhiIndex = -1;
          // var valArr = {};
    
    
          var timeArr = [1,2,3,4,5,6,7,8]
          var myYAxis = [
        {
            "type": "value",
            // 分割线
            "splitLine": {
                "show": false
            },
            // 坐标轴线
            "axisLine": {
                "lineStyle": {
                    color: 'red'
                }
            },
            // 坐标轴文本标签,详见axis.axisLabel
            "axisLabel": {},
            // 偏移像素
            "offset": 70,
            // 位置 默认自适应
            // "position": "right"
        },
        {
            "type": "value",
            "splitLine": {
                "show": false
            },
            "axisLine": {
                "lineStyle": {
                    "color": "#659ab0"
                }
            },
            "axisLabel": {},
            "offset": 35,
            "position": "left"
        },
        {
            "type": "value",
            "splitLine": {
                "show": false
            },
            "axisLine": {
                "lineStyle": {
                    "color": "#28FF28"
                }
            },
            "axisLabel": {},
            "position": "left"
        },
        {
            "type": "value",
            "splitLine": {
                "show": false
            },
            "axisLine": {
                "onZero": false,
                "lineStyle": {
                    "color": "#EEAD0E"
                }
            },
            "axisLabel": {}
        },
        {
            "type": "value",
            "splitLine": {
                "show": false
            },
            "axisLine": {
                "onZero": false,
                "lineStyle": {
                    "color": "#1d4bfe"
                }
            },
            "axisLabel": {},
            "offset": 35
        },
        {
            "type": "value",
            "splitLine": {
                "show": false
            },
            "axisLine": {
                "lineStyle": {
                    "color": "#08cbff"
                }
            },
            "axisLabel": {},
            "offset": 70
        },
        {
            "type": "value",
            "splitLine": {
                "show": false
            },
            "axisLine": {
                "lineStyle": {
                    "color": "#2ad795"
                }
            },
            "axisLabel": {},
            "offset": 105,
            "position": "left"
        },
        {
            "type": "value",
            "splitLine": {
                "show": false
            },
            "axisLine": {
                "lineStyle": {
                    "color": "#edc504"
                }
            },
            "axisLabel": {},
            "offset": 140,
            "position": "left"
        },
        {
            "type": "value",
            "splitLine": {
                "show": false
            },
            "axisLine": {
                "onZero": false,
                "lineStyle": {
                    "color": "#fb8f3c"
                }
            },
            "axisLabel": {},
            "offset": 105
        },
        {
            "type": "value",
            "splitLine": {
                "show": false
            },
            "axisLine": {
                "onZero": false,
                "lineStyle": {
                    "color": "#f96464"
                }
            },
            "axisLabel": {},
            "offset": 140
        },
        {
            "type": "value",
            "splitLine": {
                "show": false
            },
            "axisLine": {
                "onZero": false,
                "lineStyle": {
                    "color": "#2bd895"
                }
            },
            "axisLabel": {},
            "offset": 168
              }];
          // 对应每个图表系列
    			var mySeries = [
        {
            // 系列名称
            "name": "水质",
            // 系列中的数据内容
            "data": [
                3,
                3,
                3,
                3,
                3,
                2,
                2,
                3,
                3,
                3,
                3,
                1,
                2
            ],
            // 系列图表类型
            "type": "line",
            // 折线图默认参数
            "itemStyle": {
                "normal": {
                    "lineStyle": {
                        "color": "#8B668B"
                    }
                }
            },
            "markPoint": {
                "symbol": "pin", // 标注类型
                "symbolSize": 40, // 标注大小,半宽(半径)参数,当图形为方向或菱形则总宽度为symbolSize * 2
                "itemStyle": {
                    // "color": "#8B668B",
                    color: 'red',
                    "borderColor": "red",
                    "borderWidth": 100, // 标注边线线宽,单位px,默认为1
                    "borderType": "solid",
                    "normal": {
                        "label": {}
                    }
                },
                // 最大值最小值
                "data": [
                    {
                        "type": "max",
                        "name": "最大值"
                    },
                    {
                        "type": "min",
                        "name": "最小值"
                    }
                ]
            },
            "yAxisIndex": 0
        },
        {
            "name": "PH值(无量纲)",
            "data": [
                9,
                9,
                8,
                8,
                8,
                8,
                8,
                8,
                8,
                8,
                8,
                8,
                8
            ],
            "type": "line",
            "itemStyle": {
                "normal": {
                    "lineStyle": {
                        "color": "#659ab0"
                    }
                }
            },
            "markPoint": {
                "symbol": "pin",
                "symbolSize": 40,
                "itemStyle": {
                    "color": "#659ab0",
                    "borderColor": "#000",
                    "borderWidth": 0,
                    "borderType": "solid",
                    "normal": {
                        "label": {}
                    }
                },
                "data": [
                    {
                        "type": "max",
                        "name": "最大值"
                    },
                    {
                        "type": "min",
                        "name": "最小值"
                    }
                ]
            },
            "yAxisIndex": 1
        },
        {
            "name": "溶解氧(mg/L)",
            "data": [
                10.2,
                11.7,
                9.3,
                8.9,
                9.3,
                7.9,
                7.2,
                7.1,
                7.2,
                7.4,
                8,
                7.6,
                6.6
            ],
            "type": "line",
            "itemStyle": {
                "normal": {
                    "lineStyle": {
                        "color": "#28FF28"
                    }
                }
            },
            "markPoint": {
                "symbol": "pin",
                "symbolSize": 40,
                "itemStyle": {
                    "color": "#28FF28",
                    "borderColor": "#000",
                    "borderWidth": 0,
                    "borderType": "solid",
                    "normal": {
                        "label": {}
                    }
                },
                "data": [
                    {
                        "type": "max",
                        "name": "最大值"
                    },
                    {
                        "type": "min",
                        "name": "最小值"
                    }
                ]
            },
            "yAxisIndex": 2
        },
        {
            "name": "高锰酸盐指数(mg/L)",
            "data": [
                5.6,
                5.9,
                5.5,
                5.3,
                4.5,
                3,
                3,
                3.6,
                3.9,
                3.8,
                3.2,
                null,
                null
            ],
            "type": "line",
            "itemStyle": {
                "normal": {
                    "lineStyle": {
                        "color": "#EEAD0E"
                    }
                }
            },
            "markPoint": {
                "symbol": "pin",
                "symbolSize": 40,
                "itemStyle": {
                    "color": "#EEAD0E",
                    "borderColor": "#000",
                    "borderWidth": 0,
                    "borderType": "solid",
                    "normal": {
                        "label": {}
                    }
                },
                "data": [
                    {
                        "type": "max",
                        "name": "最大值"
                    },
                    {
                        "type": "min",
                        "name": "最小值"
                    }
                ]
            },
            "yAxisIndex": 3
        },
        {
            "name": "总磷(mg/L)",
            "data": [
                0.117,
                0.099,
                0.084,
                0.076,
                0.071,
                0.081,
                0.092,
                0.108,
                0.11,
                0.111,
                0.107,
                null,
                null
            ],
            "type": "line",
            "itemStyle": {
                "normal": {
                    "lineStyle": {
                        "color": "#1d4bfe"
                    }
                }
            },
            "markPoint": {
                "symbol": "pin",
                "symbolSize": 40,
                "itemStyle": {
                    "color": "#1d4bfe",
                    "borderColor": "#000",
                    "borderWidth": 0,
                    "borderType": "solid",
                    "normal": {
                        "label": {}
                    }
                },
                "data": [
                    {
                        "type": "max",
                        "name": "最大值"
                    },
                    {
                        "type": "min",
                        "name": "最小值"
                    }
                ]
            },
            "yAxisIndex": 4
        },
        {
            "name": "氨氮(mg/L)",
            "data": [
                0.6,
                0.46,
                0.41,
                0.33,
                0.27,
                0.33,
                0.37,
                0.44,
                0.43,
                0.42,
                0.44,
                null,
                null
            ],
            "type": "line",
            "itemStyle": {
                "normal": {
                    "lineStyle": {
                        "color": "#08cbff"
                    }
                }
            },
            "markPoint": {
                "symbol": "pin",
                "symbolSize": 40,
                "itemStyle": {
                    "color": "#08cbff",
                    "borderColor": "#000",
                    "borderWidth": 0,
                    "borderType": "solid",
                    "normal": {
                        "label": {}
                    }
                },
                "data": [
                    {
                        "type": "max",
                        "name": "最大值"
                    },
                    {
                        "type": "min",
                        "name": "最小值"
                    }
                ]
            },
            "yAxisIndex": 5
        },
        {
            "name": "水温(℃)",
            "data": [
                24.4,
                25,
                23.8,
                23.7,
                23.7,
                23.5,
                23.2,
                23.9,
                24.5,
                24,
                23.8,
                24.1,
                24
            ],
            "type": "line",
            "itemStyle": {
                "normal": {
                    "lineStyle": {
                        "color": "#2ad795"
                    }
                }
            },
            "markPoint": {
                "symbol": "pin",
                "symbolSize": 40,
                "itemStyle": {
                    "color": "#2ad795",
                    "borderColor": "#000",
                    "borderWidth": 0,
                    "borderType": "solid",
                    "normal": {
                        "label": {}
                    }
                },
                "data": [
                    {
                        "type": "max",
                        "name": "最大值"
                    },
                    {
                        "type": "min",
                        "name": "最小值"
                    }
                ]
            },
            "yAxisIndex": 6
        },
        {
            "name": "电导率(μS/cm)",
            "data": [
                252.4,
                256.3,
                273.1,
                286.3,
                302.7,
                331.1,
                331.3,
                320.7,
                315.5,
                317.9,
                325.5,
                335.6,
                346.1
            ],
            "type": "line",
            "itemStyle": {
                "normal": {
                    "lineStyle": {
                        "color": "#edc504"
                    }
                }
            },
            "markPoint": {
                "symbol": "pin",
                "symbolSize": 40,
                "itemStyle": {
                    "color": "#edc504",
                    "borderColor": "#000",
                    "borderWidth": 0,
                    "borderType": "solid",
                    "normal": {
                        "label": {}
                    }
                },
                "data": [
                    {
                        "type": "max",
                        "name": "最大值"
                    },
                    {
                        "type": "min",
                        "name": "最小值"
                    }
                ]
            },
            "yAxisIndex": 7
        },
        {
            "name": "浊度(NTU)",
            "data": [
                30.5,
                18.7,
                15.2,
                11.4,
                10.4,
                13.8,
                16.5,
                20.6,
                22.3,
                23.6,
                23.9,
                27.3,
                32.5
            ],
            "type": "line",
            "itemStyle": {
                "normal": {
                    "lineStyle": {
                        "color": "#fb8f3c"
                    }
                }
            },
            "markPoint": {
                "symbol": "pin",
                "symbolSize": 40,
                "itemStyle": {
                    "color": "#fb8f3c",
                    "borderColor": "#000",
                    "borderWidth": 0,
                    "borderType": "solid",
                    "normal": {
                        "label": {}
                    }
                },
                "data": [
                    {
                        "type": "max",
                        "name": "最大值"
                    },
                    {
                        "type": "min",
                        "name": "最小值"
                    }
                ]
            },
            "yAxisIndex": 8
        },
        {
            "name": "总氮(mg/L)",
            "data": [
                2.27,
                2.03,
                1.89,
                1.71,
                1.6,
                1.61,
                1.63,
                1.7,
                1.76,
                1.76,
                1.67,
                null,
                null
            ],
            "type": "line",
            "itemStyle": {
                "normal": {
                    "lineStyle": {
                        "color": "#f96464"
                    }
                }
            },
            "markPoint": {
                "symbol": "pin",
                "symbolSize": 40,
                "itemStyle": {
                    "color": "#f96464",
                    "borderColor": "#000",
                    "borderWidth": 0,
                    "borderType": "solid",
                    "normal": {
                        "label": {}
                    }
                },
                "data": [
                    {
                        "type": "max",
                        "name": "最大值"
                    },
                    {
                        "type": "min",
                        "name": "最小值"
                    }
                ]
            },
            "yAxisIndex": 9
        },
        {
            "name": "化学需氧量(mg/L)",
            "data": [
                null,
                null,
                null,
                null,
                null,
                null,
                null,
                null,
                null,
                null,
                null,
                null,
                null
            ],
            "type": "line",
            "itemStyle": {
                "normal": {
                    "lineStyle": {
                        "color": "#2bd895"
                    }
                }
            },
            "markPoint": {
                "symbol": "pin",
                "symbolSize": 40,
                "itemStyle": {
                    "color": "#2bd895",
                    "borderColor": "#000",
                    "borderWidth": 0,
                    "borderType": "solid",
                    "normal": {
                        "label": {}
                    }
                },
                "data": [
                    {
                        "type": "max",
                        "name": "最大值"
                    },
                    {
                        "type": "min",
                        "name": "最小值"
                    }
                ]
            },
            "yAxisIndex": 10
        }
              ];
          let rangeWaterQualityListOption = {
            // 布局方式
    				toolbox: {
    					// y: 'bottom',
    					feature: {
    						magicType: {
    							type: ['line', 'bar']
    						},
    						saveAsImage: {
    							pixelRatio: 2
    						}
    					}
    				},
            // 整体图表
    				grid: {
    					top:'80px',
            //   x: 80,
            // y: 60,
    					// x: xOffset + "%",// x 偏移量
    					// y: "50px", // y 偏移量
    					// width: width + "%", // 宽度
    					// height: "67%"// 高度
    				},
            // x 轴
    				xAxis: {
    					type: 'category',
              // x 轴数据
    					data: timeArr, 
    					axisLine: {
    						lineStyle: {
    							color: "green"
    						}
    					}
    				},
            // 提示框(重要)
    				tooltip: {
              // 触发类型  轴对称
    					trigger: 'axis',
              // params 包含每个图表的信息
    					formatter: function (params, ticket, callback) {
    						var str = "";
    						str += params[0].marker + "监测时间" + ":" + params[0].name + "</br>";
    						for (var i = 0; i < params.length; i++) {
    							var val = params[i].data;
    							if (params[i].data == null) {
    								continue;
    							}
    							var dw = "mg/L";
    							if (params[i].seriesName == "水质") {
    								var liebie = ["", "I类", "II类", "III类", "IV类", "V类", "劣V类"];
    								str += params[i].marker + params[i].seriesName + ":" + liebie[val] + "</br>";
    							} else if (params[i].seriesName == "PH值(无量纲)") {
    								dw = "无量纲";
    								str += params[i].marker + params[i].seriesName + ":" + val + "[" + dw + "]</br>";
    							} else {
    								str += params[i].marker + params[i].seriesName + ":" + val + "[" + dw + "]</br>";
    							}
    						}
                // 返回提示信息
    						return str;
    					}
    				},
    				color: ['#8B668B', '#659ab0', '#28FF28', '#EEAD0E', "#1d4bfe", "#08cbff", "#2ad795", "#edc504", "#fb8f3c", "#f96464"],
    				// 最上方图例
            legend: [{
    					type: 'scroll',
              // 图例宽高
    					itemHeight: 18,
    					itemWidth: 30,
              // 图例名字 需要与series系列name 一一对应图例才会显示成功
    					data: checkInfo.showName,
    					x: "center",
    					y: "top",
    					textStyle: {
    						color: "gray",
    						fontSize: 12
    					},
              // 设置选中那些折线
    					selected: {
    						'水质': false,
    						// 选中'系列1'
    						'PH值(无量纲)': true,
    						// 选中'系列2'
    						'溶解氧(mg/L)': true,
    						'高猛酸盐指数(mg/L)': true,
    						'氨氮(mg/L)': true,
    						'总磷(mg/L)': true,
    						'水温(℃)': false,
    						'电导率(μS/cm)': false,
    						'浊度(NTU)': false,
    						'总氮(mg/L)': false,
                            '化学需氧量(mg/L)': false
    					}
    				}],
    				yAxis: myYAxis,
    				series: mySeries
    			};
          myChart.setOption(rangeWaterQualityListOption, true);
        }, 
      }
    }
    </script>
    

     

    展开全文
  • I was having trouble creating a plot I need which has multiple line graphs.What I want is a way to graph each of these above the other (say one has a baseline of y=5 I want the next to have a baseline...

    I was having trouble creating a plot I need which has multiple line graphs.

    What I want is a way to graph each of these above the other (say one has a baseline of y=5 I want the next to have a baseline of y=10) and also each of these graphs must block the one above it.

    So this will inevitably look like the cover to Joy Divisions Unknown Pleasures here:

    http://cococubed.asu.edu/images/unknown_pleasures/unknown_pleasures.jpg

    Except inverted colors and I also would like an answer that utilizes python or numpy or matplotlib.

    解决方案

    Here's one way. The key point is to use fill_between function and offset each plotted line with some margin (i*2 in this case). Also, plotting has to start from the top, hence the [::-1] in the arange slice.

    t=linspace(-2*pi, 2*pi, 1000)

    for i in arange(1, pi, 0.01)[::-1]:

    left = exp(-(t + (i - 1) * 2*pi)**2) * cos(t * i)**2 - 1

    right = exp(-(t - (i - 1) * 2*pi)**2) * cos(t * i)**2 - 1

    vertical_offset = i*2

    fill_between(t, vertical_offset + left + right, facecolor='white')

    8030c9d3a69eca8fe5bff8a334541d20.png

    展开全文
  • I was having trouble creating a plot I need which has multiple line graphs.What I want is a way to graph each of these above the other (say one has a baseline of y=5 I want the next to have a baseline...

    1586010002-jmsa.png

    I was having trouble creating a plot I need which has multiple line graphs.

    What I want is a way to graph each of these above the other (say one has a baseline of y=5 I want the next to have a baseline of y=10) and also each of these graphs must block the one above it.

    So this will inevitably look like the cover to Joy Divisions Unknown Pleasures here:

    http://cococubed.asu.edu/images/unknown_pleasures/unknown_pleasures.jpg

    Except inverted colors and I also would like an answer that utilizes python or numpy or matplotlib.

    解决方案

    Here's one way. The key point is to use fill_between function and offset each plotted line with some margin (i*2 in this case). Also, plotting has to start from the top, hence the [::-1] in the arange slice.

    t=linspace(-2*pi, 2*pi, 1000)

    for i in arange(1, pi, 0.01)[::-1]:

    left = exp(-(t + (i - 1) * 2*pi)**2) * cos(t * i)**2 - 1

    right = exp(-(t - (i - 1) * 2*pi)**2) * cos(t * i)**2 - 1

    vertical_offset = i*2

    fill_between(t, vertical_offset + left + right, facecolor='white')

    7Xow1eL.png

    展开全文
  • Excel折线图面积图模板-段式折线图
  • 用于计算机等领域论文实验数据的折线图绘制
  • 2、echarts折线图动态分层 var xData = param.xData; var data = param.yData let option = []; let num =param.num ? param.num : 0; let max = num ? num *100 : 100; //处理精度丢失问题 但不是最佳...
  • python一个平面上绘制多个动态折线图,以下先将整体代码插入,再分布讲解:importnumpy as npimportmatplotlib.pyplot as pltfrom matplotlib.ticker importMultipleLocator, FormatStrFormatterdefminmax_value...
  • MPAndroidChart的强大之处就不在多说了,目前最新的版本是3.0.1,新版本方法都被弃用了,这要注意一下,网上查到的大多数资料都是关于旧版本的,今天来实现一下折线图,把过程记录下来,分享给大家。...
  • matplotlib绘制折线图

    2020-12-23 02:19:46
    开个逗b号纪念下这段闭关的时光=^=万一他以后就变成一个数据分析的大v号了来~ 好了邵大白课堂开课了 折线图绘制 咱先画个图,载慢悠的加东西 #导包 import matplotlib.pyplot as plt #绘图 plt.plot([3,5,6],[3,6,5]...
  • 最近项目上有一个折线图的需求,根据实际的产品需求、面向服务器接口数据手撸了一个,自己写随意玩=。= 简书介绍http://www.jianshu.com/p/90c68507e378 github下载地址...
  • 指标分析折线图PPT图表素材下载,本素材通过蜘蛛网结构,以折线的方式,分析了6种指标,是综合分析图表常用素材; 关键词:蜘蛛网,雷达,指标,折线图,幻灯片图表素材,PPTX格式;
  • 使用matplotlib绘制折线图   直接使用plot()函数  plt.plot(x,y,format_string,**kwargs)  x轴数据,y轴数据,format_string控制曲线的格式字串,format_string由颜色字符,风格字符,和标记字符 。  导入库 ...
  • 前言最近项目的时候,产品说要...结果是——只显示一个折线图,控制台没有报错。开始有些思路,产生问题的原因可能是:、数据没有传过来;二、数据绑定的问题;三、二问题同时有。最后发现开始的HTML结构出...
  • matplotlib是Python一个第三方库。主要用于开发2D图表,以渐进式、交互式的方式实现数据可视化,可以更直观的呈现数据,使数据更具说服力。 一、安装matplotlib pip install matplotlib -i ...
  • 绘制折线图 如果将散点图上的点从左往右连接起来,就会得到一个折线图。今天我们以R自带的Orange 数据集为例,来学习折线图的画法,该数据集中包含五种橘树的树龄和年轮数据。要考察橘树的年轮如何随着树龄变化,...
  • 使用 d3.js 构建的交互式折线图。 具有过渡、多个 TSV 数据文件源、工具提示等! 各位 d3.js 爱好者,大家好,我是 d3 新手,正在一边学习 d3.js。 我正在探索如何通过过渡和交互使无聊的图表更有趣。 这个存储库...
  • 主要介绍了Echarts动态加载折线图的实现代码,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
  • vue使用echarts 动态生成多个折线图

    千次阅读 2021-08-12 10:03:59
    刚接了一个新需求,需要同时生成多个折线图, 例如: lineList 是后台请求过来的数据,为一个数组,我们循环这个数组循环调用drawLineOne方法, 具体实现代码如下 <template v-for="(item,index) in ...
  • 之前公司有绘制实时盈利率折线图的需求,实现的还不错,今天来分享下vue+echarts实现动态折线图的方法。 实现代码 <div id=myChart></div> [removed] import echarts from 'echarts' export default { name: ...
  • excel用户制作表格的过程,有时候为了更加凸显数据的走势变化,就需要用到折线图了,大多数用户使用折线图都是直接插入使用,那么怎么插入折线图呢?方法很简单,下面小编为大家带来excel插入折线图的详细...
  • 开发天气APP的时候会要显示天的信息,所以加一个折线图来显示一下天气变化趋势是很不错的效果,本文详细介绍了开发过程,下面起来看看。
  • 作者PengXinabc,源码PXLineChart,一个简单的可滑动的折线图,可滑动,可添加条。
  • 这里是正常的折线图的渲染;只是展示tooltip的时候 自己格式化了一下。这里就是上面3.2说的 知道数组的索引就可以拿到相应的值;这params是我鼠标滑到哪里的整个对象;这方法是将数据转化为G的单位的方法;根据...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 56,390
精华内容 22,556
热门标签
关键字:

如何在一个图中做多个折线图