gnuplot行类型不希望被更改

Mat*_*ato 5 linux debian gnuplot

你能帮我吗?我希望将一行类型更改为点线.我使用这些命令:

gnuplot> set terminal png size 750,210 nocrop butt font "/usr/share/fonts/truetype/ttf-liberation/LiberationSans-Regular.ttf" 8
gnuplot> set output "/root/data.png"
gnuplot> set xdata time
gnuplot> set timefmt "%Y-%m-%d"
gnuplot> set format x "%b %d"
gnuplot> set ylabel "item1"
gnuplot> set y2label "item2"
gnuplot> set y2tics
gnuplot> set datafile separator "|"
gnuplot> plot "/root/results.txt" using 1:2 title "item1" w lines lt 4, "/root/results.txt" using 1:3 title "item2" with lines
Run Code Online (Sandbox Code Playgroud)

但我总是得到洋红色线.我使用了版本4.6 patchlevel 0.感谢您的回复.

Chr*_*oph 5

有几种方法可以使用set命令更改线条颜色:

  1. 定义线条样式:

    set style line 1 linetype 1 linecolor 7
    set style line 2 linetype 1 linecolor rgb "#dd7700"
    plot x linestyle 1, x**2 linestyle 2
    
    Run Code Online (Sandbox Code Playgroud)

    您必须明确指定使用哪种线型。

  2. 选择和增加了线的风格,而不是线类型,如果没有指定为:

    set style line 1 linetype 1 linecolor 7
    set style line 2 linetype 1 linecolor rgb "#dd7700"
    set style increment user
    plot x, x**2
    
    Run Code Online (Sandbox Code Playgroud)
  3. 重新定义默认线类型(在4.6.0版本中引入的):

    set linetype 1 linecolor 7
    set linetype 2 linetype 1 linecolor rgb "magenta"
    plot x, x**2
    
    Run Code Online (Sandbox Code Playgroud)

    请注意,与线条样式不同,重新定义 byset linetype是持久的;他们不受reset. 要重置它们,您必须使用set linetype 1 default.

所以一个最小的绘图脚本可能如下所示:

reset
set terminal pngcairo dashed monochrome
set output "/root/data.png"
set xdata time
set timefmt "%Y-%m-%d"
set format x "%b %d"
set datafile separator "|"
set style data lines

plot "/root/results.txt" using 1:2 linetype 1, "" using 1:3 linetype 3
Run Code Online (Sandbox Code Playgroud)