Group Abstract Group Abstract

Message Boards Message Boards

Label curves on the graph with their mathematical expression?

Posted 9 years ago
POSTED BY: Brandon Davis
4 Replies
Posted 9 years ago
POSTED BY: Hans Milton
Posted 9 years ago

Gianluca, I got the impression that the original poster wants the curves to be labeld by the functions itself. Not just "function" and "derivative". So this a simple variation of your solution:

var = Input["Type a variable, such as x, in this window."];
expr = Input[
   "Type an expression to be differentiated in the variable you just typed in the last window."];
g[blah_] = expr /. {var -> blah};
derivatives := {Callout[g[var], g[var], Above], Callout[g'[var], g'[var], Above]};
Plot[
    Evaluate@derivatives, {x, -3, 5},
    PlotLabel -> "A function and its Derivative", PlotRange -> 20
 ]

enter image description here

I increased the plot range, so as not to crowd the function labels

Callout documentation

POSTED BY: Hans Milton

If you have Mathematica 11 you can try Callout:

var = Input["Type a variable, such as x, in this window."];
expr = Input[
   "Type an expression to be differentiated in the variable you just \
typed in the last window."];
g[blah_] = expr /. {var -> blah};
derivatives := {Callout[g[var], "function"], 
  Callout[g'[var], "derivative"]}
Plot[Evaluate@derivatives, {x, -3, 5}, 
 PlotLabel -> "A function and its Derivative", PlotRange -> 10]

You may consider Tooltip and Legended too.

POSTED BY: Gianluca Gorni
Posted 9 years ago

Ok good news. I figured out PlotRange.. I changed it to:

PlotRange -> {-10,10}

I knew it was something easy..Now what about these damn labels on the actual curves??

I do see I use "PlotLabels" twice...For my actual title of the plot output, should I be using a different command to label the cur

POSTED BY: Brandon Davis
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard