Mar 12, 2012

Creating a colorbrewer palette for libreoffice

I am trying to draw a timeline of reproductive events in a woman's life for my dissertation. Turns out there are two so-so tools for this chore. The online tool is at lucidchart.com but the more accessible offline tool is... don't hold your breath. Libreoffice draw. (Btw, I have decided NEVER ever to draw with Libreoffice again. It is MOST painful to allign objects, fonts don't behave. EVERY single thing is crappy.)

The useful thing about libreoffice is that I can make my own color palettes for my drawings. The inbuilt and other downloadable color palettes I found were either too detailed or too ugly. I have been seeing ColorBrewer used to great effect in many graphical presentations of late, so I set about making a libreoffice palette with Colorbrewer colors.

I found the complete ColorBrewer set at this page at google code.

The idea is to take this code and transform it into a .soc file in the hidden directory: .libreoffice/3/user/config I know this is a perl script waiting to be written. But perl teething troubles lead to a quick and dirty cut-and-paste-the-manual-way-in-10-seconds.

The soc file code for libreoffice with the Spectral diverging 11 palette from Colorbrewer looks somewhat like this:


<?xml version="1.0" encoding="UTF-8"?>
<office:color-table xmlns:office="http://openoffice.org/2000/office" xmlns:style="http://openoffice.org/2000/style" xmlns:text="http://openoffice.org/2000/text" xmlns:table="http://openoffice.org/2000/table" xmlns:draw="http://openoffice.org/2000/drawing" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="http://openoffice.org/2000/meta" xmlns:number="http://openoffice.org/2000/datastyle" xmlns:svg="http://www.w3.org/2000/svg" xmlns:chart="http://openoffice.org/2000/chart" xmlns:dr3d="http://openoffice.org/2000/dr3d" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="http://openoffice.org/2000/form" xmlns:script="http://openoffice.org/2000/script">
<draw:color draw:name="SpectralDiv11A" draw:color="#9E0142"/>
<draw:color draw:name="SpectralDiv11B" draw:color="#D53E4F"/>
<draw:color draw:name="SpectralDiv11D" draw:color="#F46D43"/>
<draw:color draw:name="SpectralDiv11F" draw:color="#FDAE61"/>
<draw:color draw:name="SpectralDiv11G" draw:color="#FEE08B"/>
<draw:color draw:name="SpectralDiv11H" draw:color="#FFFFBF"/>
<draw:color draw:name="SpectralDiv11I" draw:color="#E6F598"/>
<draw:color draw:name="SpectralDiv11J" draw:color="#ABDDA4"/>
<draw:color draw:name="SpectralDiv11L" draw:color="#66C2A5"/>
<draw:color draw:name="SpectralDiv11N" draw:color="#3288BD"/>
<draw:color draw:name="SpectralDiv11O" draw:color="#5E4FA2"/>
</office:color-table>



The complete color palette series in Colorbrewer is:


maxcolors category
BrBG 11 div
PiYG 11 div
PRGn 11 div
PuOr 11 div
RdBu 11 div
RdGy 11 div
RdYlBu 11 div
RdYlGn 11 div
Spectral 11 div
Accent 8 qual
Dark2 8 qual
Paired 12 qual
Pastel1 9 qual
Pastel2 8 qual
Set1 9 qual
Set2 8 qual
Set3 12 qual
Blues 9 seq
BuGn 9 seq
BuPu 9 seq
GnBu 9 seq
Greens 9 seq
Greys 9 seq
Oranges 9 seq
OrRd 9 seq
PuBu 9 seq
PuBuGn 9 seq
PuRd 9 seq
Purples 9 seq
RdPu 9 seq
Reds 9 seq
YlGn 9 seq
YlGnBu 9 seq
YlOrBr 9 seq
YlOrRd 9 seq


This is from the R graphics manual help page. Maybe the names for the color palette's individual colors can come from here.

Now, let's see if I can make reproductive histories pretty.

---
NB2: Escaped the raw HTML characters with this online tool.

0 Comments:

Post a Comment