Inkscape and Grace oddities for science

Here’s a quick post about a couple of oddities and problems I encountered recently in Inkscape and Grace (on a Mac) in using them for preparing scientific plots. This kind of stuff isn’t especially well-documented online — it seems like people using these programs for this purpose often figure out a way that works for them and keep quiet about it. Also Grace in particular isn’t being developed at too fast a pace right now. Here we go:

  • Exporting an EPS (or PDF or SVG) from Grace and then importing the file into Inkscape results in the fonts being changed from Times (Grace’s default) to some horrible sans-serif font in Inkscape, and the spacing being all screwed up. As explained and solved here (in relation to Matlab) this happens because Inkscape can’t access the Times font used by Grace (although weirdly it knows `Times New Roman’ which looks the same). So when it looks for the font referred to in the PDF you imported from Grace, it can’t find it, and just fudges it. Using Fondu to create a version of Times that Inkscape can use solves the issue.
  • On Mac OS X Mavericks, installing Grace either via MacPorts or from source results in a couple of problems. 1) Thanks to updated Xcode tools, invalid arguments passed to the compiler generate an error not a warning and compile can fail. Apparently you can get around this by setting an environment variable, but it didn’t work for me. In Grace the problem is an `-m486′ flag which is passed to the compiler. I opened the configure script for Grace (or in MacPorts, the associated Portfile) and removed all mention of -m486 to stop this happening. 2) Once compiled, Grace on Mavericks seems to get a segmentation fault and crash on opening. This can be fixed in a hacky way by altering all mentions of the optimisation -O2 in the configure script to -O1. Or replacing a library helps to solve it properly, but I haven’t got round to that yet.
  • In Inkscape, copy and duplicate are different. If you create nice clean text or a nice clean line or circle etc, and then ctrl-c ctrl-v like usual, the pasted object no longer seems to be like a vector and will be fuzzy when you zoom in. I’ve no idea why this is but I’m sure there’s a good reason. Anyway, using ctrl-d to duplicate instead preserves the nice vectory sharpness of the original object. Given the amount of copying and pasting that goes on in making my scientific diagrams, this was quite important to find out. This seems to make it more difficult to copy an object between different files, since ctrl-c ctrl-v works (but looks crap) whereas I can’t currently find out how to `duplicate’ an object between files.
  • On opening an EPS or PDF you made with Inkscape at a later date in Inkscape, you may find that all the separate objects you had before behave as one object so it’s hard to remove or alter individual ones. You might end up using a nasty solution like a plain white box to block out bits you want to delete but can’t. This doesn’t seem to happen Inkscape’s native SVG format. If for whatever reason you don’t have the original SVG, sometimes it’s possible to select the single object in the imported EPS and then click `Object->Ungroup’. You can do this a few times to try and separate the different elements so they can be accessed one at a time. This is useful if e.g. you want to alter a figure somehow and don’t have the SVG.

I’m sure there will be experts who know more about these various issues — I’d be grateful for any more light shed. But hopefully someone who is experiencing any of these problems might find these quick and dirty solutions helpful sometime.

Advertisements