Search code examples
plotgnuplotcurve

Trace a curve with two colors?


is there a way to have a curve with two colors, well i have many curves in my plot. But I like to add a specific characteristic, i want the curve 1 to be simple line in[a,b] interval, and dotted line in interval [b,c].

an example of my graph:

plot exp(-x**2 / 2), sin(x)

can we make sin(x) plotted in dotted line from[0,5]

thanks in advance.


Solution

  • You can specify the line type on a certain interval with the linetype keyword to the plot command. I don't think there is a way to make linetype a function of interval without doing it manually. For example:

    plot exp(-x**2/2), [0:5] sin(x) lt 1 lc rgb 'green', [5:] sin(x) lt 2 lc rgb 'green'
    

    gives

    enter image description here