1
$\begingroup$

I'm solving a system of equations that gives me three solutions and then plot a series of solutions depending on a parameter. The problem is that I have to choose different solutions depending on parameters. For each combination of parameters the only one solution which makes physical sence - such solution is positive and always less then parameter P0. I guess the right solution is the minimal positive solution. In the proposed sample code the right solutions plotted in the first and third plot between 0 and 0.05 (parameter P0 = 0.1) How can I put all good solutions in a single plot automatically ? enter image description here

Quiet[solution = 
  Solve[{K1*P*M == PaM, K2*PaM*P == PMP, K3*PaM == PM, 
 P0 == P + PaM + PM + 2*PMP, r*P0 == M + PaM + PM + PMP}, {P, M, 
 PaM, PM, PMP}]];

Rmax = 5;
Rmin = 0.01;
K1 = 11;
K3 = 102;
P0 = 0.1;
K2values = {1, 10, 100, 1000, 10000, 100000, 1000000};
colors = ColorData[22, "ColorList"];

SetOptions[ParametricPlot, PlotStyle -> (Directive[#, AbsoluteThickness[3]] & /@ colors), AspectRatio -> 0.7, AxesLabel -> {"R", "v"}, PlotRange -> {{0, 5}, {-0.05, 0.2}}];
SetOptions[Graphics, ImageSize -> Large];

Plot1 = ParametricPlot[Evaluate[
Table[{{r, Re[PMP /. solution[[1]]]}}, {K2, K2values}]], {r, Rmin,
 Rmax}, PlotLabel -> "Solution 1"] ;
Plot2 = ParametricPlot[Evaluate[
Table[{{r, Re[PMP /. solution[[2]]]}}, {K2, K2values}]], {r, Rmin,
 Rmax}, PlotLabel -> "Solution 2"] ;
Plot3 = ParametricPlot[Evaluate[
Table[{{r, Re[PMP /. solution[[3]]]}}, {K2, K2values}]], {r, Rmin,
 Rmax}, PlotLabel -> "Solution 3"] ;

GraphicsGrid[{{Graphics[Plot1], Graphics[Plot2], Graphics[Plot3], Column[K2values, Background -> colors]}}, Frame -> None]
$\endgroup$
1
  • $\begingroup$ If you only want to merge these plots, the command Show[] should be, what you need. $\endgroup$
    – Stefan
    Feb 22, 2013 at 12:28

1 Answer 1

3
$\begingroup$

I'd define :

pmpSolAux[r_, P0_, K1_, K2_, K3_] = PMP /. solution;

pmpSol[r_?NumericQ, P0_?NumericQ, K1_?NumericQ, K2_?NumericQ, K3_?NumericQ] := 
  Min[Select[Re[pmpSolAux[r, P0, K1, K2, K3]], # > 0 && # < P0 &]]

(* No need for ParametricPlot *)
Plot[Evaluate[pmpSol[r, P0, K1, #, K3] & /@ K2values], {r, Rmin, Rmax}, PlotRange -> {All, {0, P0}}]

plot

If you must use ParametricPlot then the code below works; however I don't think it's possible to specify the x and y plotting ranges separately, so you'll have to compromise.

ParametricPlot[Evaluate[Table[{r, pmpSol[r, P0, K1, k2, K3]} , {k2, K2values}]],
               {r,Rmin, Rmax}, PlotRange -> {0, 1}]

parametric plot

$\endgroup$
3
  • $\begingroup$ Cool! It works! But it was an example.. I really need ParametricPlot. How to make it works with ParametricPlot? $\endgroup$
    – user4545
    Feb 22, 2013 at 13:11
  • $\begingroup$ What doesn't work ? $\endgroup$ Feb 22, 2013 at 13:26
  • $\begingroup$ Basing on good solutions I should make ParametricPlots like this: fr = Re[PM /. solution[[1]]] + 2*Re[PMP /. solution[[1]]] + Re[PaM /. solution[[1]]]; v = fr/P0; p = P0 - fr; ParametricPlot[ Evaluate[Table[{{v, v/p}}, {K2, K2values}]], {r, Rmin, Rmax}, PlotRange -> Automatic, AxesLabel -> {"v", "v/[L]"}, PlotLabel -> "Scatchard"] $\endgroup$
    – user4545
    Feb 22, 2013 at 13:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.