# How to plot 2D plot against two functions [closed]

I need to Plot two functions one is on x-axis and second on y-axis, both function have common variable $x$. The two functions are

myfunction1[{al_, be_, ga_}] := (al*be)/2 Cos[x]
(Sec[x/2])^2 (Tan[x/2])^-(be + 1) (1 + ga (Tan[x/2])^-be)^(-(al/ga) - 1)
myfunction2[{al_, be_, ga_}] := (al*be)/2 Sin[x] (Sec[x/2])^2 (Tan[x/2])^-(be + 1) (1 +
ga (Tan[x/2])^-be)^(-(al/ga) - 1)


where $0<x<\pi$, and al, be and ga are equal in both functions. I have no idea how to use Plot function or there is any other function in Mathematica to plot this?

-

## closed as off-topic by Jens, Yves Klett, Artes, m_goldberg, Sjoerd C. de VriesAug 7 '13 at 21:13

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Jens, Yves Klett, Artes, m_goldberg, Sjoerd C. de Vries
If this question can be reworded to fit the rules in the help center, please edit the question.

Have a look at ParametricPlot. –  b.gatessucks Aug 6 '13 at 18:09
You really should read the documentation for ParametricPlot. –  chuy Aug 6 '13 at 18:21
Azeem -- think of myfunction1 as $f_x$, myfunction2 as $f_y$ and your variable x as the variable $u$ in the documentation. Then your setup is exactly like the first example in the help file, but with more complex functions. To get a concrete plot, you will need to provide values for al, be, and ga. –  bill s Aug 6 '13 at 18:27
@bills al, be and ga are positive real numbers, any arbitrary value should be given, but I got this error "ParametricPlot::exclul: {4 Im[Cot[x/2]^3]-0,Im[ga Cot[x/2]^3]-0} must be a list of equalities or real-valued functions. >>" after assigning al=2,be=3,ga=4. and proceed same as you directed and help file. –  Azeem Aug 6 '13 at 18:32
ParametricPlot[{myfunction1[{2, 3, 4}], myfunction2[{2, 3, 4}]}, {x, 0 + 10^-10, Pi}] works for me. (I get 1/0 for x=0.) You should show what you tried in your question (edit it to update). –  Michael E2 Aug 6 '13 at 18:58

## 1 Answer

The main difficulty of most beginners with Mathematica is that they start with a somewhat complicated problem (displaying two functions that have three parameters in one graphic) and then trying to do it all at once. First you have to understand how various Plot types work, such as Plot and ParametricPlot, and probably how to use graphics Options to control the look of the graphic. Then there is the question of whether the graphs of each of the functions can be reasonably combined in a single plot. And why do you say you want to plot one function on the x axis and the other on the y axis? That seems quixotic because maybe the range of the first function is discordant with the domain of the second function, and how would that make a good way to compare the two functions? Perhaps that was an error and you meant plotting both against the x axis with different scales on the left and right y axes? Plotting data, or functions, depends an awful lot on what the data or functions actually look like. One can't just go ahead with a generic approach without looking at the functions because all kinds of problems can arise depending on the parameters.

So let's just explore some first. Here is a somewhat different method for defining your first function.

myfunction1[{al_, be_, ga_}][
x_] := (al*be)/2 Cos[
x] (Sec[x/2])^2 (Tan[x/2])^-(be + 1) (1 +
ga (Tan[x/2])^-be)^(-(al/ga) - 1)


I've added an extra set of square brackets to contain the parameters and the final set of [] brackets contains the variable. The first set is known as SubValues in Mathematica. We wouldn't have to put the parameters in a List, but I went along with that. This type of definition has certain advantages: besides separating parameters from variables, it makes it easy to calculate derivatives with respect to the variable. For example:

myfunction1[{a, 1, 1}]'[x]


giving

-(1/2) a Cos[x] Cot[x/2] (1 + Cot[x/2])^(-1 - a) Csc[x/2]^2 -
1/4 (-1 - a) a Cos[x] (1 + Cot[x/2])^(-2 - a) Csc[x/2]^4 -
1/2 a (1 + Cot[x/2])^(-1 - a) Csc[x/2]^2 Sin[x]


Now let's plot with the parameters {1,1,1}.

Plot[myfunction1[{1, 1, 1}][x], {x, 0, \[Pi]},
Frame -> True,
ImageSize -> 250]


Notice that I used a Frame instead of the default Axes plot. This was done with the Frame option. This is almost always better. If you do a lot of graphics you will want to get to know the options. Next you might want to explore the function in the parameter space. Here is a little custom dynamic module for doing it. (Most users use Manipulate but it can sometimes tie you in knots and it's often easier to construct a custom dynamic.)

DynamicModule[{a = 1, b = 1, c = 1},
Column[{
Row[{"a", Spacer[10],
Slider[Dynamic[a], {0, 5}, Appearance -> "Labeled"]}],
Row[{"b", Spacer[10],
Slider[Dynamic[b], {0, 5}, Appearance -> "Labeled"]}],
Row[{"c", Spacer[10],
Slider[Dynamic[c], {0, 5}, Appearance -> "Labeled"]}],
Dynamic@
Plot[myfunction1[{a, b, c}][x], {x, 0, \[Pi]},
Frame -> True,
ImageSize -> 250]
}]
]


I won't display it here, but it you start exploring with it you will find a serious problem. The scale on the vertical axis keeps changing! This is because without further guidance Mathematica determines what it thinks is a reasonable plot range, and it does this each time you move one of the sliders. Any dynamic plot requires a fixed background (you would be astonished at how often beginners make that mistake.) So take the control away from Mathematica and specify a specific fixed plot range. The following does that.

DynamicModule[{a = 1, b = 1, c = 1},
Column[{
Row[{"a", Spacer[10],
Slider[Dynamic[a], {0, 5}, Appearance -> "Labeled"]}],
Row[{"b", Spacer[10],
Slider[Dynamic[b], {0, 5}, Appearance -> "Labeled"]}],
Row[{"c", Spacer[10],
Slider[Dynamic[c], {0, 5}, Appearance -> "Labeled"]}],
Dynamic@
Plot[myfunction1[{a, b, c}][x], {x, 0, \[Pi]},
Frame -> True,
PlotRange -> {-1, 2},
ImageSize -> 250]
}]
]


Now define your second function and explore it.

myfunction2[{al_, be_, ga_}][
x_] := (al*be)/2 Sin[
x] (Sec[x/2])^2 (Tan[x/2])^-(be + 1) (1 +
ga (Tan[x/2])^-be)^(-(al/ga) - 1)


I'll leave the exploration to you. Just follow the example above.

Unless you have some really good reason, I would plot both functions on the x axis. As an example:

Plot[{myfunction1[{1, 1, 1}][x], myfunction2[{1, 1, 1}][x]}, {x,
0, \[Pi]},
Frame -> True,
ImageSize -> 250]


Now you could use that plot in a DynamicModule. Again you will have to specify a PlotRange as before. You might consider scaling one or the other of the two functions and you might include this scaling information in the FrameLabel. There are other techniques, but I'm getting tired and I hope that helps enough. Remember that the method of presentation depends critically on what the data, functions or phenomenon actually is!

If you really want the functions on the x and y axes then you have to say what the purpose is so that it might be done in an intelligent manner.

-
your counter checks are nice, but final output is not like that what I want. It will be produce nicely using ParametricPlot[{myfunction1[2,3,4],myfunction2[2,3,4]}, {x,0,pi}]. Any help regarding this is welcome. –  Azeem Aug 7 '13 at 2:17