Question: How to stack legends at bottom of a plot

WHen plotting f(x) and g(x) on same plot, and putting legend at bottom (default), the legends show horizontally. i.e. f(x) then g(x) on same line.

I'd like the legend to be stacked vertically, just like when the legend on the right or left, But keep it at bottom. But want to do all this in code. Not using any UI context tools or mouse.

Here is an example

restart;

f:=x->x^3-x^2+1;
g:=x->6-2*x-x^2;
the_legend:=[typeset("f(x) = ",f(x)),typeset("g(x) = ",g(x))]:
plots[setoptions](font=[TIMES,16], labelfont=[TIMES,18]):
the_title:="Plot of f(x) and g(x)":
plot([f(x),g(x)],x=-5..5,
     'gridlines',
     'color'=['red','blue'],
     'legend'=the_legend,
     'legendstyle'=['location'='bottom'],
     'axes'='normal',
     'title'=the_title,  
     'scaling'='unconstrained');

proc (x) options operator, arrow; x^3-x^2+1 end proc

proc (x) options operator, arrow; 6-2*x-x^2 end proc

#I want the above legend to be stacked vertically like the
#following one, but keep it at bottom

plot([f(x),g(x)],x=-5..5,
     'gridlines',
     'color'=['red','blue'],
     'legend'=the_legend,
     'legendstyle'=['location'='right'],
     'axes'='normal',
     'title'=the_title,  
     'scaling'='unconstrained');

 

 

Download legend_question.mw

Please Wait...