I know gnuplot can write SVG, but can write on top of an existing SVG
file?
I'm currently using the "with rgbimage" functionality to draw tracks on
top of "tiles" from OpenStreetMap. In this example osmfile.rgb is a
521x768 pixel rectangle of map (converted into rgb format),
trackdata.dat is a file of latitude/longitude pairs describing a route,
and convert_lon()/convert_lat() are relatively simple gnuplot functions
that convert longitude and latitude to graph coordinates.
+----------------------------------------------------------------------
|set size ratio 768/512
|plot [0:512] [0:768]\
| "osmfile.rgb" binary array = 512x768\
| flipy format='%uchar' with rgbimage t "",\
| "trackdat.dat" u (convert_lon($2)):(convert_lat($1)) w l
+----------------------------------------------------------------------
This works nicely but is dependent on the resolution of the original
image.
Is there an analogous way of using SVG map images?
Brendan
--
Brendan Halpin, Department of Sociology, University of Limerick, Ireland
Tel: w +353-61-213147 f +353-61-202569 h +353-61-338562; Room F2-025 x 3147
mailto:brendan.halpin@ul.ie http://www.ul.ie/sociology/brendan.halpin.html
|
|
0
|
|
|
|
Reply
|
brendan.halpin (15)
|
11/4/2009 2:35:26 PM |
|
Brendan Halpin wrote:
> I know gnuplot can write SVG, but can write on top of an existing SVG
> file?
No, but it doesn't seem that really what you want to do.
> I'm currently using the "with rgbimage" functionality to draw tracks
> on top of "tiles" from OpenStreetMap. In this example osmfile.rgb is a
> 521x768 pixel rectangle of map (converted into rgb format),
> trackdata.dat is a file of latitude/longitude pairs describing a
> route, and convert_lon()/convert_lat() are relatively simple gnuplot
> functions that convert longitude and latitude to graph coordinates.
>
> +----------------------------------------------------------------------
> |set size ratio 768/512
> |plot [0:512] [0:768]\
> | "osmfile.rgb" binary array = 512x768\
> | flipy format='%uchar' with rgbimage t "",\
> | "trackdat.dat" u (convert_lon($2)):(convert_lat($1)) w l
> +----------------------------------------------------------------------
>
> This works nicely but is dependent on the resolution of the original
> image.
>
> Is there an analogous way of using SVG map images?
The SVG spec allows incorporation of images in other formats, and
that is an obvious way in which gnuplot's svg support could be extended.
But as of now you would have to edit by hand the svg file coming out
of gnuplot. Several projects have used image mapping in combination
with output from the gnuplot PNG terminal, so I believe that you can
persuade gnuplot to print out the relevant coordinate scales and offset
information.
If you come up with a hand-edited svg file that demonstrates what you
would like, please upload it to the "Feature Requests" section of the
gnuplot development site on SourceForge. It is useful to have a
specific target when adding new features.
However,...
I'm afraid that work on the svg terminal has pretty much stalled
recently, for two reasons.
(1) The various svg-aware tools out there (webkit, gecko, inkscape,
openoffice) disagree with each other as to which parts of the svg
standard to implement. This makes it really hard to produce
svg output that is accepted by all of them. Worse, it's a moving target.
A year ago gnuplot output looked great when rendered by ksvg
(parallel track of webkit), but in the interim some change to ksvg
has broken it.
(2) For web-based applications, the new HTML5 canvas terminal is more
capable than the svg terminal, and HTML5 support is gaining ground
rapidly in the various browsers. My personal impression is that svg
has lost the race, and development effort is better spent elsewhere.
Of course, HTML5 is not an answer for svg applications that
don't involve the web.
>
> Brendan
|
|
0
|
|
|
|
Reply
|
sfeam
|
11/4/2009 5:14:29 PM
|
|
Thanks for the informative response.
On Wed, Nov 04 2009, sfeam wrote:
> so I believe that you can
> persuade gnuplot to print out the relevant coordinate scales and offset
> information.
That would be very useful. Any hints?
Brendan
--
Brendan Halpin, Department of Sociology, University of Limerick, Ireland
Tel: w +353-61-213147 f +353-61-202569 h +353-61-338562; Room F2-025 x 3147
mailto:brendan.halpin@ul.ie http://www.ul.ie/sociology/brendan.halpin.html
|
|
0
|
|
|
|
Reply
|
Brendan
|
11/4/2009 5:50:38 PM
|
|
Brendan Halpin wrote:
> Thanks for the informative response.
>
> On Wed, Nov 04 2009, sfeam wrote:
>
>> so I believe that you can
>> persuade gnuplot to print out the relevant coordinate scales and offset
>> information.
>
> That would be very useful. Any hints?
At the completion of each "plot" command, the following series
of user-accessible variables are defined.
The axis ranges used in the plot (equivalent to "show xrange", etc)
GPVAL_X_MIN
GPVAL_X_MAX
GPVAL_Y_MIN
GPVAL_Y_MAX
The pixel coordinates of the rectangular area defined by the X and Y
axes in the plot.
GPVAL_TERM_XMIN
GPVAL_TERM_XMAX
GPVAL_TERM_YMIN
GPVAL_TERM_YMAX
If needed, you should already know the total range of pixels used
by the plot, because you set it in the "set term" command.
Suppose you say
set term png size 500,300
set output 'sin.png'
plot sin(x)
The lower left corner of the graph corresponds to graph coordinates
[-10,-1] = [GPVAL_X_MIN, GPVAL_Y_MIN] because that's what gnuplot
chooses if you let everything default and say "plot sin(x)".
In the pixel coordinates of the output image (sin.png in this case),
this corresponds to pixel [GPVAL_TERM_XMIN, GPVAL_TERM_YMIN], which
happens to be [62,36] when I try it here but will change depending on
the font size used for labels, etc.
You can write these values to a file by saying
set print "plot.stats"
print GPVAL_X_MIN, GPVAL_X_MAX, GPVAL_Y_MIN, GPVAL_Y_MAX
and so on. If you want to get fancy, you could write these in
the form of an image map description. Otherwise you could use
a separate script to generate the HTML or SVG commands from the
bare numbers.
These variables were added at the suggestion of Allin Cottrell,
who wanted them for this same purpose as I recall. So he might
be able to provide example scripts.
The HTML5 canvas terminal writes these same values directly into the
output javascript used to draw the plot, so they can be used for
mouse tracking and rescaling. You might find that script useful as
a model. An online example is at
http://gnuplot.sourceforge.net/demo_canvas/
But I have never been able to get the equivalent mouse tracking to
work in svg, although I also never understood why not :-(
But that is a somewhat separate question from handling mouse input
via an image map. In either case, if you come up with a working
example, I'd be happy to consider using it as a template for direct
output into the *.svg file produced by the terminal driver.
|
|
0
|
|
|
|
Reply
|
sfeam
|
11/5/2009 1:36:19 AM
|
|
On Thu, Nov 05 2009, sfeam wrote:
> At the completion of each "plot" command, the following series
> of user-accessible variables are defined.
> The axis ranges used in the plot (equivalent to "show xrange", etc)
> GPVAL_X_MIN
> GPVAL_X_MAX
> GPVAL_Y_MIN
> GPVAL_Y_MAX
> The pixel coordinates of the rectangular area defined by the X and Y
> axes in the plot.
> GPVAL_TERM_XMIN
> GPVAL_TERM_XMAX
> GPVAL_TERM_YMIN
> GPVAL_TERM_YMAX
Very useful. In the Debian default version of gnuplot (4.2-6) I get the
GPVAL_X_* but no GPVAL_TERM_* -- I presume I need 4.3. Is that packaged
for Debian anywhere?
> http://gnuplot.sourceforge.net/demo_canvas/
That's got lots of potential. Thanks for the pointer.
Brendan
--
Brendan Halpin, Department of Sociology, University of Limerick, Ireland
Tel: w +353-61-213147 f +353-61-202569 h +353-61-338562; Room F2-025 x 3147
mailto:brendan.halpin@ul.ie http://www.ul.ie/sociology/brendan.halpin.html
|
|
0
|
|
|
|
Reply
|
Brendan
|
11/5/2009 9:23:22 AM
|
|
|
4 Replies
391 Views
(page loaded in 0.539 seconds)
|