Message Boards Message Boards

0
|
5743 Views
|
3 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Graphs with different colors

Posted 10 years ago

Hi,

This should be not that hard, but I tried many different ways, I can't figure it out. If you can take a quick look and help me, it would be very appreciable.

As you see in the code, I have three plots, but they are all in same colors. How can I make them different?

Clear[x]
L1 = 10;
L2 = {30, 40, 48};
f[x_] = 100 (100/x)^(-(L2/L1));
Plot[f[x], {x, 90, 100}, PlotStyle -> Dashed, 
 PlotStyle -> {Black, Red, Blue}, 
 AxesLabel -> {"10mm transmittance (%)", "target transmittance (%)"}]
Print["Sample thickness(mm)= ", L1]
Print["Target thickness(mm)= ", L2]

enter image description here

Thank you so much in advance.

POSTED BY: Sungwoo Yang
3 Replies
Posted 10 years ago

Hi Eric and Bianca, Thank you so much for your help. I really appreciate it.

POSTED BY: Sungwoo Yang

... what Eric said. However, that alone will give you the first three default colours, not the ones you specify in your code. The problem here is that you give the PlotStyle option twice, but Mathematica will only interpret the first instance of any option. This means that you have to combine Dashed and the colours in the same PlotStyle option, like this:

Clear[x]
L1 = 10;
L2 = {30, 40, 48};
f[x_] = 100 (100/x)^(-(L2/L1));
Plot[Evaluate[f[x]], {x, 90, 100}, 
 PlotStyle -> {Directive[Dashed, Black], Directive[Dashed, Red], 
   Directive[Dashed, Blue]}, 
 AxesLabel -> {"10mm transmittance (%)", "target transmittance (%)"}]
Print["Sample thickness(mm)= ", L1]
Print["Target thickness(mm)= ", L2]
POSTED BY: Bianca Eifert
Posted 10 years ago

Change the first argument of Plot from f[x] to Evaluate[f[x]].

POSTED BY: Eric Schulz
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract