1
$\begingroup$

I have the following plot:

Plot[Table[C*r^2 + 2 C, {C, {25, 100, 150, 300}}] // Evaluate,
     {r, 0, 1000}, 
     PlotLegends ->LineLegend[{25, 100, 150, 300}, LegendLabel -> C,
             LabelStyle -> {GrayLevel[0.2], Bold, 10}, LegendFunction -> "Frame"], 
     AxesLabel -> {r, Plot}, 
     PlotLabel -> "Plot"]

But I need to include a constraint: r >= C. So when C is 300, the plot should show only for r = 300 to r = 1000.

How should I modify this code?

$\endgroup$
3
  • $\begingroup$ Change the first argument in Table to ConditionalExpression[C*r^2 + 2 C, r >= C]? $\endgroup$
    – kglr
    Jul 24, 2014 at 21:24
  • $\begingroup$ it worked! Shame on me, it was too easy. thank you! $\endgroup$
    – YoJesseP
    Jul 24, 2014 at 21:31
  • $\begingroup$ my pleasure. Welcome to mma.se. I posted the comment as an answer. $\endgroup$
    – kglr
    Jul 24, 2014 at 23:38

1 Answer 1

3
$\begingroup$
Plot[Table[ConditionalExpression[C*r^2 + 2 C, r >= C], 
          {C, {25, 100, 150, 300}}] // Evaluate, 
     {r, 0, 500}, 
     PlotLegends -> LineLegend[{25, 100, 150, 300}, LegendLabel -> C, 
                               LabelStyle -> {GrayLevel[0.2], Bold, 10}, 
                               LegendFunction -> "Frame"], 
     AxesLabel -> {r, Plot}, 
     PlotLabel -> "Plot"]

enter image description here

$\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.