Plotting grouped scatter plot with different markers from a text wave
greenriver
Hi,
I have three waves. Wave0 and wave 1 are numerics and wave 2 is text wave. I am trying to create a scatter plot (x=wave0, y=wave1) automatically grouped with different markers (ex: g1, g2, g3). For grouping, I’d like to use a text wave which contains g1, g2, g3 and corresponds to x and y waves.
Any suggestion would be welcomed.
I'd use a numeric wave containing the marker type (MT):
make /T/N=10 GL={"G2","G1","G3","G3","G2","G1","G1","G3","G2","G1","G2"}
display wY vs wX
ModifyGraph mode=3, zmrkNum(wy)={MT}
MT = stringmatch(GL,"G1") ? 1 : MT
MT = stringmatch(GL,"G2") ? 16 : MT
MT = stringmatch(GL,"G3") ? 7 : MT
TextBox/C/N=text0/A=RT/X=0.00/Y=0.00 "\\W516 G1\r\\W507 G2\r\\W501 G3"
HJ
July 23, 2018 at 03:54 am - Permalink
But you can also use the text wave that has "G1", "G2", "G3" as the source for text markers:
PauseUpdate; Silent 1 // building window...
Display /W=(244,463,639,671) wY vs wX
ModifyGraph mode=3
ModifyGraph rgb=(0,0,0)
ModifyGraph msize=4
ModifyGraph textMarker(wY)={GL,"default",0,0,5,0.00,0.00}
EndMacro
Note that HJDrescher accidentally made his text wave with 11 elements. The contents of the braces (GL={...}) overrides the /N= flag.
July 23, 2018 at 01:35 pm - Permalink
In reply to But you can also use the… by johnweeks
Ooops
July 23, 2018 at 02:19 pm - Permalink
In reply to I'd use a numeric wave… by HJDrescher
Great, Thanks! Is there any way not to use MT but directly use my text wave?
July 23, 2018 at 06:45 pm - Permalink
In reply to But you can also use the… by johnweeks
Thanks John. Could you provide me a way to put different marker for each group? e.g., black solid circle, red triangle, blue open circle..
July 23, 2018 at 07:00 pm - Permalink
That could be done by text markers and using escape sequences.
However, this is getting a little ugly. Maybe you want to reconsider the data structure and store one set of data in one xy wave-pair (or an Nx2 wave).
HJ
July 24, 2018 at 12:23 am - Permalink
In reply to Thanks John. Could you… by greenriver
It seems like that is what HJDrescher showed you originally. The easiest way to pick a marker is via a numeric wave containing marker numbers, and selecting that marker wave in the Modify Trace Appearance dialog as the Marker as f(z) wave. The code HJDrescher gave you was an easy way to build the marker wave.
July 24, 2018 at 11:02 am - Permalink
Hi,
I run into this need quite a bit. Basically numeric waves with data and text waves with labels. Some other programs handle this as a course of business easily.
I cobbled together a simple tool that helps create the marker wave for customization.
Attached without warranty.
Andy
July 24, 2018 at 06:29 pm - Permalink
Hi,
Updated my tool. You can now both a marker wave based on a text wave, or extract subsets of waves based on a key text wave.
The extraction looks for unique names in the text wave and then extracts each subset appending that label to end of the base wave name.
I have been meaning to write this for my own use. Feedback is most welcome.
Andy
July 25, 2018 at 04:57 pm - Permalink
In reply to That could be done by text… by HJDrescher
Thanks, HJ. All your codes are very hlepful.
I will consider your recommendation too.
July 26, 2018 at 08:30 pm - Permalink