DataGraph Forums › Technical Support › Support Desk › Plot(s): How to show every Nth point?
I regularly plot spectral data having a thousand points in each line. I use both the Plot and Plots commands, depending on how many spectra I need to show in the graphic. In publications, I may not want or be able to assign colors (e.g., to avoid posing issues for colorblind readers or due to extra cost). In many cases, having the ability to change the line style is sufficient to distinguish between a small number of spectra in a plot, but sometimes that gets hard to look at and decipher once there are more than just a few spectra.
It appears that the point style option doesn’t offer the ability to draw a point every Nth data point in Plot or Plots. Is this correct?
I can imagine creating a new pair of columns every Nth y- and x-axis pair, and overlaying that plot on top of the original plot (which has no points), but that could become quite cumbersome (adds a lot of unnecessary data to the file) with many spectra.
You are correct. There is no built-in setting to plot every nth point.
One option is to use a mask to specify which rows to plot. For example, you can use a Logical statement to plot at row increments.
We uploaded a new example file using this approach, where a slider changes the increment.
Here the slider for n is changed to 20, to plot every 20th value in a point.
This uses a Logical statement in the mask itself along with the mod function (remainder after division. The full statement is “mod(v-1,n)==1”.
This means that values are only drawn when the remainder after division of (#-1)/n is equal to 1.
Note ‘v’ in this statement represents the column chosen as the Shared mask.
Please check out the file and see if this helps.
I think this is why Datagraph is so great, because it accepts expressions is so many places, you can creat the functionality you need.
Thank you very much, dgteam. This is a nice solution that gets me most of the way to where I’d like to be. (The addition of the online examples has been very useful, so thank you for that, too.)
A couple of reasons this feature might be worth incorporating within the Plot/Plots command are: 1) so that the legend line would then include the point marker, too (for the time being, I’m happy to add “(triangles)” to the end of the label text); and 2) to automagically deal with a plot/s that is/are offset.
Sandrift, both of these things are easily accomplished already. The legend line includes the point marker just by adding the legend, as shown below:
As far as dealing with offset plots, it is trivial to adjust the off set axis column by making a new column adding or subtracting the adjustment and use that as the x value in the plot command.
Jordan, yes, I see what you mean about the legend. As I said in my original message, I commonly plot many (tens of) spectra at a time using the Plots command in large part because it includes offsetting of all of those spectra (precisely so that I don’t have to do what you describe). The scatterplots offered as a workaround do not have offset capability, so yes, I understand that I would have to duplicate them and apply a different offset to each one. I also indicated that doing so would be a cumbersome workaround for me, and it takes time away from analyzing the data.
If the DataGraph team feels my feature suggestion isn’t worthwhile for some reason, that’s fine, it was only a suggestion, and not all are worth the time to implement.
Ah understood…another option is to split your uses between two graphs in the same file, having one where is your publication quality plot showing every Nth point, and another graph for you to do your analysis using the plot commands.
I think your suggest is good, I was under the impression that you needed some direction on how to manually implement offsets. I’m sorry if it came off a little harsh.
DataGraph Forums › Technical Support › Support Desk › Plot(s): How to show every Nth point?