|
From: Dima K. <gn...@di...> - 2018-11-07 01:38:19
Attachments:
wide.png
|
Hi. I have a very VERY non-square image file (attached). This is a 4000x20 png. I want to use gnuplot to plot it with a square aspect ratio. (In my actual use case, I'd plot stuff on top of it). I do this: set size ratio -1 plot "wide.png" binary filetype=auto with rgbimage Normally this works, but with such a wide image the "set size ratio -1" doesn't work: the image is scaled to fill the plot, and I get very tall and very skinny pixels. If I zoom in with Ctrl-Shift-MouseWheelUp then it gets unconfused after a few cycles. I bet there's something hardcoded in the scaling logic. Can somebody please take a look? |
|
From: Dima K. <gn...@di...> - 2018-11-07 05:03:29
Attachments:
40x20.png
|
Ethan Merritt <me...@uw...> writes: >> I have a very VERY non-square image file (attached). This is a 4000x20 >> png. I want to use gnuplot to plot it with a square aspect ratio. (In my >> actual use case, I'd plot stuff on top of it). I do this: >> >> set size ratio -1 >> plot "wide.png" binary filetype=auto with rgbimage >> >> Normally this works, but with such a wide image the "set size ratio -1" >> doesn't work: the image is scaled to fill the plot, and I get very tall >> and very skinny pixels. > > I do not understand the problem. > Of course the pixels are very tall and skinny, since there are 4000 > of them in one direction and only 20 in the other. Hi. I want a square aspect ratio of the thing being plotted (size ratio -1). This means: - square pixels - the image rendered by gnuplot should thus look like the input image: it should be very wide; i.e. not square The other mode is "size ratio 1" (or equivalently "size square"), which sets a square aspect ratio on the resulting image by making the pixels non-square. I'm attaching a less skewed image, so that you can see that "size ratio -1" is indeed the right thing. The issue here is that gnuplot behaves differently with the extra-wide image. |
|
From: sfeam <me...@uw...> - 2018-11-07 06:26:12
|
On Tuesday, 06 November 2018 20:46:31 Dima Kogan wrote:
>
> Ethan Merritt <me...@uw...> writes:
>
> >> I have a very VERY non-square image file (attached). This is a 4000x20
> >> png. I want to use gnuplot to plot it with a square aspect ratio. (In my
> >> actual use case, I'd plot stuff on top of it). I do this:
> >>
> >> set size ratio -1
> >> plot "wide.png" binary filetype=auto with rgbimage
> >>
> >> Normally this works, but with such a wide image the "set size ratio -1"
> >> doesn't work: the image is scaled to fill the plot, and I get very tall
> >> and very skinny pixels.
> >
> > I do not understand the problem.
> > Of course the pixels are very tall and skinny, since there are 4000
> > of them in one direction and only 20 in the other.
>
> Hi.
>
> I want a square aspect ratio of the thing being plotted (size ratio -1).
> This means:
>
> - square pixels
> - the image rendered by gnuplot should thus look like the input image:
> it should be very wide; i.e. not square
Ah, I understand now.
Yes there is a sanity check on the aspect ratio that limits it to a
ratio of 1:100. That code dates waayyy back and I don't know what
logic went into deciding this was the limit.
You could try changing it to, say, 1:1000.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
diff --git a/src/boundary.c b/src/boundary.c
index b096410..85a7f20 100644
--- a/src/boundary.c
+++ b/src/boundary.c
@@ -629,7 +629,7 @@ boundary(struct curve_points *plots, int count)
/* Set aspect ratio if valid and sensible */
/* EAM Mar 2008 - fixed borders take precedence over centering */
- if (current_aspect_ratio >= 0.01 && current_aspect_ratio <= 100.0) {
+ if (current_aspect_ratio >= 0.001 && current_aspect_ratio <= 1000.0) {
double current = ((double) (plot_bounds.ytop - plot_bounds.ybot))
/ (plot_bounds.xright - plot_bounds.xleft);
double required = (current_aspect_ratio * t->v_tic) / t->h_tic;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
cheers,
Ethan
>
> The other mode is "size ratio 1" (or equivalently "size square"), which
> sets a square aspect ratio on the resulting image by making the pixels
> non-square.
>
> I'm attaching a less skewed image, so that you can see that "size ratio
> -1" is indeed the right thing. The issue here is that gnuplot behaves
> differently with the extra-wide image.
>
>
|
|
From: Dima K. <gn...@di...> - 2018-11-08 05:47:16
|
sfeam <me...@uw...> writes:
> Right now the code is
>
> if (too-big)
> warn
> else
> apply the correcion
>
> I suppose the alternative is to remove the "else". I.e. warn on the
> extreme case so that if there is a divide-by-zero or other bad outcome
> at least you have some hint as to what went wrong.
>
> Would you prefer that?
Maybe? The wide images that previously would be rejected appear to work
just fine after your patch (i.e. they're expectedly illegible, but you
can interactively zoom in as expected). So yeah. This logic probably is
what I favor (until we find something that breaks):
if (too-big)
warn
do-the-thing;
Thanks much
|
|
From: Dima K. <gn...@di...> - 2018-11-08 03:29:16
|
sfeam <me...@uw...> writes: > Ah, I understand now. Yes there is a sanity check on the aspect ratio > that limits it to a ratio of 1:100. That code dates waayyy back and I > don't know what logic went into deciding this was the limit. You could > try changing it to, say, 1:1000. Hi Ethan. I just went to look at this, and it looks like you applied a patch already. Thanks! I don't quite understand why this limit is there at all. As long as the aspect ratio is > 0 and < infinity, I think we should accept it. I hit this through normal usage, and I can imagine hitting even the more extreme limit at some point later. My use case is this: - I'm plotting an image with annotations plotted on top (points, lines, etc). - The initial plot indeed has a crazy aspect ratio, and isn't very useful. But I can clearly see the annotations, and I can then interactively zoom into the area with the annotations, producing a useful plot. The square aspect ratio is preserved by the zoom operation Unless something predictable will break, maybe the limit should go away, or become much larger? |