'''With[{k = {1, 10}}, Plot[k*x^2, {x, 0, 1}]]'''

I want to use two separate colours for two k values. How to do that? Thanks in advance.


1 Answer 1


Wrap the first argument of Plot with Evaluate

With[{k = {1, 10}}, Plot[Evaluate[k*x^2], {x, 0, 1}]]

enter image description here

Alternatively, add the option Evaluated -> True:

With[{k = {1, 10}}, Plot[k*x^2, {x, 0, 1}, Evaluated -> True]]

same picture

  • $\begingroup$ @ChowdhuryAminulIslam, my pleasure. Thank you for the accept. $\endgroup$
    – kglr
    Sep 8, 2020 at 20:41
  • $\begingroup$ @kgir, I can further use 'PlotStyle' within the command to customise the colours. $\endgroup$ Sep 8, 2020 at 20:43
  • 1
    $\begingroup$ yes, you can use, for example, PlotStyle-> {Red, Green} or PlotStyle->{Directive[Thick, Dashed, Orange],Directive[Dotted, Purple]} etc. $\endgroup$
    – kglr
    Sep 8, 2020 at 20:46

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.

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