Search code examples
gnuplotdrawlabelaxis-labelsmaxima

How to set the origin to O and remove the zero labels in Maxima draw?


The draw (2d) function in Maxima has several settings to control the axis, but as far as I can tell, none that hides the zero label of the xy-axis and to replace it with either a 0 or a O.

Maybe that's possible to use with the option user_preamble?


Solution

  • You will need to set the xtics and ytics values explicitly, omitting the origin, and use label to label the origin.

    load(draw)$
    draw2d( user_preamble="set zeroaxis linetype 5; set xtics axis;
       set ytics axis; set border 0;", 
       xtics={-3, -2, -1, 1, 2, 3},
       ytics={-1, -1/2, 1/2, 1},
       label(["O", 0, 0]),
       explicit(sin(x),x,-%pi, %pi))$
    

    enter image description here

    You can tweak the label coordinates if you don't want the origin label to appear right at the intersection in my example above. Replacing label(["O",0,0]) with label(["O", -0.15, 0.1]) gives

    enter image description here