精华内容
下载资源
问答
  • 如何画多个折线图
    千次阅读
    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 #这里导入...
  • Canvas之画多个折线图

    千次阅读 2017-06-14 20:51:26
    使用html画多个折线图,效果图如下: 二,代码片段(完整的代码在文章的最后) var a_canvas; var a_context; var b_canvas; var b_context; window.onload = function() { a_canvas = ...

    一说明:

    使用html画多个折线图,效果图如下:


    二,代码片段(完整的代码在文章的最后)

    <canvas id="a_canvas" width="850" height="450" ></canvas>
    <script>
    			var a_canvas;
    			var a_context;
    
    			var b_canvas;
    			var b_context;
    
    			window.onload = function() {
    				a_canvas = document.getElementById('a_canvas');
    				if(a_canvas && a_canvas.getContext) {
    					a_context = a_canvas.getContext('2d');
    				}
    
    				b_canvas = document.getElementById('b_canvas');
    				if(b_canvas && b_canvas.getContext) {
    					b_context = b_canvas.getContext('2d');
    				}
    
    				a_centerX = a_canvas.width / 3, //Canvas三分之一x轴坐标
    					a_centerY = a_canvas.height / 2, //Canvas中心点y轴坐标
    					rad = Math.PI * 2 / 100, //将360度分成100份,那么每一份就是rad度
    
    					whiteCircle(a_context, a_centerX, a_centerY);
    				text(a_context, a_centerX, a_centerY);
    				list(a_context, a_centerX, a_centerY);
    				
    				var white_data = [17, 3, 15, 5, 14, 3, 27, 5];
    				var yellow_data = [10, 13, 5, 5, 4, 13, 27, 15];
    				var white="white";
    				var yellow="yellow";
    				lineChart(b_context,b_canvas,white_data,white);//context,canvas,data,color
    				lineChart(b_context,b_canvas,yellow_data,yellow);
    			}
    			//绘制内圈
    			function whiteCircle(context, centerX, centerY) {
    				context.save();
    				context.beginPath();
    				context.radius = 80;
    				context.lineWidth = 80;
    				context.strokeStyle = "#81EF7D";
    				context.arc(centerX, centerY, 170, 0, Math.PI * 2, false);
    				context.stroke();
    				context.closePath();
    				context.restore();
    			}
    			//文字绘制
    			function text(context, centerX, centerY) {
    				context.save(); //save和restore可以保证样式属性只运用于该段canvas元素
    				context.strokeStyle = "#81EF7D"; //设置描边样式
    				context.fillStyle = "#1DABE2";
    
    				context.font = "80px sans-serif"; //设置字体大小和字体
    
    				//绘制字体,并且指定位置
    				context.fillText("0", centerX - 20, centerY - 10);
    				context.font = "40px sans-serif";
    				context.fillText("延误总数", centerX - 75, centerY + 40);
    				context.stroke(); //执行绘制
    				context.restore();
    			}
    
    			function list(context, centerX, centerY) {
    
    				context.save(); //save和restore可以保证样式属性只运用于该段canvas元素
    				context.beginPath();
    				context.arc(centerX * 3 * 0.9 - 20, centerY * 2 * 0.9 - 10, 10, 0, 360, false);
    				context.fillStyle = "#81EF7D";
    				context.fill();
    				context.closePath();
    				context.strokeStyle = "#81EF7D"; //设置描边样式
    				context.fillStyle = "black";
    				context.font = "30px sans-serif";
    				context.fillText("其他", centerX * 3 * 0.9, centerY * 2 * 0.9);
    
    				context.stroke(); //执行绘制
    				context.restore();
    			}
    			function lineChart(context,canvas,data,color) {
    				
    				// 绘制背景
    				var gradient = context.createLinearGradient(0, 0, 0, 300);
    
    				context.fillStyle = gradient;
    
    				context.fillRect(0, 0, canvas.width, canvas.height);
    
    				// 描绘边框
    				var grid_cols = data.length + 1;
    				var grid_rows = 8;
    				var cell_height = canvas.height / grid_rows;
    				var cell_width = canvas.width / grid_cols;
    				context.lineWidth = 1;
    				context.strokeStyle = "#a0a0a0";
    
    				var max_v = 60;
    
    				for(var i = 0; i < data.length; i++) {
    					var d = 0;
    					if(data[i] < 0) {
    						d = d - data[i];
    					} else { d = data[i]; };
    					if(d > max_v) { max_v = d };
    				}
    				max_v = max_v * 1.0;
    				// 将数据换算为坐标
    				var points = [];
    				for(var i = 0; i < data.length; i++) {
    					var v = data[i];
    					var px = cell_width *  (i + 1);
    					var py = canvas.height - canvas.height * (v / max_v);
    					points.push({ "x": px, "y": py });
    				}
    
    				
    
    				// 绘制折现
    				context.beginPath();
    				context.moveTo(points[0].x, points[0].y);
    				for(var i = 1; i < points.length; i++) {
    					context.lineTo(points[i].x, points[i].y);
    				}
    
    				context.lineWidth = 4;
    				context.strokeStyle = color;
    				context.stroke();
    
    				//绘制坐标图形
    				for(var i in points) {
    					if(i < 19) {
    						var p = points[i];
    
    						context.beginPath();
    						context.lineWidth = 4;
    						context.radius = 4;
    						context.strokeStyle = "white";
    						context.fillStyle = color;
    						context.arc(p.x, p.y, 7, 0, Math.PI * 2, false);
    
    						context.stroke();
    						context.fill();
    						context.closePath();
    					} else {
    
    					}
    
    				}
    
    			}
    		</script>


    
    

    三,Demo地址(该demo还包换圆环,柱状图等等)

    展开全文
  • python画多折线图(简介)

    千次阅读 2021-01-10 10:22:30
    新建一pathon项目。 二、代码 # -*- coding: utf-8 -*- import matplotlib.pyplot as plt names = ['1', '2', '3', '4', '5', '6'] x = range(len(names)) plt.rcParams['font.sans-serif'] = ['SimHei'] # ...

    目录

     

    一、打开python

    二、代码 

    三、运行结果 


    一、打开python

    新建一个pathon项目。 

    二、代码 

    # -*- coding: utf-8 -*-
    import matplotlib.pyplot as plt
    
    names = ['1', '2', '3', '4', '5', '6']
    x = range(len(names))
    plt.rcParams['font.sans-serif'] = ['SimHei']  # 显示汉字
    
    y_1 = [2, 3, 4, 5, 6, 1]
    y_2 = [3, 4, 5, 6, 1, 2]   //y轴的值
    y_3 = [4, 5, 6, 1, 2, 3]
    
    plt.plot(x, y_1, color='orangered', marker='o', linestyle='-', label='A')
    plt.plot(x, y_2, color='blueviolet', marker='D', linestyle='-.', label='B')
    plt.plot(x, y_3, color='green', marker='*', linestyle=':', label='C')
    plt.legend()  # 显示图例
    plt.xticks(x, names, rotation=45)
    plt.xlabel("X轴坐标")  # X轴标签
    plt.ylabel("Y轴坐标")  # Y轴标签
    plt.show()

    三、运行结果 

     

    展开全文
  • Matlab绘制多个折线图的方法

    千次阅读 多人点赞 2021-06-29 00:11:22
    给出一个Matlab绘制折线图的例子:Matlab绘制多个折线图和子图的详细方法,并且字体设置为Times New Roman,可用于普通课程作业的撰写。 %% 维数选择 % 人脸1.f Dim = 10:10:100; %% 数据选择 % 人脸1.f RKSH = [53 ...

    给出一个Matlab绘制折线图的例子:Matlab绘制多个折线图和子图的详细方法,并且字体设置为Times New Roman,可用于普通课程作业的撰写。

    %% 维数选择
    % 人脸1.f
    Dim = 10:10:100;
    %% 数据选择
    % 人脸1.f
    RKSH = [53 68 74 77 77 78 78 78 78 78];
    RKSHs = [73 81 84 84 85 86 88 88 88 88];
    TCA = [63 73 74 78 77 78 78 78 79 79];
    TCAs = [72 81 84 83 85 86 88 88 88 88];
    IGLDA = [61 73 77 78 78 80 81 81 81 81];
    IGLDAs = [72 81 84 83 85 86 88 88 88 88];
    TIT = [58 68 72 76 76 75 74 75 75 75];
    TITs = [62 71 76 78 79 79 81 82 83 82];
    %% 画图
    %1
    subplot(2,2,1)
    plot(Dim,RKSH,'-*b',Dim,RKSHs,'-or'); %线性,颜色,标记
    %title('RKHS-DA AND SLDARKHS-DA');
    axis( [0,110,50,100])  %确定x轴与y轴框图大小
    set(gca,'XTick',[0:10:110]) %x轴范围
    set(gca,'YTick',[50:10:100]) %y轴范围
    legend('RKHS-DA','SLDARKHS-DA','Location','SouthEast', 'FontName','Times New Roman','FontSize',8,'FontWeight','normal');   %右下角标注
    xlabel('Dimensionality of Subspace', 'FontName','Times New Roman','FontSize',11,'FontWeight','normal')  %x轴坐标描述
    ylabel('Accuracy (%)', 'FontName','Times New Roman','FontSize',11,'FontWeight','normal') %y轴坐标描述
    %2
    subplot(2,2,2)
    plot(Dim,TCA,'-*b',Dim,TCAs,'-or'); %线性,颜色,标记
    %title('TCA AND SLDA-TCA');
    axis( [0,110,50,100])  %确定x轴与y轴框图大小
    set(gca,'XTick',[0:10:110]) %x轴范围
    set(gca,'YTick',[50:10:100]) %y轴范围
    legend('TCA','SLDA-TCA','Location','SouthEast', 'FontName','Times New Roman','FontSize',8,'FontWeight','normal');   %右下角标注
    xlabel('Dimensionality of Subspace', 'FontName','Times New Roman','FontSize',11,'FontWeight','normal')  %x轴坐标描述
    ylabel('Accuracy (%)', 'FontName','Times New Roman','FontSize',11,'FontWeight','normal') %y轴坐标描述
    %3
    subplot(2,2,3)
    plot(Dim,IGLDA,'-*b',Dim,IGLDAs,'-or'); %线性,颜色,标记
    %title('IGLDA AND SLDA-IGLDA');
    axis( [0,110,50,100])  %确定x轴与y轴框图大小
    set(gca,'XTick',[0:10:110]) %x轴范围
    set(gca,'YTick',[50:10:100]) %y轴范围
    legend('IGLDA','SLDA-IGLDA','Location','SouthEast', 'FontName','Times New Roman','FontSize',8,'FontWeight','normal');   %右下角标注
    xlabel('Dimensionality of Subspace', 'FontName','Times New Roman','FontSize',11,'FontWeight','normal')  %x轴坐标描述
    ylabel('Accuracy (%)', 'FontName','Times New Roman','FontSize',11,'FontWeight','normal') %y轴坐标描述
    %4
    subplot(2,2,4)
    plot(Dim,TIT,'-*b',Dim,TITs,'-or'); %线性,颜色,标记
    %title('TIT AND SLDA-TIT');
    axis( [0,110,50,100])  %确定x轴与y轴框图大小
    set(gca,'XTick',[0:10:110]) %x轴范围
    set(gca,'YTick',[50:10:100]) %y轴范围
    legend('TIT','SLDA-TIT','Location','SouthEast', 'FontName','Times New Roman','FontSize',8,'FontWeight','normal');   %右下角标注
    xlabel('Dimensionality of Subspace', 'FontName','Times New Roman','FontSize',11,'FontWeight','normal')  %x轴坐标描述
    ylabel('Accuracy (%)', 'FontName','Times New Roman','FontSize',11,'FontWeight','normal') %y轴坐标描述
    

    图片示例(直接运行结果):
    在这里插入图片描述
    一些线型和颜色的设置参数:
    在这里插入图片描述
    在这里插入图片描述

    展开全文
  • 主要为大家详细介绍了python使用matplotlib模块绘制折线图、散点图的方法,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
  • matlab绘制折线图

    千次阅读 2022-02-16 17:52:36
    %绘制折线图 clear clc n = 12; x = 1:n; C = 10 * rand(n,1); A = 10 * rand(n,1); J = 10 * rand(n,1); figure; plot(x,C,'s-',x,A,'s-.',x,J,'s--'); legend('C','A','J'); 效果:
  • 5、在插入图表框中单击折线图,在这里折线的图样很,选择第二个图样为例,单击确定。6、第二个折线图样输入到文档中。WPS怎么插入数据的折线图1、新建一个excel文档,可以将它命名为自己想要的名称。2、双击打开...
  • python pyplot画多折线图

    千次阅读 2020-12-06 14:51:57
    #X轴标签 plt.ylabel("AUC") #Y轴标签 pyplot.yticks([0.70, 0.75,0.80,0.85,0.90,0.92]) pyplot.xticks([10, 20, 50, 100]) #plt.title("A simple plot") #标题 plt.savefig('Fig.png',dpi = 300) 效果
  • 用于计算机等领域论文实验数据的折线图绘制
  • Matplotlib中如何在 一画布中绘制折线图
  • php结合echarts画多个折线图

    千次阅读 2018-03-20 20:19:36
    echarts是百度出的一个画图工具基本上是js写出来的,对于php来生成一个折线图或者饼图这些数据可视化来说是相当的方便。在工作中也会常遇到数据可视化的东西,一些简单的图可以用echarts特别的方便。还有hcharts这种...
  • 由于不知道这样的标题是否能表达清楚我的意思,我再详细描述一下这几天遇到的问题:首先,想个折线图,但又不是普通的y=f(x)这样的图,而是由组数据组成。这几组数据中,有着不同的x和y坐标值——这似乎意味着...
  • Matplotlib入门-1-plt.plot( )绘制折线图

    千次阅读 2020-11-23 19:58:17
    在Python学堂1-8中,我们通过一实例(温湿度变化曲线对比分析图)对Matplotlib模块中的常用折线图进行了初步的认知学习。本章及后续几章内容是对前面内容的总结以及细化。系统性的带领大家共同学习Matplotlib中的...
  • 利用Chart控件显示一组或组数据。可以选择是直方图还是折线图,可设置为3D模式。只是一控件,集成后自己调用 接口传输数据,数据是数组形式存在。
  • matplotlib是Python中的一第三方库。主要用于开发2D图表,以渐进式、交互式的方式实现数据可视化,可以更直观的呈现数据,使数据更具说服力。 一、安装matplotlib pip install matplotlib -i ...
  • R语言ggplot2绘制折线图

    万次阅读 多人点赞 2020-10-22 22:12:28
    涉及ggplot2使用知识点:去掉背景色及网格线,保留坐标轴边框;设置显示中文字体;更改图例位置至内并添加边框线使图片更美观;设置坐标轴刻度值。除此之外,还有数据的融合处理。
  •  这里我利用的是matplotlib.pyplot.plot的工具来绘制折线图,这里先给出一段代码和结果图: 1.代码 # -*- coding: UTF-8 -*- import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt #...
  • 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...
  • 这篇文章利用的是matplotlib.pyplot.plot的工具来绘制折线图,这里先给出一段代码和结果图:# -*- coding: UTF-8 -*-import numpy as npimport matplotlib as mplimport matplotlib.pyplot as plt#这里导入你自己...
  • 本文给出Matlab绘制组数据折线图的代码,可以满足期刊论文发表的绘图要求。
  • matplotlib绘制折线图

    2020-12-23 02:19:46
    matplotlib绘制折线图 这阳春三月的邵大白在家过的什么日子,幽栖地僻经过少,花径不曾缘客扫~ 开逗b号纪念下这段闭关的时光=^=万一他以后就变成一数据分析的大v号了来~ 好了邵大白课堂开课了 折线图绘制 咱先...
  • # coding=gbk # 解决中文显示问题加上面一行注释!...# 更中文字体见:https://www.cnblogs.com/yimeishui/p/6198123.html matplotlib.rc("font",family='SimSun') X=[3, 4, 5, 6, 7, 8] stuY=
  • 用ggplot2绘制多维折线图

    千次阅读 2022-01-20 20:33:53
    最近工作遇到了需要大量绘制同种类型图片的重复性任务,用Excel着实伤不起,而且如果...我这里使用的是rgb函数,前三参数分别对应红绿蓝三颜色通道,maxColorValue 表示颜色通道取值范围的最大值,常取255。 ye =
  • 如何从Pandas数据帧绘制多个折线图

    千次阅读 2020-12-24 18:59:02
    我看不出旋转有什么帮助,因为最后你需要把你的数据分两次,一次是一周中的几天,它将被放入几子区,而城市又将有自己的颜色线。在这一点上,我们已经到了熊猫用它的绘图包装所能做的极限了。Matplotlib使用...
  • 本文用实例演示如何用d3.js实现实时刷新的折线图,非常具有实用价值,需要的朋友可以参考下。
  • 之前公司有绘制实时盈利率折线图的需求,实现的还不错,今天来分享下vue+echarts实现动态折线图的方法。 实现代码 <div id=myChart></div> [removed] import echarts from 'echarts' export default { name: ...

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 26,791
精华内容 10,716
关键字:

如何画多个折线图