GiovineItalia / Gadfly.jl

Crafty statistical graphics for Julia.
http://gadflyjl.org/stable/
Other
1.9k stars 250 forks source link

Feature request: refined styling of labels #1073

Open IgorDouven opened 6 years ago

IgorDouven commented 6 years ago

Suppose I have a title like: "Histogram of significant p-values", and I would like the p (and only the p) to be italicised. Maybe I'm overlooking something, but I cannot find any way to do that, or more generally to style just parts of a label (which can for instance easily be done in ggplot2). It would be nice to have this feature.

bjarthur commented 6 years ago

see http://giovineitalia.github.io/Compose.jl/latest/#Text-1

plot(x=rand(1000), Geom.histogram, Guide.title("Histogram of <i>p</i>-values"))

will leave this open, as there is a bug for Guide.title("<i>p</i>-values")

IgorDouven commented 6 years ago

Thanks! This gave the error:

ERROR: Could not parse pango markup.

I suppose that's due to the bug? (Or a problem with Cairo?)

Mattriks commented 6 years ago

As well as pango markup, Julia can generate symbols (including italic symbols, symbols with hats, super and subscript etc): https://docs.julialang.org/en/latest/manual/unicode-input/ There is an example here, where I mix the 2 forms: https://discourse.julialang.org/t/plotting-histogram-on-the-y-axis-at-the-end-of-a-time-series/5381/4

IgorDouven commented 6 years ago

Thanks, very nice indeed. I noticed that Guide.title(" p = .2 ") works, but Guide.title("p = .2") throws an error. Perhaps it is obvious why to anyone with experience in HTML -- which I don't have.

Mattriks commented 4 years ago

@IgorDouven Does Guide.title("𝑝= .2") work for you on Gadfly 1.3? (It may have been fixed by GiovineItalia/Compose.jl#394?)

IgorDouven commented 4 years ago

For the past years, I have been consistently using HTML syntax in Gadfly labels (so in this case, <i>p</> etc.). That works very well for me. I'm not sure I can italicize text in the editor I'm using (VSCode). But next time I run a notebook in Jupyter lab, I'll check whether your solution works.