GNUplot循环 - 最好的方法吗?

时间:2014-01-05 02:10:41

标签: python gnuplot

我有一个名为tmptwo的字典,如下所示:

{'test-test': [['2014-01-05 01:06:11', 37, 34, 0], ['2014-01-05 01:09:20', 44, 32, 11]], 'another-test': [['2014-01-05 01:06:11', 88, 76, 6], ['2014-01-05 01:09:20', 62, 9, 3]]}

我试图通过stdin将这些数据传输到GNUplot。但是我正在努力编写循环来做到这一点。

我必须按以下顺序绘图:

  1. 第一个列表的时间戳,后跟关键'test-test'的三个整数之一
  2. 第一个列表的时间戳,后跟关键字'another-test'的三个整数之一
  3. 与1.相同,但下一个列表
  4. 与2.一样,但下一个列表
  5. 当然这里只有两个键,所以很容易用4个步骤解释这个特定例子的算法。但是在我的实际脚本中,字典将具有多个键和多个列表(尽管所有键在其各自的值对中具有相同数量的列表)在键的值(其本身是列表)内。你跟着吗?

    我知道可能有一种更简单的方式来输入数据,但这就是我正在使用的...

    到目前为止,我将这些数据输入GNUplot的功能如下:

    def startPlotting(selection, gnuplot, tmptwo):
        try:        
            if selection == 'totals':
                sel = 1
            if selection == 'usable':
                sel = 2
            if selection == 'inserted':
                sel = 3
    
    
            for items in zip(*tmptwo.values()):
                for item in items:
                    gnuplot.stdin.write("%s,%i\n" % (item[0],item[sel]))
                gnuplot.stdin.write("e\n")
            gnuplot.stdin.write("reset\n")
            gnuplot.stdin.flush()
    
        except (IOError, TypeError, NameError) as e:
            raise
    

    到目前为止,我没有快乐。你能帮忙吗?

    编辑:

    根据下面的建议更新了代码中的循环,但GNUplot仍然出错。我显然无法找到解决方案......有什么建议吗?

0 个答案:

没有答案
相关问题