Alumnus of Freie Universität Berlin – Michael Grünstäudl, PhD

Successful habilitation in botany and bioinformatics

Generating automatic figure labels

Following the German motto “Ordnung ist das halbe Leben!”

Have you ever been frustrated by having to differentiate between dozens of similar graphs or figures, and the only memorable difference between them were their unique file names?

In a recent simulation study, I had exactly that feeling, so I came up with some code to automatically label figures with their file names. Here is how it works:

For example, please assume three similar graphs with the file names testResults_A.png, testResults_B.png, and testResults_C.png, respectively.

testResults_A

testResults_A

testResults_B

testResults_B

testResults_C

testResults_C

 

 

 

 

 

 

 

 

Let us annotate each figure automatically with its file name (but excluding the file type ending) using ImageMagick.

for i in $(ls *.png); do convert $i -background Orange label:${i%.png*} +swap -gravity Center -append ${i%.png*}.withAnno.png; done

 

On the top of each figure, an orange bar with the respective file name has now been added.

annotated testResults_A

annotated testResults_A

annotated testResults_B

annotated testResults_B

annotated testResults_C

annotated testResults_C

 

 

 

 

 

 

 

 

UPDATE: I found it necessary to manually set the font size in several cases. It is hereby important to set option pointsize as the first option in the list.

for i in $(ls *.png); do convert $i -pointsize 60 -background Orange label:${i%.png*} +swap -gravity Center -append ${i%.png*}.withAnno.png; done

Der Beitrag wurde am Friday, den 28. August 2015 um 15:23 Uhr von Michael Grünstäudl veröffentlicht und wurde unter audiovisual, bioinformatics abgelegt. Sie können die Kommentare zu diesem Eintrag durch den RSS 2.0 Feed verfolgen. Sie können einen Kommentar schreiben, oder einen Trackback auf Ihrer Seite einrichten.

Leave a Reply

Captcha
Refresh
Hilfe
Hinweis / Hint
Das Captcha kann Kleinbuchstaben, Ziffern und die Sonderzeichzeichen »?!#%&« enthalten.
The captcha could contain lower case, numeric characters and special characters as »!#%&«.