How to set the origin to O and remove the zero lab

2019-07-25 02:44发布

问题:

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?

回答1:

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

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