arklumpus / TreeViewer

Cross-platform software to draw phylogenetic trees
GNU Affero General Public License v3.0
188 stars 9 forks source link

Partially italicize node labels #22

Closed lxsteiner closed 8 months ago

lxsteiner commented 9 months ago

Thank you for the program, it's so powerful and easy to manipulate trees! The tutorials are super useful!

I wanted to ask if there is another way to italicize leaf node labels. I've found ways to add genus and species names easily, but often these need to contain strain or accession ID information as well (e.g. one of your examples: https://raw.githubusercontent.com/wiki/arklumpus/TreeViewer/Cyanobacteria_support_legend.svg). Is it even possible to italicize only part of the attribute?

A naive workaround would be to separate the non-italicized attributes and add them as a separate node label, then add them to the end (or anywhere after) the genus species label by adjusting the X-axis position. This does create some issues or larger gaps since it depends on the length of the branches and position of individual nodes with the 1st label. Any other way how I could anchor the 2nd label right after the position of the first label without manually adjusting the X-axis position?

I'd appreciate any other suggestions, thank you!

PS. Alternatively exporting as SVG and applying font styles is also working, but if the tree is large some automation with TreeViewer would be helpful.

Best, Leon

arklumpus commented 9 months ago

Hi, I'm glad that you're finding TreeViewer useful!

It should be quite easy to do what you're asking: you just need to set the attribute value to something like

<i>Synechocystis sp.</i> PCC 6803

In this way, only the part between the <i></i> tags will be in italics. You can also do other things, like <b></b> for bold or <#RRGGBB></#> for colour... The full list is here: https://giorgiobianchini.com/VectSharp/text.html#drawing-formatted-text (ignore the implementation details and just scroll down to the bullet points).

I hope this is useful, let me know if you have any other issues!

lxsteiner commented 8 months ago

Sorry, I was familiarizing myself with TreeViewer in the meantime and it took me too long to figure out what you had meant, that I can pass attribute formatting options by formatting them literally in the attachment data that gets imported with Further transformations->Parse node states (or individually with Change attribute). Neat! Thank you.