TransWikia.com

How to use two separate colours for two lines in a single 'Plot' within the 'With' command?

Mathematica Asked by Chowdhury Aminul Islam on October 13, 2020

”’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.

One Answer

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

Correct answer by kglr on October 13, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP