Visualizing RDF

I see nodes and edges...

I recently did a review of options for creating visual representations of RDF data. I didn’t just want a general visualization tool, but something that understood RDF enough to represent class instances and literal values differently. I will emphasize instances because several tools out there can read RDF schema or ontologies and create a visualization of classes and their relationships and potential properties, but I want to see instances with their property values.

My favorite ended up being the RDF Shape tool from the University of Oviedo’s WESO group in northern Spain. I also liked RDF Grapher from the Linked Data Finland project. Both let me create SVG files that I can edit with the Inkscape editor if I don’t like their algorithmic layout of a particular dataset’s RDF graph nodes. Before I go into detail about that and demonstrate some Inkscape editing, I wanted to describe some of the research I did to get there.

The W3C RDF Validation Service can create visualizations that you may recognize from W3C publications. It has been available for at least sixteen years, according to the “Last modified” date at the bottom of the page. It lets you paste some RDF into a field or enter the URL of an RDF dataset in another field, and then after you set the “Triples and/or Graph” field to include a Graph in its output, clicking the Parse button generates the image.

To test the various graph generation tools I used the ex012.ttl sample data from my book Learning SPARQL and then added a few schema.org follows triples to connect up the three people in the sample data:

d:i0432 schema:follows d:i9771. 
d:i8301 schema:follows d:i0432, d:i9771. 

The W3C RDF Validation Service created this image from that data.

RDF graph image generated by W3C Validator

The text labels are small enough to be illegible. As we’ll see, if a tool can generate SVG, like the W3C RDF Validation Service can, editing the image with an SVG editing tool might make it narrower so that it displays the labels at a more readable size (“Scalable Vector Graphics!”). For this image, though, that’s just too much editing.

An image like this is pretty common with the W3C RDF Validation Service. Also, the input must be RDF/XML, so that was another reason to look for new alternatives.

A Stack Overflow discussion provided a good starting place for research into alternatives. Some alternatives were more focused on visualizing schema and ontology classes, as I mentioned above, and others were general-purpose visualization tools that had an RDF plugin available that may or may not be up to date with the latest version of the visualization tool.

This list is where I found out about WESO RDF Shape. To learn more about that project, see its About page.

The “Data analysis and visualization” link on the RDF Shape page leads to the Data analysis form where you can paste some RDF in just about any serialization, click the blue Analyze button, and then click the Visualizations tab that appears with the result.

RDF Shape did this with the data that I used to make the previous image:

RDF graph image generated by RDF Shape

I don’t love the yellow. I could edit each individual square with the Inkscape editor and change their color, but because it’s SVG, it’s XML, which means that I could edit that directly with a text editor. I globally replaced the polygon/@fill values of “#ffff00” with “#8aeaea” and then the graph looked like this:

RDF graph image generated by RDF Shape, after global replace of color value

If you prefer a certain style of font, rectangle fill colors, or oval and rectangle outline colors, a little XSLT or even perl could turn the default RDF Shape SVG into whatever you like with similar replacements.

Using Inkscape for more hands-on editing, I moved a few shapes and arrows in that last image to make the image narrower so that it (and especially its text) can be displayed bigger, which makes the whole thing easier to read:

RDF Shape image after some Inkscape

To learn how to do these kinds of edits with Inkscape, I started with their Basic tutorial and then skipped around in the sections of their Beginners’ Guide. For editing the lines with the arrows, the section Editing Paths with the Node Tool was helpful.

I doubt that I know 5% of what Inkscape can do. Instead of writing out the important parts that I learned so that I could make the edits mentioned above, I just made a two-minute demo video:

I mentioned that in addition to the WESO RDF Shape tool, I also liked the RDF Grapher tool. Here is the RDF Grapher version of the same data as an SVG image:

RDF Grapher version of same data

Overall it’s similar to the RDF Shape version, and you have similar options for editing its SVG XML directly (for example, those five lines of text at the bottom were easy to find in the SVG XML and delete) or using Inkscape like I did in the video.

Have you found any RDF visualization tools that you really like?


Comments? Reply to my tweet (or even better, my Mastodon message) announcing this blog entry.