Unicode characters in Plot

Hello, I’m building a Turing model and I’m using unicode character for the third variable.
Plotting the sample I obtain this:

How could I correctly render the unicode symbol of the third variable?


can you provide a MWE?


@model function λ(y)
    lambda1 ~ Exponential(alpha)
    lambda2 ~ Exponential(alpha)
    τ ~ Uniform(1, n_count_data)
    for i in 1:length(y)
        y[i] ~ Poisson(τ > i ? lambda1 : lambda2)
    # return τ

e = sample(λ(count_data), Gibbs(MH(:τ), HMC(0.01, 5, :lambda1, :lambda2)), 10000)
savefig(plot(e), "sample.png")

The problem is that the τ variable is shown as “?” in the plot.

A wild guess: that font looks like Nimbus (freebie version of Helvetica) so it’s possible it might not have all the characters you want. You may be able to select another, depending on the back-end.

1 Like

How can I select the font used in the plot?
I have tried
plot(e, fontfamily = "my-font")
but nothing changes.

I think it might depend on which plotting backend you’re using. I’ve had success specifying fonts with PyPlot and Makie. The GR fonts are listed here.

I think I cannot use PyPlot (it seems that it don’t support Turing seriestype).

Using GR how is possible to set the choosen font? I could try to use Symbol.

I have also found this issue: Unicode Support in Julia 1.0 · Issue #143 · jheinen/GR.jl · GitHub

using Plots
plot(1:5, 11:15, title = "τ is twice as good as π")

and these seem to work as well:

plot(1:5, 11:15, title = "τ is twice as good as π", fontfamily="Times")
plot(1:5, 11:15, title = "τ is twice as good as π", fontfamily="DejaVu Sans")
plot(1:5, 11:15, title = "τ is twice as good as π", fontfamily="New Century Schoolbook Roman")

Thank you. Setting



using Plots

works fine.