:

## Labels on Plot and Along Axis: Workarounds, Sort Of

Maple 17

I'm sharing this in the hope it might help someone (my future self being the most likely). Since my suggestions are not perfect and a little messy, feel free to suggest better ways.

I spend a great deal of time tweaking my plots. Oftentimes I want to add labels to the curves right onto the plot. Most of the time it's easy to do. Occasionally I struggle. Sometimes I succeed, sometimes I give up.

Below is an example of the kind of plot I sometimes create. It's not perfect.

What I did was to create a list of curves a corresponding list of labels to print near the curves and a list of x- and y-coordinates to position the labels.

fLst := [seq(f(x,i),i=iMin..iMax,step)]: # List of functions to be plotted
fInd := i -> ListTools:-Search(f(x,i),fLst): # Returns the position in list given value of exponent i
fLab := [seq(x^i,i=iMin..iMax,step)]: # List of text labels

pTxt := seq( plots:-textplot([xPos,yPos(i),'typeset'('f', " = ", fLab[fInd(i)])], 'align'={'above','right'}),i=iMin..iMax,step): # Text Labels

p1 := plots:-display( [ pLst, pTxt ]
, 'labels' = [ x, "" ]
, 'view' = [ xMin .. 1.1*xMax, fMin .. fMax ]
, 'title' = "Text labels: x-axis too cluttered"
) : p1 ;

As you can see from the code snippet, I had a bit of a struggle with the values of the exponents and the position in the corresponding list, which I solved with ListTools:-Search. Surely, there's an easier way, but it works fine.

I'm not too happy with the x-axis labels though, I find them too cluttered.

A quick and easy workaround is to ask Maple to print fewer labels, here 4:

plots:-display( p1, 'tickmarks' = [ 4, default ] );

This is easy to do, but the number 0.000005 is not easy to read: I'd rather see powers of 10 notation: 5*10^(-6).

So I created my own x-axis labels.

xticks := [seq(op([10^(-i)=10^convert(-i,name),5*10^(-i)=5.*10^convert(-i,name)]),i=6..1,-1)]:
plots:-display( p1, 'tickmarks' = [ xticks, default ] );

This third plot is better, but the format along the x-axis is different from the one along the y-axis, which was produced automatically by Maple. The difference is that the y-axis labels have a multiplication sign (an x) just before the power of 10, which the x-axis doesn't have. It would be better to either create a multiplication sign for the x-axis labels or to remove it along the y-axis labels.  Either way would be fine.

There may be a way to create exponent-style labels along the x-axis in the same style as the y-axis by telling Maple to create them, just as we can ask for piticks (labels written as multiples of Pi), but I couldn't work it out and my time ran out. Still, while currently imperfect, I thought I'd share these things on Mapleprimes, since it's unlikely I'll spend much more time digging for improvements.

complete worksheet:

﻿