gnuplot:错误的列标题?

时间:2016-06-10 11:49:21

标签: gnuplot

我在Linux上使用GNUPLOT 4.6,代码如下:

set datafile separator ","  
set style data linespoint  
set xdata time;set timefmt "%Y/%m/%d %H:%M";set autoscale  
plot 'PHY_Long_CHA_CMPK.csv' every ::7 using 2:3 title columnheader(3),\
     'PHY_Long_CHA_CMPK.csv' every ::7 using 2:4 title columnheader(4),\
     'PHY_Long_CHA_CMPK.csv' every ::7 using 2:5 title columnheader(5),\  
pause -1

我没有得到正确的列标题,(第一,第二,第三),只是filename.csv。 有人能帮帮我吗? 我不应该更改文件filename.csv的数据。所以我正在尝试使用GNUPLOT函数......

filename.csv示例:

filename.csv  
Serial number  
From : 2015/12/09 13:15  
To   : 2016/06/09 23:30  
sampling rate : 15  

No.,"time","First","Second","Third"  
1,"2015/12/09 13:30",0,0,0  
2,"2015/12/09 13:45",0,0,0  
3,"2015/12/09 14:00",0,0,0  
4,"2015/12/09 14:15",0,0,0

2 个答案:

答案 0 :(得分:2)

因为现在,所有列标题都是" filename.csv" ;-)你必须评论评论行......

    ALTER FUNCTION [dbo].[fnRecursiveSplitString] (
    @input VARCHAR(255)
    ,@Delimeter1 CHAR(1)
    ,@Delimeter2 CHAR(1)
    )
RETURNS TABLE
AS
RETURN (
        WITH CTE1 AS (
                SELECT substring(@input, 0, charindex(@Delimeter1, @input)) field
                    ,substring(@input, charindex(@Delimeter1, @input) + 1, (charindex(@Delimeter2, @input) - charindex(@Delimeter1, @input)) - 1) item
                    ,CAST(STUFF(@input, 1, charindex(@Delimeter2, @input), '') AS VARCHAR(255)) INPUT
                    ,1 RN

                UNION ALL

                SELECT CASE 
                        WHEN LEN(INPUT) > 0
                            THEN CASE 
                                    WHEN charindex(@Delimeter2, INPUT) > 0
                                        THEN substring(substring(INPUT, 0, charindex(@Delimeter1, INPUT)), 0, charindex(@Delimeter2, INPUT))
                                    ELSE substring(INPUT, 0, charindex(@Delimeter1, INPUT))
                                    END
                        END
                    ,CASE 
                        WHEN LEN(INPUT) > 0
                            THEN substring(INPUT, charindex(@Delimeter1, INPUT) + 1, CASE 
                                        WHEN charindex(@Delimeter2, INPUT) > 0
                                            THEN (charindex(@Delimeter2, @input) - charindex(@Delimeter1, @input)) - 1
                                        ELSE LEN(INPUT)
                                        END)
                        END
                    ,CASE 
                        WHEN LEN(INPUT) > 0
                            THEN CAST(STUFF(INPUT, 1, CASE 
                                            WHEN charindex(@Delimeter2, INPUT) > 0
                                                THEN charindex(@Delimeter2, INPUT)
                                            ELSE LEN(INPUT)
                                            END, '') AS VARCHAR(255))
                        END
                    ,RN + 1
                FROM cte1
                WHERE len(INPUT) > 0
                )
        SELECT rn RowNum
            ,field
            ,item
        FROM CTE1
        )

不应该使用' ,\ '在最后的绘图线。

答案 1 :(得分:2)

您的列标题实际上是filename.csv,因为它是您文件中的第一行。 every ::7没有做你期望它做的事情,也就是说,跳过前7行。它的作用是跳过前7个数据条目。如果您想跳过标题,可以使用评论符号#或管道输入,删除awk的前几行:

set datafile separator ","  
set style data linespoint  
set xdata time;set timefmt "%Y/%m/%d %H:%M";set autoscale  
plot "< awk '(NR > 6){print $0}' PHY_Long_CHA_CMPK.csv" using 2:3 title columnheader(3),\
     "< awk '(NR > 6){print $0}' PHY_Long_CHA_CMPK.csv" using 2:4 title columnheader(4),\
     "< awk '(NR > 6){print $0}' PHY_Long_CHA_CMPK.csv" using 2:5 title columnheader(5)
pause -1