# Does Julia support Chinese characters when plotting graph?

**URL:** https://discourse.julialang.org/t/does-julia-support-chinese-characters-when-plotting-graph/81806
**Category:** General Usage
**Created:** [May 27, 2022, 6:13pm UTC](https://discourse.julialang.org/t/does-julia-support-chinese-characters-when-plotting-graph/81806 "2022-05-27T18:13:03Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Raymond](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raymond/32/36557_2.png) [@Raymond](https://discourse.julialang.org/u/Raymond)
#### Post date: [May 27, 2022, 6:13pm UTC](https://discourse.julialang.org/t/does-julia-support-chinese-characters-when-plotting-graph/81806/1 "2022-05-27T18:13:03Z")

</div>

Dear all ,

How to dispaly Chinese characters in the graph?

```julia
julia> y = rand(10);

julia> t = 1:10;

julia> plot(t, y, xlabel = "时间")
GKS: glyph missing from current font: 26102
GKS: glyph missing from current font: 38388
GKS: glyph missing from current font: 26102
GKS: glyph missing from current font: 38388
GKS: glyph missing from current font: 26102
GKS: glyph missing from current font: 38388
GKS: glyph missing from current font: 26102
GKS: glyph missing from current font: 38388
GKS: glyph missing from current font: 26102
GKS: glyph missing from current font: 38388

```

![xxx](https://global.discourse-cdn.com/julialang/original/3X/4/f/4f4888411806f7935153809542bd019b0755f073.png)

---

<div class="post-metadata">

### Author: ![Raymond](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raymond/32/36557_2.png) [@Raymond](https://discourse.julialang.org/u/Raymond)
#### Post date: [May 27, 2022, 6:32pm UTC](https://discourse.julialang.org/t/does-julia-support-chinese-characters-when-plotting-graph/81806/2 "2022-05-27T18:32:29Z")

</div>

I have solved this problem.

```julia
using PlotlyJS
plotlyjs()
plot(rand(10), xlabel = "时间")

```

---

<div class="post-metadata">

### Author: ![polyactis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/polyactis/32/51034_2.png) [@polyactis](https://discourse.julialang.org/u/polyactis)
#### Post date: [July 29, 2024, 7:42am UTC](https://discourse.julialang.org/t/does-julia-support-chinese-characters-when-plotting-graph/81806/3 "2024-07-29T07:42:04Z")

</div>

> <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

```julia
ENV["GKS_ENCODING"] = "utf-8"
using Plots
plot(rand(10),title="àçħℏÅÇ图形")

```

Or due to missing font, specify the font. And make sure you have Chinese font installed.

- [How to use Chinese font in matplotlib visuals - #6 by randyzwitch - ☁️ Community Cloud - Streamlit](https://discuss.streamlit.io/t/how-to-use-chinese-font-in-matplotlib-visuals/7895/6)

```julia
using Plots
x = 1:10
y = rand(10)

myfont = font(12, "Arial") # Define a custom font
#OR. fontsize is incorrect.
#Plots.default(fontfamily="Arial", fontsize=12)

plot(x, y,
     title="My Plot", titlefont=myfont,
     xlabel="X-axis", ylabel="Y-axis", guidefont=myfont,
     tickfont=myfont,
     legendfont=myfont)

```
