# Unicode characters in Plot

**URL:** <https://discourse.julialang.org/t/unicode-characters-in-plot/53997>\
**Category:** General Usage\
**Tags:** turing\
**Created:** [January 26, 2021, 4:44pm UTC](https://discourse.julialang.org/t/unicode-characters-in-plot/53997 "2021-01-26T16:44:18Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![mcql](https://avatars.discourse-cdn.com/v4/letter/m/59ef9b/32.png) [@mcql](https://discourse.julialang.org/u/mcql)\
**Post date:** [January 26, 2021, 4:44pm UTC](https://discourse.julialang.org/t/unicode-characters-in-plot/53997/1 "2021-01-26T16:44:18Z")

</div>

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

 ![fnuts](https://global.discourse-cdn.com/julialang/original/3X/4/a/4afb4ced49a673695da94c67ae84571ac9fedb09.png)

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

Thanks

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [January 26, 2021, 5:07pm UTC](https://discourse.julialang.org/t/unicode-characters-in-plot/53997/2 "2021-01-26T17:07:52Z")

</div>

can you provide a MWE?

---

<div class="post-metadata">

**Author:** ![mcql](https://avatars.discourse-cdn.com/v4/letter/m/59ef9b/32.png) [@mcql](https://discourse.julialang.org/u/mcql)\
**Post date:** [January 26, 2021, 5:28pm UTC](https://discourse.julialang.org/t/unicode-characters-in-plot/53997/3 "2021-01-26T17:28:58Z")

</div>

Sure.

```julia
@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)
    end
    # return τ
end

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.

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [January 26, 2021, 7:58pm UTC](https://discourse.julialang.org/t/unicode-characters-in-plot/53997/4 "2021-01-26T19:58:37Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![mcql](https://avatars.discourse-cdn.com/v4/letter/m/59ef9b/32.png) [@mcql](https://discourse.julialang.org/u/mcql)\
**Post date:** [January 27, 2021, 12:28pm UTC](https://discourse.julialang.org/t/unicode-characters-in-plot/53997/5 "2021-01-27T12:28:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [January 27, 2021, 12:31pm UTC](https://discourse.julialang.org/t/unicode-characters-in-plot/53997/6 "2021-01-27T12:31:26Z")

</div>

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](https://gr-framework.org/fonts.html).

---

<div class="post-metadata">

**Author:** ![mcql](https://avatars.discourse-cdn.com/v4/letter/m/59ef9b/32.png) [@mcql](https://discourse.julialang.org/u/mcql)\
**Post date:** [January 27, 2021, 1:59pm UTC](https://discourse.julialang.org/t/unicode-characters-in-plot/53997/7 "2021-01-27T13:59:58Z")

</div>

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](https://github.com/jheinen/GR.jl/issues/143)

---

<div class="post-metadata">

**Author:** ![cormullion](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cormullion/32/49131_2.png) [@cormullion](https://discourse.julialang.org/u/cormullion)\
**Post date:** [January 27, 2021, 2:05pm UTC](https://discourse.julialang.org/t/unicode-characters-in-plot/53997/8 "2021-01-27T14:05:22Z")

</div>

```julia
ENV["GKS_ENCODING"]="utf-8"
using Plots
gr()
plot(1:5, 11:15, title = "τ is twice as good as π")

```

and these seem to work as well:

```julia
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")

```

---

<div class="post-metadata">

**Author:** ![mcql](https://avatars.discourse-cdn.com/v4/letter/m/59ef9b/32.png) [@mcql](https://discourse.julialang.org/u/mcql)\
**Post date:** [January 27, 2021, 2:36pm UTC](https://discourse.julialang.org/t/unicode-characters-in-plot/53997/9 "2021-01-27T14:36:18Z")

</div>

Thank you. Setting

```julia
ENV["GKS_ENCODING"]="utf-8"

```

before

```julia
using Plots

```

works fine.
