From: Ethan A M. <me...@uw...> - 2020-04-09 23:00:12
|
On Thursday, 9 April 2020 14:06:01 PDT Dima Kogan wrote: > Ethan A Merritt <me...@uw...> writes: > > > On Thursday, 9 April 2020 11:58:52 PDT Dima Kogan wrote: > >> A common use case for me is to mark-up images. So gnuplot would plot an > >> image, and render stuff on top of it. > > > > Already there in 5.4 (please test release candidate!) > > What? Wow! OK. > > First off, I've been running 5.4-rc1 (built from source, new > x11_waitforinput patch cherry-picked) for a few days now. No surprises > yet. > > I just tried out 'set pixmap'. For me it only appears to work in the > most basic cases, and I can't tell if it's any faster. I think there're > several issues at play. > > I tried small images first. Using http://gnuplot.info/figs/front2.png > from the gnuplot site. > > This works: > > set terminal x11 > set pixmap 1 "/tmp/front2.png" at 0,0 > plot x > > This doesn't: > > set terminal x11 > set pixmap 1 "/tmp/front2.png" at 0,0 width first 300 behind > plot x I think you misunderstood the meaning of "first" in that context. The default xrange is [-10:10], if you place an image with its lower corner at 0,0 then the maximum size that will fit in the plot is set pixmap 1 "/tmp/front2.png" at 0,0 width first 10 behind i.e. 10 units in the first axis coordinate system > The plot pops up, and goes away immediately. Might be x11_waitforinput() > still needs work, because in the qt terminal it does work. x11 is weird > in lots of cases here, so I'm using qt for the rest of this email. Will > revisit x11 later. I have no idea what that's all about, but possibly it is a result of trying to draw a bitmap that extends waaaay off screen, since "width first 300" is 30 times too big to fit on screen. > You need to zoom out manually because the pixmap isn't a part of the > autoscaling logic. Should it be? It is when using "with rgbimage" I > think. Again a misunderstanding? If you use axis coordinates (e.g. "first 10") then it autoscales. If you stay in pixel coordinates then it doesn't scale. > It'd also be really nice to use the native size of the image somehow. > The default "set pixmap" uses is "native image size in pixel > coordinates". But what I'd want usually is "native image size in plot > axis coordinates", and this isn't available. What does that even mean? > I have to know the size, > and to communicate it in the command with something like "first 300". No, that's wrong. If you use plot coordinates you *don't* need to know the original size in pixels because it will be scaled to match the plot. You are specifying a width in plot coordinates. > Usually when talking about images, the y axis is flipped: the (0,0) > pixel is the TOP-left not the BOTTOM-left. So "set pixmap at" should > maybe place the top-left pixel of the image? In my usage I generally do > "set yrange [:] reverse". But even in that usage "set pixmap at" places > the bottom-left pixel. Among the same lines, it should be possible for > the image pixel axes to follow the plot axes. In that mode "set yrange > [:] reverse" would plot the image right side up, and with the default > axis orientation, it would be upside down. Pixmaps are not intended as a replacement for "with image". I think of it more like placing a complicated character glyph within a page of text. You can specify where to put it, and you can make it larger or smaller, but in the end it is still the same character. Rotation, inversion, or other substantial transformation is left to images=pictures rather than to pixmaps=characters. > "set pixel height" and "set pixel size" don't play nicely with "set > yrange [:] reverse", so for instance this doesn't draw an image at all: > > set yrange [:] reverse > set pixmap 1 "/tmp/front2.png" at 0,0 height 300 > plot x Huh. That indeed looks like a bug of some sort. The requested height is still wrong there (should be <10) but yes setting yrange reverse messes up the placement. I will have a look at that. > "set pixel size" doesn't follow the docs, I think. The docs say it wants > "set pixel size A B", while it actually wants "set pixel size A,B". Note > the extra comma. yes. > I tried big images too. I THINK they work, but it's still really slow > compared to any image viewer. Is that expected? Should it be faster than > what "with rgbimage" does? "slow" when doing what? rotating in 3D? Can you do that in a normal image viewer? The difference from rgbimage is that all the "with image" commands treat the individual pixels as independent data points. They are stored and manipulated separately, taking up a lot of memory. The "pixmap" mechanism stores and dumps a whole png image, which is much more compact, possibly with rescaling. The internal storage is persistant, so it doesn't have to be read in and re-processed as new data on each plot/replot etc. So yeah, it should be faster so far as the gnuplot code is concerned. What happens after you send it to an X-server is another matter. Once it is in the x11 display list it probably doesn't make any difference how it got there. Ethan |