# Typing special characters in Plot legends and titles

**URL:** <https://discourse.julialang.org/t/typing-special-characters-in-plot-legends-and-titles/24771>\
**Category:** General Usage\
**Tags:** plotting\
**Created:** [May 30, 2019, 2:28pm UTC](https://discourse.julialang.org/t/typing-special-characters-in-plot-legends-and-titles/24771 "2019-05-30T14:28:13Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [September 4, 2019, 8:45pm UTC](https://discourse.julialang.org/t/typing-special-characters-in-plot-legends-and-titles/24771/11 "2019-09-04T20:45:13Z")

</div>

> [@dalejordan](#):
>
> Can anyone shed light on what the root problem is with just displaying Unicode in strings? Do backends not support Unicode or is Plots dropping the ball? Or what?

Plots is Latin1 by default with the GR backend at least, due in part to limitations of the backend:

> <https://github.com/TuringLang/MCMCChains.jl/issues/111>
>
> Sorry for yet another question. My parameter names contain Greek letters, e.g. \<…img src="https://latex.codecogs.com/svg.latex?\\Large&space;\\alpha" /\> or \<img src="https://latex.codecogs.com/svg.latex?\\Large&space;\\rho\_A" /\>. In standard Julia plots, I can pass a \[LaTeXString\](https://github.com/stevengj/LaTeXStrings.jl) for labelling. Is this also possible here or would I have to write my own plotting code for the chains? Or do you recommend a different approach?

Even if a backend supports Unicode strings, its text rendering may not be capable of displaying many characters (due to limited font coverage, lack of support for combining characters, lack of support for fallback fonts for missing glyphs…). See here for a summary:

> <https://github.com/JuliaPlots/Plots.jl/issues/791>
>
> \`\`\`julia
> using Plots; gr()
> plot(x-\>x, xlabel="λ")
> \`\`\`
> \>BoundsError: attempt …to access 1-element Array{UInt8,1} at index \[2\]
> 
> \> in setindex!(::Array{UInt8,1}, ::Int64, ::Int64) at ./array.jl:415
> in latin1(::String) at /home/juliohm/.julia/v0.5/GR/src/GR.jl:456
> in text at /home/juliohm/.julia/v0.5/GR/src/GR.jl:488 \[inlined\]
> in gr\_text(::Float64, ::Float64, ::String) at /home/juliohm/.julia/v0.5/Plots/src/backends/gr.jl:191
> in gr\_display(::Plots.Subplot{Plots.GRBackend}, ::Measures.Length{:mm,Float64}, ::Measures.Length{:mm,Float64}, ::Array{Float64,1}) at /home/juliohm/.julia/v0.5/Plots/src/backends/gr.jl:711
> in gr\_display(::Plots.Plot{Plots.GRBackend}) at /home/juliohm/.julia/v0.5/Plots/src/backends/gr.jl:494
> in \_show(::Base.AbstractIOBuffer{Array{UInt8,1}}, ::MIME{Symbol("image/svg+xml")}, ::Plots.Plot{Plots.GRBackend}) at /home/juliohm/.julia/v0.5/Plots/src/backends/gr.jl:1089
> in show(::Base.AbstractIOBuffer{Array{UInt8,1}}, ::MIME{Symbol("image/svg+xml")}, ::Plots.Plot{Plots.GRBackend}) at /home/juliohm/.julia/v0.5/Plots/src/output.jl:197
> in show(::Base.AbstractIOBuffer{Array{UInt8,1}}, ::MIME{Symbol("text/html")}, ::Plots.Plot{Plots.GRBackend}) at /home/juliohm/.julia/v0.5/Plots/src/output.jl:177
> in show(::Base.AbstractIOBuffer{Array{UInt8,1}}, ::String, ::Plots.Plot{Plots.GRBackend}) at ./multimedia.jl:33
> in #sprint#304(::Void, ::Function, ::Int64, ::Function, ::String, ::Vararg{Any,N}) at ./strings/io.jl:37
> in display\_dict(::Plots.Plot{Plots.GRBackend}) at /home/juliohm/.julia/v0.5/Plots/src/output.jl:266
> in execute\_request(::ZMQ.Socket, ::IJulia.Msg) at /home/juliohm/.julia/v0.5/IJulia/src/execute\_request.jl:187
> in eventloop(::ZMQ.Socket) at /home/juliohm/.julia/v0.5/IJulia/src/eventloop.jl:8
> in (::IJulia.##13#19)() at ./task.jl:360

The solution is for backends to switch to a modern full-featured text renderer. As explained in the issue above, HarfBuzz seems to be a promising cross-platform option.

---

_[View the full topic](https://discourse.julialang.org/t/typing-special-characters-in-plot-legends-and-titles/24771)._
