Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

setting absolute size of point (or circle) with autoscaled xrange

1,462 views
Skip to first unread message

fearless_fool

unread,
Feb 7, 2013, 10:26:22 AM2/7/13
to
I understand that the size of a circle or point is in units of the x axis. But what if I want to set the circle size to an absolute number of pixels, or percentage of the plot area?

In particular, what if I want to set the circle size to the same as shown in the legend?

I'm currently doing a scatter plot as shown below. I compute the circle size (shown below as 0.667) by pawing over the x values to get the min and max and scaling the size relative to that. This sort of works, except that the autoscaling limits are not the same as the minimum and maximum of the data:
=====
set terminal aqua enhanced font "Helvetica, 14"

plot "-" using 1:2:(0.667) title "{/Helvetica=12 predicted}" with circles fillstyle solid noborder linecolor rgb "#ff4444"
9.0 26870.488225
10.74 26622.450975
12.48 26375.879575
...
94.26 17585.44715
end
=====
Another approach would be do to a dry run (i.e. "set table /dev/null; plot etc; unset table") and capture the values of GPVAL_XMIN and GPVAL_XMAX to see where autoscaling set them, then scale the circle size accordingly.

(I'd hoped I could do something like '... with circles size screen 0.01 ...' but no luck.)

Is there an easier way?

sfeam

unread,
Feb 7, 2013, 12:04:31 PM2/7/13
to
fearless_fool wrote:

> I understand that the size of a circle or point is in units of the x
> axis. But what if I want to set the circle size to an absolute number
> of pixels, or percentage of the plot area?

See "help set style circle"

set style circle radius screen 0.01
plot "-" using 1:2 with circles

Ethan

fearless_fool

unread,
Feb 7, 2013, 12:23:10 PM2/7/13
to sf...@users.sourceforge.net
On Thursday, 7 February 2013 09:04:31 UTC-8, sfeam wrote:
> See "help set style circle"
>
> set style circle radius screen 0.01
> plot "-" using 1:2 with circles

Well, heck yeah! That IS a lot easier -- thank you.

To push the question a bit further: If I want to use *two* different circle styles whose sizes are given in terms of screen coordinates, is there a way to set up multiple styles? Conceptually along the lines of (yeah, I know this doesn't actually work):

set style circle1 radius screen 0.01 fillstyle solid noborder linecolor rgb "#666666"
set style circle2 radius screen 0.015 fillstyle solid noborder linecolor rgb "#ff4444"

plot "-" using 1:2 title "actual" with circles1, \
"-" using 1:2 title "predicted" with circles2
2011-01-03 39415.0
2011-01-04 36220.0
2011-01-05 35065.0
...
end
2011-01-03 39000.0
2011-01-04 36000.0
2011-01-05 35000.0
...
end

sfeam

unread,
Feb 7, 2013, 1:29:00 PM2/7/13
to
fearless_fool wrote:

> On Thursday, 7 February 2013 09:04:31 UTC-8, sfeam wrote:
>> See "help set style circle"
>>
>> set style circle radius screen 0.01
>> plot "-" using 1:2 with circles
>
> Well, heck yeah! That IS a lot easier -- thank you.
>
> To push the question a bit further: If I want to use *two* different
> circle styles whose sizes are given in terms of screen coordinates, is
> there a way to set up multiple styles? Conceptually along the lines of
> (yeah, I know this doesn't actually work):

You could fake it by plotting one case with circles and the other case
with ellipses that just happen to be circular:

set style circle radius screen 0.01
set style ellipse size screen 0.02, screen 0.02 units xx

But if you want a third case then you're out of luck :-)

Ethan

fearless_fool

unread,
Feb 7, 2013, 1:36:37 PM2/7/13
to sf...@users.sourceforge.net
On Thursday, 7 February 2013 10:29:00 UTC-8, sfeam wrote:
> You could fake it by plotting one case with circles and the other case
> with ellipses that just happen to be circular:
> set style circle radius screen 0.01
> set style ellipse size screen 0.02, screen 0.02 units xx
>
> But if you want a third case then you're out of luck :-)
>
> Ethan

VERY cute!! :) I'm guessing, though, that to handle the general case with N overlaid scatterplots, I should use the "do a dummy plot to capture GPVAL_XMIN and GPVAL_XMAX and scale accordingly". Thinking about it, that technique is probably not as difficult as I first imagined.

fearless_fool

unread,
Feb 7, 2013, 1:55:59 PM2/7/13
to sf...@users.sourceforge.net
On Thursday, 7 February 2013 10:36:37 UTC-8, fearless_fool wrote:
> to handle the general case with N overlaid scatterplots,
> I should use the "do a dummy plot to capture GPVAL_XMIN
> and GPVAL_XMAX and scale accordingly".

I found a problem with this: the setting GPVAL_X_{MIN MAX} doesn't honor autoscaling when printing to a table. In particular:

=====
set terminal aqua enhanced font "Helvetica, 14"

set table '/dev/null'
plot "-" using 1:2 title "predicted" with circles fillstyle solid noborder linecolor rgb "#ff4444"
9.0 26870.488225
94.26 17585.44715
end
unset table
print 'after plotting to /dev/null, GPVAL_X_MIN = ', GPVAL_X_MIN, ", GPVAL_X_MAX = ", GPVAL_X_MAX

plot "-" using 1:2 title "{/Helvetica=12 predicted}" with circles fillstyle solid noborder linecolor rgb "#ff4444"
9.0 26870.488225
94.26 17585.44715
end
print 'after plotting to screen, GPVAL_X_MIN = ', GPVAL_X_MIN, ", GPVAL_X_MAX = ", GPVAL_X_MAX
=====
produces
=====
after plotting to /dev/null, GPVAL_X_MIN = 9.0, GPVAL_X_MAX = 94.26
after plotting to screen, GPVAL_X_MIN = 0.0, GPVAL_X_MAX = 100.0
=====

For now, will use (94.26 - 9.0) as my scaling constant rather than the more accurate (100.0 - 0.0). But is there a way to find out what the autoscale limits WOULD get set to if I were printing to the screen (rather than to /dev/null)?

P.S. FWIW, I'm now running gnuplot 4.6 patchlevel 1.

sfeam

unread,
Feb 7, 2013, 4:31:56 PM2/7/13
to
If it were me, I'd probably use

SCALE = <something to be decided by inspection>

plot 'foo' using 1:2:(SCALE*column(3)) with points \
pointtype 6 pointsize variable

See also

http://gnuplot.sourceforge.net/demo/pointsize.html
0 new messages