Plot(s): How to show every Nth point?

Welcome to our Forums Technical Support Support Desk Plot(s): How to show every Nth point?

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #4102
    sandrift
    Participant

      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.

      #4105
      dgteam
      Moderator

        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.

        Slider

        Here the slider for n is changed to 20, to plot every 20th value in a point.

        PlotwithPoints

        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”.

        Commands

        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.

        #4106
        jordan
        Participant

          I think this is why Datagraph is so great, because it accepts expressions is so many places, you can creat the functionality you need.

          #4107
          sandrift
          Participant

            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.

             

            #4114
            jordan
            Participant

              Sandrift, both of these things are easily accomplished already. The legend line includes the point marker just by adding the legend, as shown below:

              Untitled

              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.

              #4115
              sandrift
              Participant

                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.

                #4116
                jordan
                Participant

                  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.

                Viewing 7 posts - 1 through 7 (of 7 total)
                • You must be logged in to reply to this topic.

                Welcome to our Forums Technical Support Support Desk Plot(s): How to show every Nth point?