1
$\begingroup$

I have "Manipulate[Plot ... " Where I can adjust my variables. In that chart I want to include datapoints. Right now I have two separate graphs:

 Manipulate[Plot[volatility[k, beta, alpha, rho, v], {k, 20, 45}, PlotRange -> {0, 0.3}], {b, 0,1}, {a, 0, 1}, {p, -1, 1}, {v, 0, 1}]

ListPlot[{{31.174, 0.1751}, {36.5, 0.20}, {27.88, 0.16}, {41.28, 
0.23}, {24, 0.154}}, PlotRange -> {{20, 45}, {0, 0.3}}]

How can I gather those plots in one chart. "Show" function does not work here

$\endgroup$

closed as off-topic by Michael E2, Karsten 7., Bob Hanlon, Yves Klett, Young Aug 8 '16 at 19:04

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." – Michael E2, Karsten 7., Bob Hanlon, Yves Klett, Young
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$ – Michael E2 Aug 6 '16 at 21:12
  • $\begingroup$ Have you seen Show? $\endgroup$ – Michael E2 Aug 6 '16 at 21:12
  • $\begingroup$ Yeah, I have mentioned it in my question. But maybe I am using it wrong. How would you use it? $\endgroup$ – Michael Aug 6 '16 at 21:14
  • 1
    $\begingroup$ Like the first example in the docs: Show[Plot[x^2, {x, 0, 3.5}], ListPlot[{1, 4, 9}]]? How were you using it? $\endgroup$ – Michael E2 Aug 6 '16 at 21:34
  • $\begingroup$ Show[Manipulate[Plot[x^2, {x, 0, 3.5}]], ListPlot[{1, 4, 9}]] Remember that I need the manipulate function $\endgroup$ – Michael Aug 6 '16 at 23:10
1
$\begingroup$

I think 'show' function is the way to go. Try this structure:

 Manipulate[ Show[ Plot[],ListPlot[], PlotRange-> ],{} ] 

Your code will be something like that:

Manipulate[
 Show[
        Plot[volatility[k, beta, alha, rho, v], {k, 0, 40}],   
        ListPlot[{{31.174, 0.1751}, {36.5, 0.2}, {27.88, 0.16}, {41.28,0.23}, {24, 0.154}}],
        PlotRange -> {{0, 45}, {0, 0.3}}
     ],
 {beta, 0, 1}, {alpha, 0.1, 1}, {rho, 0.1, 1}, {v, 0.1, 1}]  
$\endgroup$
  • $\begingroup$ And I assume that b, a, p and v are meant to be beta, alpha, rho and v? If it is in a financial context (which I am pretty sure that it is) then I think my assumption is correct $\endgroup$ – k.dkhk Aug 8 '16 at 16:39
1
$\begingroup$

Something like

Manipulate[
  Plot[volatility[k, beta, alpha, rho, v], {k, 20, 45}, 
    PlotRange -> {{20, 45}, {0, 0.3}},
    Epilog ->
      {Red, AbsoluteThickness[5], 
       Point[{{31.174, 0.1751}, {36.5, 0.20}, {27.88, 0.16}, 
              {41.28, 0.23}, {24, 0.154}}]}],
  {b, 0, 1},
  {a, 0, 1},
  {p, -1, 1},
  {v, 0, 1}]

Of course, I could not test this since you didn't provide a working example.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.