Different color markers in an XY scatter plot
Peeyush Khare
Hi,
I have an XY scatter plot with 1 Y wave and 1 X wave. Let's say each wave contains 12 points. Now I want to use three different colors to color different markers on the plot such that points 0-4 are red, 5-8 are blue and 9-12 are green. Kindly advise how this could be done..
Many Thanks and Regards,
Peeyush
Here is a MWE
xW = p
yW = gnoise(1)
// assign values to zWave
zW[0,3] = 1 // red
zW[4,7] = 0 // blue
zW[8,11] = 2 // green
Display yW vs xW
ModifyGraph mode=3,marker=19
// this line colours the points according to zWave
// uses BlueRedGreen colortable with limits of 0 and 2 so that
// 0, 1 and 2 are blue, red and green
ModifyGraph zColor(yW)={zW,0,2,BlueRedGreen,0}
August 30, 2020 at 11:11 pm - Permalink
Alternative is to make a three column wave for all points like this:
zW[0,3][0] = 65535
zW[4,7][2] = 65535
zW[8,11][1] = 65535
ModifyGraph zColor(yW)={zW,0,2,directRGB,0}
August 31, 2020 at 02:35 am - Permalink
Great, thanks sjr51!
Also, I have another situation and I'm wondering if you could please help..
100 points in the y wave which are distributed between 16 categories. The categories are all mixed among the 100 points. There need to be 16 colors on the scatter plot, one for each category.
What I have done so far is that I created a third wave that contains category IDs and applied it to the y-wave. So every datapoint in the y wave has an ID going from 1 to 16. I have tried using this 3rd wave as the color wave but the colors come out like rainbow256. I need the colors to be very distinct from each other.. and it would be great to be able to drop 16 different markers, one for each category, if possible. So this is the first objective..
The second objective is to then create a legend in the graph that displays the markers and color categories..
Many Thanks and Regards,
Peeyush
August 31, 2020 at 09:26 am - Permalink
For your second question, you can specify which point gets added to a textbox/legend. In my example above, doing:
TextBox/C/N=text0/F=0/A=MC "\\s(yW[0]) red marker\r\\s(yW[4]) blue marker"
will add two markers for the same wave. In the annotation dialog just type "\s(yW[4]) blue marker" where the number in square brackets is the point that has the marker and colour you want to describe.
Your first question is more tricky. Getting 16 colours that are very distinct is difficult. With the combination of colours and markers you can get there though. You can make another wave for the marker numbers (the numbers are given in the manual) and apply that in a similar way to apply f(z) for colour.
August 31, 2020 at 12:50 pm - Permalink