【问题标题】:Gnuplot line typesGnuplot 线型
【发布时间】:2013-10-25 02:19:16
【问题描述】:

如何在 gnuplot 上绘制不同类型的线条?我要画不同的颜色。我的脚本加入了几个文件,我认为这就是为什么这些行不是破折号的原因。四个中只有两个是虚线。 谢谢 费利佩

#!/usr/bin/gnuplot

set grid
set title 'Estado dos arquivos no BTRIM com peers de comportamento condicionado'
set xlabel 'Tempo discreto'
set ylabel 'Quantidade de arquivos'
set style line 1 lc rgb '#0060ad' lt 1 lw 2 pi -1 ps 1.0
set style line 2 lc rgb '#dd181f' lt 9 lw 2 pi -1 ps 1.0
set style line 3 lc rgb '#29c524' lt 6 lw 2 pi -1 ps 1.0
set style line 4 lc rgb '#7D72F9' lt 7 lw 2 pi -1 ps 1.0
set style line 5 lc rgb '#000000' lt 8 lw 2 pi -1 ps 1.0

set termoption dashed
#set pointintervalbox 0
#set boxwidth 0.1
#set style fill solid

plot '<paste ../00/StatisticNormal.txt ../01/StatisticNormal.txt ../02/StatisticNormal.txt  ../03/StatisticNormal.txt ../04/StatisticNormal.txt ../05/StatisticNormal.txt ../06/StatisticNormal.txt ../07/StatisticNormal.txt ../08/StatisticNormal.txt ../09/StatisticNormal.txt' smooth unique with line ls 1 title 'Normais', \
'<paste ../00/StatisticVogue.txt ../01/StatisticVogue.txt ../02/StatisticVogue.txt ../03/StatisticVogue.txt ../04/StatisticVogue.txt ../05/StatisticVogue.txt ../06/StatisticVogue.txt ../07/StatisticVogue.txt ../08/StatisticVogue.txt ../09/StatisticVogue.txt' smooth unique with line ls 2 title 'na Moda', \
'<paste ../00/StatisticPopular.txt ../01/StatisticPopular.txt ../02/StatisticPopular.txt ../03/StatisticPopular.txt ../04/StatisticPopular.txt ../05/StatisticPopular.txt ../06/StatisticPopular.txt ../07/StatisticPopular.txt ../08/StatisticPopular.txt ../09/StatisticPopular.txt' smooth unique with line ls 3 title 'Populares', \
'<paste ../00/StatisticRarity.txt ../01/StatisticRarity.txt ../02/StatisticRarity.txt ../03/StatisticRarity.txt ../04/StatisticRarity.txt ../05/StatisticRarity.txt ../06/StatisticRarity.txt ../07/StatisticRarity.txt ../08/StatisticRarity.txt ../09/StatisticRarity.txt' smooth unique with line ls 4 title 'Raros'

pause -1

【问题讨论】:

  • 那是您的解决方案吗?如果在线型定义中使用lclt 部分仅用于选择虚线类型。这取决于终端。要查看支持的破折号类型以及它们关联的线型,只需使用test 命令,例如set terminal pngcairo dashed; set output 'test.png'; test; set output 或与任何其他终端类型类似。

标签: gnuplot


【解决方案1】:

直到版本 4.6

linestyle 的破折号类型由linetype 给出,它也会选择线条颜色,除非您使用linecolor 明确设置另一种颜色。

但是,对虚线的支持取决于所选的终端:

  1. 有些终端不支持虚线,比如png(使用libgd
  2. 其他终端,如pngcairo,支持虚线,但默认禁用。要启用它,请使用 set termoption dashedset terminal pngcairo dashed ...
  3. 终端之间的确切破折号模式不同。要查看定义的linetype,请使用test 命令:

跑步

set terminal pngcairo dashed
set output 'test.png'
test
set output

给予:

postscript 终端显示不同的破折号模式:

set terminal postscript eps color colortext
set output 'test.eps'
test
set output

5.0 版

从 5.0 版开始,引入了以下与线型、虚线图案和线条颜色相关的更改:

  • 引入了新的dashtype 参数:

    要获得预定义的破折号模式,请使用例如

    plot x dashtype 2
    

    您还可以指定自定义破折号模式,例如

    plot x dashtype (3,5,10,5),\
         2*x dashtype '.-_'
    
  • 终端选项 dashedsolid 被忽略。默认情况下,所有线条都是实心的。要将它们更改为虚线,请使用例如

    set for [i=1:8] linetype i dashtype i
    
  • 默认的线条颜色集已更改。您可以使用set colorsequence default|podo|classic 在三种不同的颜色集之间进行选择:

【讨论】:

  • 这篇文章很有用
  • @Phonon 你可以定义更多的线型然后使用set linetype cycle 20
  • 谢谢,但是如何定义更多的线型?
  • set linetype 10 lc rgb '#4488bb' dt (5, 5, 10, 10), set linetype 11 ... 等等
  • 在此处将虚线添加到 termtype x11 gnuplot 4.6 的链接:lists.gnu.org/archive/html/octave-maintainers/2012-12/… 遵循此操作后,我在 termtype x11 测试中看到了虚线。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多