Scatter Plot colour function
Mike German
I am plotting x versus y data as separate waves in a scatter plot and using z data as a colour function. All x and y points have values and the y data has a number of points that are set to NaN. There are 20000 points.
This does not work as I intended because on checking spot points using graph info some x-y points show up where the y value is set to NaN. Is this to be expected ?
Hi Mike,
It would be best if you started by stating which version of Igor you are using and what platform you are working on.
I think I am missing something in your description. I tried to simulate your example (IP8 on WIN10) using the following:
•display yyy vs xxx
•ModifyGraph mode=3
•matrixop/o zzz=setnans(zzz,greater(zzz,6))
•ModifyGraph zColor(yyy)={zzz,*,*,Grays,0}
•ShowInfo
I tried to scan all the points starting at point 0 and using the arrow key to move the cursor sequntially) but I did not see any NaNs. If you see something different I suggest you send a copy of the experiment (or the relevant part) to support@wavemetrics.com.
AG
November 23, 2019 at 10:30 am - Permalink
In reply to Hi Mike, It would be best… by Igor
Sorry. Win 10 Pro and Igor pro Version 8.0..4.2
All waves (x,y,z) have the same number of points as per your example but I was deliberately trying to exclude certain z point by setting them to NaN.
November 23, 2019 at 10:42 am - Permalink
Assuming that you got the info window using Ctrl-i and dragged one of the cursors onto the graph you can use the left and right arrows to scan the plot. The info window should give you a readout of the data point that is under the cursor. You can then display a table showing the XYZ data and you should be able to match the values from the info window to the table. If your data contained a NAN for any y value, it would not be displayed in the graph but you could have a real check based on the point number shown in the info window and the one in the table.
November 23, 2019 at 11:01 am - Permalink
If the cursor is placed on a point that contains a NaN value, the info window will display NaN in the appropriate box. You can't drop the cursor on a NaN, but you can use the Cursor command or the arrow keys to move the cursor onto a NaN value. If the cursor is moved to a point that has a NaN value, it will move to the edge of the plot area, as shown in the attached screen shot.
November 25, 2019 at 09:35 am - Permalink
@Mike: Not sure if I understand correctly, but I got the impression that you just want to exclude points from the color scale when NaN, not from the graph itself. Maybe you can clarify.
If so, then this may work for you (note that I use INF instead of NaN):
xx = p
yy = p + enoise(1)
zz = inf
zz[0, ;2] = p
display yy vs xx
wavestats/Q zz
ModifyGraph mode=3,msize=6
ModifyGraph zColor(yy)={zz,V_min,V_max,YellowHot,0},zColorMax(yy)=(65535,65535,65535)
EDIT:
on re-reading your initial post you have y-values at NaN, so the above probably doesn't help.
November 25, 2019 at 11:09 pm - Permalink
In reply to If the cursor is placed on a… by johnweeks
This is not what I get on my scatter plots. The first creen shot shows the curors dropped on to a space on the graphic and a point is indicated that shows an xy value and, correctly, no marker because the corresonding f(z) value is NaN. An expanded shot, moved to a close by wave point also shows no marker but here the f(z) value is a number. So the NaN points are not high lighted by the info cursor and the scatter display does not correctly show the marker for where the number is valid.
My problem is that I want to display valid numbers only and I am not sure that I will get that!
November 26, 2019 at 02:25 am - Permalink
Ooops. in my original posting that should have been been the f(z) data has some NaNs not the y data. Sorry.
November 26, 2019 at 02:43 am - Permalink
In reply to Ooops. That should have… by Mike German
Heh. That does change things...
But now I'm confused- what are you trying to show? and how?
Since the info window doesn't show the Z values, it's not clear to me what you are trying to do.
Would a window hook that handles the cursormoved event be able to show something useful to you? Or it could detect that the f(z) value is NaN and move the cursor to the next non-NaN point.
November 26, 2019 at 10:42 am - Permalink
In reply to This is not what I get on my… by Mike German
Once you disable the marker stroke in my example above the INF points will disappear:
ModifyGraph useMrkStrokeRGB=0
Your two screen shots show the cursor on exactly the same point number 7992 but maybe it's just a faulty upload.
If you think there is some inconsistency it would be best if you could share the data and include a step-by-step description how to reproduce it.
November 27, 2019 at 08:14 am - Permalink
In reply to Mike German wrote: Ooops… by johnweeks
I will just restate (correctly) what I am doing from the beginning. I have a scatter plot of X and Y waves to show the distribution of 20000 randomly generated points. Various other parameters are calculated relating to these points. To focus on one particular aspect of one of these parameters I filter out various values by setting the values to NaN. I then use the f(z) option for the markers to colourise using this filtered parameter containing the NaNs.
The scatter plot didn't look as I expected it and that led me to investigate the displayed points using graph info. It was at this stage that I found what I thought was a discrepency between what the cursor indicated as a valid value and the actual value as shown in my pngs above.
I have circumevented the issue by making new waves containing the valid values of the z parameter only and for the corresponding values for X and Y. The new scatter plot using valid points only looks the same as the previous one that included NaNs. So, the data on the original plot was displayed as it should have been.
Thanks for all the advice. My issues are now sorted out with the new plot, from my point of view the query is completed.
November 27, 2019 at 08:29 am - Permalink