Menu

What happens when there are more data point pairs than pixels in the X direction?

Toewe
2013-02-04
2013-02-05
  • Toewe

    Toewe - 2013-02-04

    I'm using the squared plot and have many times more data points than the X-axis has pixels. Does every data point (which will be squared rectangles because of the plot style) get plotted? What if it overlays a previously plotted point? Does a smaller Y value point immediately after (so close in X that the effective X pixel is the same) a larger value erase part or all of the larger rectangle? Hope this makes sense, it's a bit hard to explain.

     
  • lbayuk

    lbayuk - 2013-02-05

    Every data point gets plotted, in the order they appear in the data array. Exactly as you said: because the plotting is on an integer grid, not every point can have a unique X value in the image.

    PHPlot converts each pair of (Xw,Yw) world coordinates into device coordinates (X,Y). For the 'squared' plot type, it draws 2 lines: the horizontal segment from (Xp,Yp) to (X,Yp), and then the vertical segment from (X,Yp) to (X,Y), where (Xp,Yp) is the previous point.

    Since there are more data points than X pixels, in some cases X==Xp, meaning - as you said - the effective X pixel coordinate is the same. So the horizontal segment collapses to a single point, and the vertical line segments from adjacent data points overlay. What you should get at that X position is a vertical line from min(Yi) to max(Yi), for all data points 'i' that end up with the same X pixel coordinate.

    Well, anyway, that's what I think it does. It's hard to see that, even with my screen magnifier and some contrived examples, as it gets very crowded.

    Does that help? (By the way, there are no rectangles here - just squared off lines. I hope we are talking about the same plot type.)

     
    • Toewe

      Toewe - 2013-02-05

      Yes that helps. You understood the question perfectly. If it does what you suggested, I'm a happy camper, or should that be happy plotter.

      I understand your clarification about two line segments being plotted versus the rectangle that I suggested. You are correct of course. There is a minor drawing issue with the corner formed by these two segments as you probably know. If the lines have widths of 2 or more, the corners look stepped rather than squared. It's really minor, but being a bit picky.... Cheers and thanks for your help.

       
  • lbayuk

    lbayuk - 2013-02-05

    There is a minor drawing issue with the corner formed by these two
    segments as you probably know. If the lines have widths of 2 or more, the
    corners look stepped rather than squared.

    No actually I didn't know. Thanks for pointing that out... I see what's going on, and I don't like it. There is no control on the line caps or line join shapes. When line widths are > 1, the horizontal and vertical lines used in a Squared plot are drawn by the PHP GD extension using filled rectangles of that width (or height). The short end of the rectangle is centered at the (X,Y) point. So at every corner of the Squared plot, you get these 2 rectangles meeting, with a missing corner, as shown in the upper left here:
    GD thick line corner issue

    It probably could be worked around in PHPlot by adjusting either X (for the horizontal segment) or Y (for the vertical segment) by 1/2 the width, but I don't like the idea much.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.