Here's an example of a figure made of three separate graphs, combined and cleaned up in Inkscape.
If you’re going to publish a graph or a model, you want something that looks clean and professional. But R output, like graphs or a various plots, often don’t come out the way you want. Even if you’re a wiz at manipulating the plot command, you can probably still see room for improvement. How many times have you spent 30 minutes or more trying to figure out what parameter moves you label over 3 pixels, all the while dreaming that you could just reach into the computer and move the little bugger yourself? I have the solution! Here’s how you do it:
- Write your script in R to generate whatever plot or image you need. Make sure all the labels are in there that you need R to generate. Today I’m making ordination plots with the vegan package.
Here's an example of a typical output from R. It's generally ok, but wouldn't you want to move some stuff around?
- Save the plot as a PDF file. To save it, activate the plot window -> File -> Save As -> PDF (I mean it. Not an image file, but a PDF. And I know it looks ugly, but we’ll fix it later.) NOTE: Make sure you don’t resize the image window before you save the file. In the past I’ve had some funny things happen (like letters rotating 180°) if I tried to resize it before I saved it. We’ll do any resizing later.
- Open up your favorite vector illustration software. I like Inkscape because it works and it’s free/open source. I highly recommend it.
- In Inkscape, File -> Open -> Find your PDF -> click OK -> pick the settings you like in the dialog that pops up -> click OK.
- Save it as an SVG file. You’ll be saving now in Inkscape’s native format and have the original PDF in case you need to go back to the start.
- Now is the fun part… you get to make the image look better. There are some tricks…
- If you can’t select something, like a text box, it’s probably a part of a group. The bottom of the screen will tell you if you’ve selected a group. To fix this, just click the Ungroup button. For example, everything that falls inside the plot area gets grouped – so all the points, lines, and even a white box that you probably don’t even notice are in a group.
- Layers are your friend. Put each type of item in it’s own layer. For example, I like to put my axes in one layer, my graphed points in another, all the labels in another, etc.
- Ctrl + Alt + V (paste in place) is your other friend. Use it to remove items from one layer into another without messing up the alignment.
- Did the import turn all of your points into something strange like q’ s? Mine did. Use the “Replace Text” tool in the Extension menu under Text. If you change all you “q” points into “o”, you can then convert the o’s to paths and fill them with black so they look like points.
- Finally, export your image or save it as a new PDF.
I was thinking about how many software tools I use that are somewhat off the beaten trail and thought I would make a list of the tools I use often. I thought it might be a good reference so in case I forget to link something later, the information is here.
I like using open source tools. Not only are they free, but I find in many cases that the development and bug fixes go much more quickly in open source projects than in their proprietary cousins. I’m not a programmer (well, I program in R, but that’s not the same kind of programming as big applications), so I appreciate that others are and that they put their time into these tools and that they do it free of cost. The following tools come highly recommended by me for use in graphic art, photography, geospatial science, and their intersection – cartography.
- Quantum GIS – a powerful geographic information system program for spatial analysis and data visualization
- Inkscape – a vector illustration software similar to Adobe Illustrator (so I’ve heard… never worked with AI myself).
- Gimp – a raster editor similar to Adobe Photoshop (again, I haven’t worked with Photoshop)
- XnView – a photo organizer and editor, good for quick fixes and batch processing
- Hugin – a photo panorama stitching software that I use to stitch my air photos into one scene; works much better on standard panoramas than what I try to get it to do
- R – Stats software; you can get graphical interfaces for it, but writing scripts isn’t too complicated (and this is coming from a person with a loathing for command line).
Since I’ve started my research, I’ve been fascinated by the way different researchers represent their data. I am particularly drawn to simple, elegant, and effective diagrams. I think these kinds of images are not only science, but art. This one is from Figure 3A from “Synecology of Beach Vegetation Along the Pacific Coast of the United States of America: A First Approximation” published in the Journal of Biogeography vol. 3 no. 1 by Barbour, DeJong, & Johnson (1976). The smooth graph at the top of each section shows a cross-section of the beach and below it is a histogram of where each species showed up along this profile. It makes it really easy to see which species tend to occur near the front or back of the beach. My goal is to produce similar diagrams for my data. I wonder though how it could be made easier to understand. What are your thoughts for improving this kind of diagram?