Place an equation on a Plot?

I want to place the equation on the plot. I make macros so it is easier to create plots. In this case y=x^3, with domain between [-5,5], and range between [-25, 25] The below script allows the user to enter the function and domain and range, and have the graph be generated automatically. This is just a small portion of the whole script.

The question is how to add a text version of the equation to the graph, and still use this template structure. I was able to do it with version 6, but not with version 7.

xL = -5
xR = 5

yT = 25

yB = -25

t = x^3

pp = Plot[Evaluate[t], {x, xL, xR}]

This is the complete script

clear[GraphSize]
clear[Tg]
clear[Te]
clear[Wg]
clear[We]
clear[Shifte]
clear[Sidee]
clear[xL]
clear[xR]
clear[yT]
clear[yB]
clear[t]
Null
Null
Null
Null
Null
Null
Null
Null
Null
Null
Null
Null
Null

GraphSize = 185
Tg = 6
Te = 6
Wg = Bold
We = Bold
Shifte = 0
Sidee = -1

Tope = 1

xL = -5`
xR = 5`
yT = 25
yB = -25

t = x^3

pp = Plot[Evaluate[t], {x, xL, xR}, 
   BaseStyle -> {FontSize -> Tg, FontWeight -> Wg}, 
   ImageSize -> {GraphSize, Automatic}, AspectRatio -> 1/1,  
   Ticks -> {{xL, xL + (xR - xL)/10, xL + 2 (xR - xL)/10, 
      xL + 3 (xR - xL)/10, xL + 4 (xR - xL)/10, xL + 5 (xR - xL)/10, 
      xL + 6 (xR - xL)/10, xL + 6 (xR - xL)/10, xL + 7 (xR - xL)/10, 
      xL + 8 (xR - xL)/10, xL + 9 (xR - xL)/10, xR}, {yB, 
      yB + (yT - yB)/10, yB + 2 (yT - yB)/10, yB + 3 (yT - yB)/10, 
      yB + 4 (yT - yB)/10, yB (yT - yB)/10, yB + 6 (yT - yB)/10, 
      yB + 7 (yT - yB)/10, yB + 8 (yT - yB)/10, yB (yT - yB)/10, yT}},
    GridLines -> {{xL, xL + (xR - xL)/10, xL + 2 (xR - xL)/10, 
      xL + 3 (xR - xL)/10, xL + 4 (xR - xL)/10, xL + 5 (xR - xL)/10, 
      xL + 6 (xR - xL)/10, xL + 6 (xR - xL)/10, xL + 7 (xR - xL)/10, 
      xL + 8 (xR - xL)/10, xL + 9 (xR - xL)/10, xR}, {yB - yB/100, 
      yB + (yT - yB)/10, yB + 2 (yT - yB)/10, yB + 3 (yT - yB)/10, 
      yB + 4 (yT - yB)/10, yB + 5 (yT - yB)/10, yB + 6 (yT - yB)/10, 
      yB + 7 (yT - yB)/10, yB + 8 (yT - yB)/10, yB + 9 (yT - yB)/10, 
      yT}},  GridLinesStyle -> Directive[Gray, Thin], 
   AxesStyle -> Arrowheads[{-0.05, 0.05}],  AxesLabel -> {"x", "y"}, 
   AxesOrigin -> {0, 0}, PlotRange -> {yB, yT}, 
   PlotStyle -> RGBColor[1, 0, 1]] /. 
  Line[x_] -> {Arrowheads[{-.05, .05}], Arrow[x]}
Export["F:\\OneEquation.eps", pp, "EPSTIFF"]

Here are a few ways:

Plot[t^3, {t, -5, 5}, Epilog -> Text[t^3, {3, 40}]]
Plot[Callout[t^3, t^3], {t, -5, 5}]
Plot[Legended[t^3, t^3], {t, -5, 5}]
Plot[t^3, {t, -5, 5}, PlotLabel -> t^3]

Try this one

Plot[t^3 && -25 <= t^3 <= 25, {t, -5, 5}]

The function is y=x^3, not t^3.

Your reply does not put the equation on the graph

The equation is y=x^3

Plot[t^3, {t, -5, 5}, Epilog β†’ Text[t^3, {3, 40}]]

Does put t^3 on the graph, but does not put y=x^3 on the graph, and does not use the variable and table format.

Please avoid making multiple comments of the same meaning and please do invest some work into this yourself. You can easily modify the code for what you need:

Plot[t^3, {t, -5, 5}, Epilog -> Text[y == x^3, {3, 40}]]

Please also read forum rules and format code correctly: http://wolfr.am/READ-1ST

This is the original script

xL = -5
xR = 5

yT = 25

yB = -25

t = x^3

pp = Plot[Evaluate[t], {x, xL, xR}]

Your answer does not use variables. I know how to put the equation on the graph without using the variables, and I know how to do it using version 6.

@Peter Munro. please learn to format code properly on this forum: http://wolfr.am/READ-1ST

You keep posting non-formatted code.

Hi

Al code I post can be copied and pasted into version 7 and run

Plot[t^3 && -25 <= t^3 <= 25, {t, -5, 5}
, Epilog β†’ Text[y == x^3, {3.2, 15}]
]

How does your answer relate to

xL = -5
xR = 5

yT = 25

yB = -25

t = x^3

pp = Plot[Evaluate[t], {x, xL, xR}]

Dear, @Peter Munro, you did not format code properly again as we asked you. It should be syntax-highlighted and framed, for example:

pp = Plot[Evaluate[t], {x, xL, xR}]

Please learn to format code properly on this forum: http://wolfr.am/READ-1ST

I am a bit confused, The Callout suggested by Gianluca seems to be what you requested – just change the variable slightly:

Plot[Callout[t, t], {x, xL, xR}]

or, with formatting

Plot[Callout[t, Style[t, Red, Medium]], {x, xL, xR}]

This gives the plot:

You can experiment with different formats, etc. (I would suggest that you try a variety before reposting).
[1]: http://community.wolfram.com//c/portal/getImageAttachment?filename=Plot.png&userId=599067

Now we are getting somewhere, but the question is how to put the equation on the graph. The equation would be either y=x^3 or y=x^3.

I think the misunderstanding is that an expression like t = x^3 is not an equation – it is an assignment – t is assigned the value of x^3. If you want the equation you must enter y == x^3 or if you already defined t, y == t. To put your expression on the plot in an equation form you need to do something like this:

eqn = y == t

Which assigns the equation y == t (which evaluates to y == x^3) to the variable, eqn.

Then plot it with

Plot[Callout[t, Style[eqn, Red, Medium]], {x, xL, xR}]

to get

If you insist on having = instead of ==, you can do it with HoldForm:

Plot[Callout[t, Style[HoldForm[y = t^3], Red, Medium]], {x, xL, xR}]

This is what I want, but Callout does not work with version 7, so I opted for PlotLabel for now. Later I will want to know how to use something like Legended command for graphing translations. In that case, I would want to have a have a legend to show the progression of translations from y=sinx to y=2sinx to y=2sin3x to y=2sin[3(x+pi/4)] to y=2sin[3(x+pi/4)]+1 This is for the eTutoring.com project. see http://www.etutoring.com/Free_Videos.php I need youtube subscribers, and/or donations. I am not making videos for a while while my right arm recovers from an injury. I have also added an image of the more detailed plot

xL = -5 

xR = 5

yT = 25

yB = -25

t = x^3

eqn = y == t

pp = Plot[t, {x, xL, xR}, PlotLabel -> eqn]

I have been using PlotLegend, but have had some difficulty adding the y= part. Do you know how to do that? Using the method for one equation did not work for multiple equations. I want to have a legend for translations.

clear[t]
clear[t1]
clear[t2]
clear[parenteqn]
clear[eqn1]
clear[eqn2]
clear[y]

t = x^3
t1 = (2 x)^3
t2 = 3 (2 x)^3
parenteqn = t
eqn1 = t1
eqn2 = t2

Plot[{t, t1, t2}, {x, -2, 2}, PlotLegend -> {parenteqn, eqn1, eqn2}, 
 LegendPosition -> {1, -.4}, LegendShadow -> None]

Peter,

Gianluca is correct. you keep using = instead of ==. if you want an expression like y = x^3 to print on the plot you MUST type it as y ==x^3 (Note there are two equal signs here!!!)

You need one small change to your posted code:

t = x^3
t1 = (2 x)^3
t2 = 3 (2 x)^3
parenteqn = y == t
eqn1 = y == t1
eqn2 = y == t2

Your plot command will now work as expected (in Version 7 – I can’t run it with my newer version).

Just so you understand, the expression:

parenteqn = y == t

means β€œdefine parenteqn to be the equation y == x^3” – the β€œt” gets substituted. This will now put β€œy=x^3” where you want it in the legend.