#1115 Image ranges aren't cropped correctly in aqua terminal

2D plot (258)

Setting xrange/yrange for an image yields incorrect cropping on most devices: there is a 1/2-pixel error in either direction, causing the image to overlap the axes. For example,

set xrange [10:40]
set yrange [10:40]
plot [10:40] [10:40] "-" binary array=(51,51) format="%double" using 1 notitle with image

followed by a 51x51 image will cause the axes to be overdrawn by the image itself. A current workaround is to say something like:

set xrange [10:40]
set yrange [10:40]
plot [9.5:40.5] [9.5:40.5] "-" binary array=(51,51) format="%double" using 1 notitle with image

which artificially expands the axes, but is ugly.

I have only verified the problem with the Aqua terminal. x11, png, and pdf appear to do the Right Thing.


  • Ethan Merritt

    Ethan Merritt - 2012-04-14

    It's not an image range error.
    Gnuplot treats the coordinate [x,y] of a finite sized pixel as defining the center of the pixel.
    So yes, if you expand the image pixels so that they occupy more than one screen pixel, then the pixel at [0,0] will extend across the axis to [-size/2,-size/2]

    So that part of it works as intended.
    You can see an example of the intended use in the first two plots of the heatmaps demo.

    Now as to whether the aqua terminal clips images correctly - that's another question. Could you please re-examine your plots in light of the above and then report back whether there's an image clipping problem?

  • Craig DeForest

    Craig DeForest - 2012-04-14

    Yes, I'm quite pleased about Gnuplot handling pixels correctly -- it is very nice to see, and I agree that the behavior is correct in that respect!

    The cropping/clipping is the issue -- the images render exactly right in the other devices.
    For what it's worth, I think this may also have been the cause of my bug 3477226 ("polygon objects crop incorrectly") as when I submitted it I didn't realize that there is so much variation in behavior between different output devices -- I don't think I reported which terminal I was using when I observed that bug, but it was in fact aqua.

  • Ethan Merritt

    Ethan Merritt - 2012-04-19

    Unfortunately aquaterm is unlike other gnuplot terminals in that it is maintained (or not) as a separate program with its own project site etc. In other words, we can't fix it in gnuplot.

    What we can do, however, is provide generic fallback code that is supposed to do the same thing on all terminals, at the cost of forgoing any clever optimization that the terminal might otherwise provide. Try running your tests again, this time adding the keyword "failsafe", i.e.
    plot ... with image failsafe

  • Craig DeForest

    Craig DeForest - 2012-04-19

    sfeam: that works like a champ. It solves my problem -- I'm in the midst of taking over an interface layer between Perl/PDL and Gnuplot (link is: https://github.com/drzowie/PDL-Graphics-Gnuplot\), and I can just issue "failsafe" mods automagically for aqua.


  • Ethan Merritt

    Ethan Merritt - 2012-04-23

    revised description of the 'with image failsafe' in gnuplot.doc

  • Ethan Merritt

    Ethan Merritt - 2012-04-23
    • status: open --> closed-works-for-me

Log in to post a comment.