0
$\begingroup$

I am trying to use a Manipulate expression to plot $f(x)$, a function of $x$ and dependent parameters $a$, $b$ and $c$. So the x-axis is $x$ and the y-axis is $f(x)$. Also, I want to add a point to the plot. The expression giving the point is $g(a,b,c)$. So basically what I want to do is that each time I change $a$, $b$ or $c$, I get a updated line for $f(x)$ and an updated point corresponding to $g(a,b,c)$, both of which will show in the plot.

How can I do that?

Here is the code:

Manipulate[
  Plot[(x - 1)*(a - b)*c, {x, 0, 1}, PlotRange -> 2], 
  {a, 0, 1},
  {b, 0, 1}, 
  {c, 5, 50}]

The point is given by g = a^2 + b - c. I am not sure how to include the point into the plot.

$\endgroup$
  • 2
    $\begingroup$ You are not giving us enough information. We need to know the definitions of f`` how and g. We need the see the Manipultat e` expression you wrote. With that additional information, unless you doing something really weird, it should easy to show you how to use the xy-coordinates produced by g in an Epilog option given to your plot/ $\endgroup$ – m_goldberg Feb 22 '18 at 3:41
  • $\begingroup$ The code is posted. Thanks! $\endgroup$ – ycole Feb 22 '18 at 17:47
  • 2
    $\begingroup$ Your question still has a problem. To plot a point requires two coordinates $x$ and $y$. However, g only gives a single number, not a list of two numbers that could be used to plot a point. As it is, g could be used to plot a horizontal or vertical line in the plot or it could be displayed on the plot as number, but it can't be shown on the plot as point. Can you clarify how expect g to show up in the plot? $\endgroup$ – m_goldberg Feb 22 '18 at 20:34
  • $\begingroup$ Welcome! To make the most of Mma.SE start by taking the tour now. It will help us to help you if you write an excellent question. Edit if improvable, show due diligence, give brief context, include minimal working example of code and data in formatted form. As you receive give back, vote and answer questions, keep the site useful, be kind, correct mistakes and share what you have learned. $\endgroup$ – rhermans May 30 '18 at 15:12
2
$\begingroup$

The OP doesn't give enough information, so this is a generic answer. Use Epilog and Point with the arguments {x,g[x]}.

Manipulate[
 Plot[
  (x - 1)*(a - b)*c, {x, 0, 1}
  , PlotRange -> 2
  , Epilog -> {
    PointSize[Large]
    , Red
    , Point[{0, (0 - 1)*(a - b)*c}]
    , Point[{1, (1 - 1)*(a - b)*c}]
    }
  , PlotTheme -> "Scientific"
  ]
 , {a, 0, 1}
 , {b, 0, 1}
 , {c, 5, 50}
 ]

Mathematica graphics

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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