# Why in plots，plot can't correctly display chinese

**URL:** <https://discourse.julialang.org/t/why-in-plots-plot-cant-correctly-display-chinese/19511>\
**Category:** New to Julia\
**Created:** [January 11, 2019, 12:49pm UTC](https://discourse.julialang.org/t/why-in-plots-plot-cant-correctly-display-chinese/19511 "2019-01-11T12:49:45Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![hzgzh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hzgzh/32/6596_2.png) [@hzgzh](https://discourse.julialang.org/u/hzgzh)\
**Post date:** [January 11, 2019, 12:49pm UTC](https://discourse.julialang.org/t/why-in-plots-plot-cant-correctly-display-chinese/19511/1 "2019-01-11T12:49:45Z")

</div>

using Plots  
plot(rand(10),title=“图形”)

---

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [January 11, 2019, 1:27pm UTC](https://discourse.julialang.org/t/why-in-plots-plot-cant-correctly-display-chinese/19511/2 "2019-01-11T13:27:52Z")

</div>

How is this question different from your last posted topic?

> [@why plot can't using chinese string](https://discourse.julialang.org/t/why-plot-cant-using-chinese-string/19473):
>
> using Plots plot(rand(10),title=“设备”)

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [January 11, 2019, 4:23pm UTC](https://discourse.julialang.org/t/why-in-plots-plot-cant-correctly-display-chinese/19511/3 "2019-01-11T16:23:39Z")

</div>

Please provide a full example with the output that you get. I suspect that you’re having issues not because of the Chinese text but because you’re using Unicode double quotes instead of `"`.

Edit: no, it looks like that’s an artifact of the code not being quoted. If it’s quoted it looks like this:

```julia
using Plots
plot(rand(10),title="图形")

```

---

<div class="post-metadata">

**Author:** ![Per](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/per/32/10387_2.png) [@Per](https://discourse.julialang.org/u/Per)\
**Post date:** [January 11, 2019, 4:35pm UTC](https://discourse.julialang.org/t/why-in-plots-plot-cant-correctly-display-chinese/19511/4 "2019-01-11T16:35:11Z")

</div>

see: [Error with unicode labels in GR backend · Issue #791 · JuliaPlots/Plots.jl · GitHub](https://github.com/JuliaPlots/Plots.jl/issues/791)

---

<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:** [January 11, 2019, 4:51pm UTC](https://discourse.julialang.org/t/why-in-plots-plot-cant-correctly-display-chinese/19511/5 "2019-01-11T16:51:54Z")

</div>

You don’t say what the error is? Also you should specify what backend you are using — what is `Plots.backend()`?

If you are using the Matplotlib backend, note that you often have to change the font settings with Matplotlib to ensure that Unicode characters render correctly, as the default font does not have good Unicode coverage.

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [January 11, 2019, 6:30pm UTC](https://discourse.julialang.org/t/why-in-plots-plot-cant-correctly-display-chinese/19511/6 "2019-01-11T18:30:52Z")

</div>

Someone who knows more about CJK in LaTeX may be able to simplify this:

```julia
using PGFPlotsX

# run this just once, to setup PGFPlotsX
PGFPlotsX.latexengine!(PGFPlotsX.PDFLATEX)
push!(PGFPlotsX.CUSTOM_PREAMBLE, raw"\usepackage{CJKutf8}",
      raw"\newcommand{\zh}[1]{\begin{CJK}{UTF8}{gbsn}#1\end{CJK}}")

# the actual plot
p = @pgf Axis({title = raw"\zh{图形}" }, Plot(Coordinates(enumerate(rand(10)))))

# we also save it
pgfsave("/tmp/test.pdf", p)

```

 ![test](https://global.discourse-cdn.com/julialang/original/3X/5/4/54e60bc6ac6d0d1022fd9c6e68888fd6bb27661d.png)

---

<div class="post-metadata">

**Author:** ![hzgzh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hzgzh/32/6596_2.png) [@hzgzh](https://discourse.julialang.org/u/hzgzh)\
**Post date:** [January 12, 2019, 5:30am UTC](https://discourse.julialang.org/t/why-in-plots-plot-cant-correctly-display-chinese/19511/7 "2019-01-12T05:30:52Z")

</div>

gr as backend,I will try [Error with unicode labels in GR backend · Issue #791 · JuliaPlots/Plots.jl · GitHub](https://github.com/JuliaPlots/Plots.jl/issues/791)

---

<div class="post-metadata">

**Author:** ![hzgzh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hzgzh/32/6596_2.png) [@hzgzh](https://discourse.julialang.org/u/hzgzh)\
**Post date:** [January 12, 2019, 5:30am UTC](https://discourse.julialang.org/t/why-in-plots-plot-cant-correctly-display-chinese/19511/8 "2019-01-12T05:30:57Z")

</div>

![img](https://global.discourse-cdn.com/julialang/original/3X/9/3/9314b1d5280cf3c950a1144b0eb5541f1366197a.png)  
result like this,the gr backend can’t display CJK correctly

---

<div class="post-metadata">

**Author:** ![hzgzh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hzgzh/32/6596_2.png) [@hzgzh](https://discourse.julialang.org/u/hzgzh)\
**Post date:** [January 12, 2019, 5:35am UTC](https://discourse.julialang.org/t/why-in-plots-plot-cant-correctly-display-chinese/19511/9 "2019-01-12T05:35:00Z")

</div>

using PlotlyJS can display chinese correctly  
using Plots;plotlyjs()  
plot(rand(10),title=“图形”) ![newplot](https://global.discourse-cdn.com/julialang/original/3X/f/7/f7ab96d9a6ba9e45ae507f486ec6f62e6197a4a4.png)

---

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [January 12, 2019, 5:35am UTC](https://discourse.julialang.org/t/why-in-plots-plot-cant-correctly-display-chinese/19511/10 "2019-01-12T05:35:23Z")

</div>

Try the PlotlyJS backend – that seems to work.  
(You’ll need to update your packages to get the latest update to Plots to be able to use that backend.)
