Group Abstract Group Abstract

Message Boards Message Boards

0
|
3.6K Views
|
4 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Trouble with syntax combining Plot and Switch

Posted 2 years ago

Hi! If I

Plot[{Sin[x],Cos[x]},{x,0,2π}]

then I get the sine plotted in the default blue, and the cosine in the default orange. The command

key="one";
Switch[key,"one",{Sin[x],Cos[x]},"two",{-Sin[x],-Cos[x]}]

gives {Sin[x],Cos[x]}. Following this up with

Plot[%,{x,0,2π}]

results again in both curves being plotted in different colors. However

Plot[Switch[key,"one",{Sin[x],Cos[x]},"two",{-Sin[x],-Cos[x]}],{x,0,2π}]

results in both curves being plotted in the same color, and I could not manage to manually change that by using the option PlotStyle option.

Why is that so, and how can I change the plot colors if I use Plot with Switch in this way?

An example notebook is attached!
Thanks for help! : )

POSTED BY: Gernot H
4 Replies
Posted 2 years ago

Thank you so much!

POSTED BY: Gernot H
Posted 2 years ago
POSTED BY: Gernot H
Posted 2 years ago
POSTED BY: Eric Rimbey
Posted 2 years ago
POSTED BY: Hans Milton
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard