3

How can we plot in maxima with different line styles (for example dash, dash-dot, etc. and not just change the color of the lines). Minimal working example:

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

The above can probably be done with the style option of plot2d. However, I cannot find the right option.

ASarkar
  • 469
  • 5
  • 16

2 Answers2

5

One way is to set linetype in 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

slitvinov
  • 5,693
  • 20
  • 31
3

You may also use draw, instead of plot. Example:

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));

look for draw, and line_type, in the help

  • 1
    I think this also answers my question. However, I can only select one answer as "accepted answer". I would also like to point out (for future SO users) that the draw2d command works after the command `load(draw)$` has been used. – ASarkar Dec 17 '18 at 04:33
  • @ASarkar, it is enough to know that it helps, I don't care much abouts points :-) Thank you, for the note on `load(draw)`, though I do not need to issue that command, it looks like it is needed in some cases (I am running 5.40.0 over Linux) – Rolazaro Azeveires Dec 28 '18 at 21:43