zoukankan      html  css  js  c++  java
  • Gnuplotlinux下的画图工具

    Gnuplot 是一种免费的绘图工具,可以移植到各种主流平台。它可以下列两种模式之一进行操作:当需要调整和修饰图表使其正常显示时,通过在 gnuplot 提示符中发出命令,可以在交互模式下操作该工具。或者,gnuplot 可以从文件中读取命令,以批处理模式生成图表。
    在shell中敲打"gnuplot", 进入到gnuplot编辑环境里
    初级基础命令:
    1. set terminal  postscript
    设置终端
    2. set xlabel 'x-date'
    x坐标轴的名字为"x-date"
    3. set title "demo"
    该图的名字为"demo"
    4. set key top left
        set key box
    设置图例的位置和形状
    5. set output '/test/aa.ps'
    设置图片保存到的文件目录
    6. set xdata time
    set timefmt "%H:%M:%S"
    set format x "%H:%M:%S"
    设置x坐标轴数据的格式
    7.plot ["17:39:31":"17:50:48"] '/var/log/dns.log' using 1:2 title "test" with lines linetype 1
    画图, x坐标起点是"17:39:31", 终点是"17:50:48", 源文件为'/var/log/dns.log' , 使用该文件的第一列和第二列数据作图,画直线图

    8. 例子:
    set xlabel 'x-time'
    set ylabel 'y-%'
    set mxtics 1
    set title "cpu data analysis"
    set key top left
    set key box
    set term post eps color solid enh
    set output '/export/home/nancy/cpu.eps'
    set xdata time
    set timefmt "%H:%M:%S"
    set format x "%H:%M:%S"
     plot  ["17:39:31":"17:50:48"] '/export/home/nancy/cpu' using 1:2 title "usr" with line
    s linecolor rgb "yellow", '/export/home/nancy/cpu' using 1:3 title "sys" with line linecolor r
    gb "red" , '/export/home/nancy/cpu' using 1:4 title "w" with line linecolor rgb "blue", '/expo
    rt/home/nancy/cpu' using 1:5 title "idle" with line linecolor rgb "green"


    9. 写成脚本直接运行
    把8中的命令写到*.plt文件里, 可以gnuplot>load ‘a.plt’, 若只想生成ps或eps文件, 则可以直接在shell下运行gnuplot a.plt

    10. ps和eps
    ps:生成pft文件
    eps:可以直接插入到word/execel 文件中.

    11. 目前还有个小问题没有解决---已解决,更新例子(8)
    当我在一个图中画多条线时, 如何使用不同的颜色来加以区分


    12. 有用的文章
    http://www.ibm.com/developerworks/cn/linux/l-gnuplot/index.html
    http://cycloid.blog.163.com/blog/static/8847862006823102056295/

    http://dsec.pku.edu.cn/dsectest/dsec_cn/gnuplot/ (gnuplot 中文手册)
  • 相关阅读:
    cocos2d-x3.0 SpriteFrameCache
    POJ 2417 Discrete Logging 离散对数
    C++Vector使用方法
    UML时序图
    7个最好的免费杀毒软件下载
    iOS_17_控制开关_TabBarController_由storyboard道路
    里氏替换原则
    笔试题&面试题:输入一个维度,逆时针打印出一个指定矩阵
    __weak如何实现目标值自己主动设置nil的
    静态构造函数实际运行多少次?
  • 原文地址:https://www.cnblogs.com/morebetter/p/1086485.html
Copyright © 2011-2022 走看看