Message Boards Message Boards

0
|
3929 Views
|
4 Replies
|
0 Total Likes
View groups...
Share
Share this post:

[?] Change the style of each item being plotted by ListPlot?

Posted 5 years ago

I have a list of values:

{1, 1, 1, 3, 4, 4, 4, 3, 3, 3, 3, 4, 15, 23,...}

I want to plot the items, but I want the colour of each item to be determined by its value. What's the most 'Wolfram' way of doing this?

Cheers Andy

POSTED BY: Andrew Burnett
4 Replies
Posted 5 years ago

Hi Arnoud, I wasn't thinking of ColorFunction, but only because I didn't know about it! Thank you for the suggestions. I learn about at least two new functions every time I ask a question.

Cheers Andy

POSTED BY: Andrew Burnett

You mean by using ColorFunction?

ListPlot[
 RandomInteger[100, 20],
 ColorFunction -> "Rainbow"
 ]
POSTED BY: Arnoud Buzing
Posted 5 years ago

Here is one way to do it.

data = {1, 1, 1, 3, 4, 4, 4, 3, 3, 3, 3, 4, 15, 23};
data // Map[Style[#, Hue[Rescale[#, MinMax[data]]]] &] // ListPlot[#, PlotRange -> All] &

enter image description here

POSTED BY: Rohit Namjoshi
Posted 5 years ago

Thanks, that gives me exactly what I was looking for. I didn't realise that I could wrap data points in functions, inside a list, and have those functions evaluated by the ListPlot function. Cheers Andy

POSTED BY: Andrew Burnett
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