Re: Associate a color to each element in a vector [message #76573] |
Tue, 14 June 2011 00:24 |
Gray
Messages: 253 Registered: February 2010
|
Senior Member |
|
|
On Jun 13, 10:55 am, "le.davide" <le.dav...@tiscali.it> wrote:
> On Jun 12, 4:42 pm, Gray <grayliketheco...@gmail.com> wrote:
>
>> On Jun 12, 9:25 am, "le.davide" <le.dav...@tiscali.it> wrote:
>
>>> Dear all,
>>> consider a scatter plot of the couple of points (x,y), where each x
>>> and y is an array. Do you know if it is possible to associate a color
>>> to each element according to its position in the vector?
>>> ...I don't know of much this is clear.
>>> Thanks in advance.
>
>> Or rather, colors=scale_vector(indgen(n_elements(x)),0,255)
>
> Thanks for the suggestion but I get the error message:
> PLOT: Expression must be a scalar or 1 element array in this context:
> COLORS.
That's because you're using PLOT and not PLOTS, which lets you specify
a vector of colors.
|
|
|
Re: Associate a color to each element in a vector [message #76581 is a reply to message #76573] |
Mon, 13 June 2011 10:55  |
le.davide
Messages: 18 Registered: November 2010
|
Junior Member |
|
|
On Jun 12, 4:42 pm, Gray <grayliketheco...@gmail.com> wrote:
> On Jun 12, 9:25 am, "le.davide" <le.dav...@tiscali.it> wrote:
>
>> Dear all,
>> consider a scatter plot of the couple of points (x,y), where each x
>> and y is an array. Do you know if it is possible to associate a color
>> to each element according to its position in the vector?
>> ...I don't know of much this is clear.
>> Thanks in advance.
>
> Or rather, colors=scale_vector(indgen(n_elements(x)),0,255)
Thanks for the suggestion but I get the error message:
PLOT: Expression must be a scalar or 1 element array in this context:
COLORS.
|
|
|
|
Re: Associate a color to each element in a vector [message #76584 is a reply to message #76583] |
Sun, 12 June 2011 13:42  |
Gray
Messages: 253 Registered: February 2010
|
Senior Member |
|
|
On Jun 12, 9:25 am, "le.davide" <le.dav...@tiscali.it> wrote:
> Dear all,
> consider a scatter plot of the couple of points (x,y), where each x
> and y is an array. Do you know if it is possible to associate a color
> to each element according to its position in the vector?
> ...I don't know of much this is clear.
> Thanks in advance.
Or rather, colors=scale_vector(indgen(n_elements(x)),0,255)
|
|
|
Re: Associate a color to each element in a vector [message #76585 is a reply to message #76584] |
Sun, 12 June 2011 13:41  |
Gray
Messages: 253 Registered: February 2010
|
Senior Member |
|
|
On Jun 12, 9:25 am, "le.davide" <le.dav...@tiscali.it> wrote:
> Dear all,
> consider a scatter plot of the couple of points (x,y), where each x
> and y is an array. Do you know if it is possible to associate a color
> to each element according to its position in the vector?
> ...I don't know of much this is clear.
> Thanks in advance.
So, what you probably want is something like this.
colors = indgen(n_elements(x))
plots, x, y, color=colors, psym=1
|
|
|