Mathematica PlotStyle->{color,color,color} not working

  • Context: Mathematica 
  • Thread starter Thread starter rynlee
  • Start date Start date
  • Tags Tags
    Mathematica
Click For Summary

Discussion Overview

The discussion revolves around an issue with plotting in Mathematica, specifically related to the use of the PlotStyle option when plotting a list of complex functions. Participants explore the behavior of color assignment in plots and suggest potential solutions to the problem encountered.

Discussion Character

  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant describes an issue where all curves in a plot are colored with the last color from a specified color list, despite expecting each curve to take on a different color.
  • Another participant suggests that the issue may stem from how the functions are being evaluated and proposes using a different plotting approach, specifically recommending the use of Evaluate[] or mapping the imaginary part over the correlation list.
  • A later reply confirms that using Evaluate[] resolved the issue, indicating that the original approach was not correctly applying the color styles as intended.

Areas of Agreement / Disagreement

Participants generally agree that the use of Evaluate[] was a necessary step to resolve the plotting issue, but the initial disagreement centered around the method of plotting the list of functions.

Contextual Notes

The discussion does not address potential limitations of the proposed solutions or the specific conditions under which the original issue arose.

rynlee
Messages
44
Reaction score
0
Hi All, running into a bit of a mathematica issue. I put the following code into plot:
Code:
Plot[Im[correlationList], {t, 0, timeEnd}, 
  PlotStyle -> ColorList]

correlationList is a list of complex functions that have been evaluated at t. It correctly plots all of them (if I change it to correlationList[[2]] for example it only plots the second function, etc., as is it plots all of the functions on the same plot)

(I've omitted PlotRange -> {Full, {-1, 1}}, ImageSize -> Large, from the above command, but that's in there too)

ColorList is a list of Hue[] evaluations, i.e.
Code:
In:ColorList
Out: {Hue[1/10],Hue[1/5],Hue[3/10],Hue[2/5],Hue[1/2],Hue[3/5],Hue[7/10],Hue[4/5],Hue[9/10],Hue[1]}

When I plot this however, it colors *all* of the curves the *last* color in the color list.

This behavior holds even when I change the PlotStyle term, for example if I use {Orange,Blue,Green} instead of ColorList, it plots *all* of the functions green, none orange or blue. So it always takes the last member of the list. I'm not sure why it's doing this.

I tried transposing ColorList (which I generate from an Array[0&,10] command, then filled in with a Do[] loop), but that just gave error messages.

Thanks for any help,

rynlee
 
Physics news on Phys.org
I'm thinking that you might need to Plot[{Im[correlationList[[1]]], ..., Im[correlationList[[n]]]}] rather than
Plot[Im[{correlationList[[1]], ..., correlationList[[n]]} ], if you get what I mean.

So what happens if you plot Evaluate[Im[correlationList]] instead?
Or first convert it to a list, e.g. plotting I am /@ correlationList?
 
yep the evaluate[] did it! Thanks!
 
The final function (just to show what it should look like if anyone else has the same problem):
 

Attachments

  • Prob 2Gi.jpg
    Prob 2Gi.jpg
    27.1 KB · Views: 657

Similar threads

  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 18 ·
Replies
18
Views
5K