虚线的千里马情节

时间:2018-12-14 14:55:49

标签: plot maxima

我们如何绘制具有不同线条样式的最大值(例如破折号,破折点等),而不仅仅是改变线条的颜色)。 最小的工作示例:

f(x) := sin(x) $
g(x) := cos(x) $
plot2d( [f(x), g(x)], [x,0,10], 
        [style, [lines, 1,4], [lines, 1,3]] )$

以上可能可以通过style的{​​{1}}选项来完成。但是,我找不到正确的选项。

2 个答案:

答案 0 :(得分:4)

一种方法是在gnuplot_preamble中设置线型。

f(x) := sin(x) $
g(x) := cos(x) $

p: "set linetype 1 dashtype '-'
    set linetype 2 dashtype '.'" $

plot2d(
  [f('x), g('x)], ['x, 0, 10],
  ['gnuplot_preamble, p],
  ['style, ['lines, 4, 4], ['lines, 4, 3]])$

enter image description here

答案 1 :(得分:3)

您也可以 使用draw而不是plot。示例:

f(x) := sin(x) $
g(x) := cos(x) $ 
draw2d(line_type=dashes, explicit(f(x),x,0,10), color=red, explicit(g(x),x,0,10));

在帮助中查找drawline_type