This post is to help anyone who is just as frustrated about typesetting in plots
as I was before I solved my problem. (Note: the technique works with the version

2020 and newer and may work with earlier versions.)


Why? Because there is no obvious help in Maple showing what works. (And if folks

can improve what I have posted,  please do so. At least when someone executes

a search for this type of problem, they might see the best approach.)

Goal: typeset a name of a function in any text of a plot.

Approach: According to help, '?plot, typesetting',  one should use the
option(procedure?) typeset.   For example:

"restart;   plots:-setoptions(size = [400, 200]):    `f__1`(x) :=cos(x)*(e)^(-(x^(2))/(4)) :    p1 := plot(`f__1`(x), x = -5..5,                         legend = typeset("function ", `f__1`(x) )  );"



However, what I want in the legend is the expression "`f__1`(x),"not the evaluated

expression. Entering the name with single quotes around the expression leads to this:


p1 := plot(f__1(x), x = -5 .. 5, legend = typeset("function ", 'f__1(x)'))



which is great, except that when I wish to redisplay the plot




the expression f__1(x)is evaluated.


According to the code completion capability of Maple, the procedure

"Typesetting:-Typeset" exists, and it does not evaluate the function:


p1 := plot(f__1(x), x = -5 .. 5, legend = Typesetting:-Typeset(f__1(x))); plots:-display(p1)



except there is no help regarding this procedure.


It appears that the procedure operates only on one item.


Solution: Hence, the ultimate solution for my problem is to still use the typeset 

option, but Typeset any expression.


p1 := plot(f__1(x), x = -5 .. 5, legend = typeset("function ", Typesetting:-Typeset(f__1(x)))); plots:-display(p1)



Again, if you can contribute to this post, I would appreciate it.



Please Wait...