No lines in SVG from Gnuplot

Using Inkscape with other software? Talk about it here.
barney

No lines in SVG from Gnuplot

Postby barney » Mon Dec 22, 2008 9:41 am

Hi, I'm trying to export charts from Gnuplot and then edit / enhance them in Inkscape. Problem is, the lines don't seem to appear in Inkscape. When I open the same svg file in Konqueror or Firefox, I see all the lines as I expect. But Inkscape seems to think that the line stroke is not defined.

My gnuplot code is as follows:

Code: Select all

set terminal svg size 800 600
set out "test.svg"
plot sin(x)
and this gives me a file called test.svg. This looks fine in Konqueror and Firefox, with black lines around the chart and a red line for the sine curve. But everything is white in Inkscape apart from the labels on the axes and the "sin(x)" label for the data. If I do edit-select all, and under object-fill and stroke set the stroke paint to flat black, then I see the lines ok (but they're all black, of course).

I can post the generated svg if necessary (it's 7k), but I think the pertinent bit is this:

Code: Select all

<g style="fill:none; color:red; stroke:currentColor; stroke-width:1.00; stroke-linecap:butt; stroke-linejoin:miter">
   <path d='M715.6,34.6 L757.8,34.6 M58.8,141.4 L66.0,190.5 L73.3,243.7 L80.5,298.7 L87.7,353.5 L94.9,405.6
      L102.2,453.1 L109.4,493.9 L116.6,526.5 L123.9,549.4 L131.1,561.8 L138.3,563.2 L145.5,553.5 L152.8,533.0 ...

So it seems the color is red, but maybe the "currentColor" is putting Inkscape off?

Any ideas how I can fix this, either with extra commands to gnuplot or modification of the svg before opening in Inkscape, or some trick in Inkscape maybe?

System: Mandriva 2008.1, KDE, Gnuplot 4.2.2, Inkscape 0.46

bbyak
Posts: 64
Joined: Sun Oct 07, 2007 4:53 am

Re: No lines in SVG from Gnuplot

Postby bbyak » Thu Dec 25, 2008 2:07 pm

currentColor rendering is fixed in SVN version, try it

barney

Re: No lines in SVG from Gnuplot

Postby barney » Mon Dec 29, 2008 7:47 am

Thanks for the tip, I will try and find some time to do some compilation to see if that is fixed.
However, that wouldn't solve my problem even if it worked. You see, I'm trying to build a charting function onto a piece of GPS-related software, and I'm using gnuplot to generate the charts (like altitude against distance, for example). And I want to recommend a tool to take the svg file and edit / annotate / enhance the svg file, do any conversions or whatever. If to get that to work I have to recommend that people take testing code out of subversion and compile it themselves to get a version of inkscape which will do it, that will never fly. That is why I would prefer a solution which:
1) Calls gnuplot with some extra parameters so that it can be seen in Inkscape (preferred solution)
2) Does some trick with Inkscape to make the output visible (preferred solution)
3) Does some alteration of the svg output inbetween so that Inkscape can render and modify it (not quite-so-preferred solution because then my program would have to accept the svg stream, alter it on the fly and do the file writing itself, rather than just let gnuplot write out the file).

barney

Re: No lines in SVG from Gnuplot

Postby barney » Sun Jan 11, 2009 11:13 pm

So it seems there's no solution which doesn't involve compiling svn code?
According to the gnuplot guys this bug was fixed in sodipodi a while ago but unfortunately not yet available in inkscape - shame.

I did some experimenting though and found out that the following replacement offers a workaround for this bug:

Code: Select all

sed -i -e "s/stroke:currentColor/stroke:black/g" blah.svg

Of course that hack only works if sed is available. And as I said I'd rather not mangle the svg on-the-fly.

bbyak
Posts: 64
Joined: Sun Oct 07, 2007 4:53 am

Re: No lines in SVG from Gnuplot

Postby bbyak » Mon Jan 12, 2009 7:56 am

You just need to wait for 0.47. Or you can point your users to daily binaries which exist at least for Windows, and for some Linux distros as well. Or you can compile it yourself and distribute as part of your solution to them.

As for Sodipodi fix, I would really appreciate a pointer. I think we have carefully lifted all useful fixes that appeared in Sodipodi between Inkscape fork and the death of Sodipodi. There were very few of them anyway.

barney

Re: No lines in SVG from Gnuplot

Postby barney » Mon Jan 12, 2009 10:20 am

Thanks, but I don't want to recommend daily builds and I don't want to compile and distribute Inkscape. I'd prefer a "lower-intensity" hack ;)

As for Sodipodi fix, I would really appreciate a pointer. I think we have carefully lifted all useful fixes that appeared in Sodipodi between Inkscape fork and the death of Sodipodi. There were very few of them anyway.
I'm afraid I don't know much more than this, this is just what I was told on the gnuplot newsgroup:
We worked with the sodipodi developers to fix a number of bugs that
caused it to render gnuplot output incorrectly. Unfortunately, when
inkscape was forked from sodipodi, these fixes were lost.
I suggest that you file new bug reports against inkscape.

I do not remember all the details, but I think the main issue was
proper inheritance of "currentcolor" and other state variables.

I also found a bug report sounding very similar to my problem, but dating back to 2007: https://bugs.launchpad.net/inkscape/+bug/174720

maarten

Re: No lines in SVG from Gnuplot

Postby maarten » Fri Jan 30, 2009 1:52 am

Hi Barney,

something that works for me is:
* select all objects (ctrl-a)
* drag on a corner to resize
* undo (ctrl-z)
then the previously invisible objects become visible. As soon as I try to put things in a layer and lock the layer, they disappear again, unfortunately.
hope this helps,

maarten

barney

Re: No lines in SVG from Gnuplot

Postby barney » Mon Feb 09, 2009 8:26 am

Wow, you're right! But I think you've found another rendering bug, rather than a solution!

If I do as you suggest, I can see the lines again, but if I save it as an svg and then reopen it, the lines are gone again.
On the other hand, if I export a bitmap to a png file, I get no lines before I try your trick, and afterwards I get the lines in the png file! Crazy.
Similarly the lines appear in pdfs after doing this trick, whereas beforehand they were missing. So this is a way to get the lines back, depending on what you want to do with the file. But I can't say I like it....
Thanks for the tip though!

djeedai

Re: No lines in SVG from Gnuplot

Postby djeedai » Wed Feb 18, 2009 11:15 am

barney wrote:I did some experimenting though and found out that the following replacement offers a workaround for this bug:

Code: Select all

sed -i -e "s/stroke:currentColor/stroke:black/g" blah.svg

Of course that hack only works if sed is available. And as I said I'd rather not mangle the svg on-the-fly.


A better -- temporary -- fix would be to use the "color" attribute to fill the "stroke" color. As Gnuplot seems to always put a "color" attribute just before the "stroke" one, the following sed fix can be used, preserving colors:

Code: Select all

cat input.svg | sed -e 's/color:\([^;]*\);\s*stroke:[^;]*;/color:\1; stroke:\1;/' > output.svg


Hope this helps,

vanzandtj

Re: No lines in SVG from Gnuplot

Postby vanzandtj » Sat Sep 12, 2009 4:36 am

Here's a version in perl that modifies a file in place:

perl -p -i -e 's/color:([^;]*);\s*stroke:[^;]*;/color:$1; stroke:$1;/' blah.svg


Return to “Inkscape & other”