logo

Inserting Korean Text into Julia Plots 📂Julia

Inserting Korean Text into Julia Plots

Environment

  • OS: Windows
  • julia: v1.6.2

Error

result0.png

julia> plot(data, color = :black,
        label = "값", title = "브라운모션")
GKS: glyph missing from current font: 48652
GKS: glyph missing from current font: 46972
GKS: glyph missing from current font: 50868
GKS: glyph missing from current font: 47784
GKS: glyph missing from current font: 49496

Cause

The issue is due to the inability to find Korean fonts.

Solution

Both methods are not ideal, and alternative suggestions are always welcome. It is a fact that support for Korean is limited given that using Julia often does not require much Korean.

default(fontfamily = "") 1

plot(data, color = :black,
 label = "값", title = "브라운모션", fontfamily = "")

default(fontfamily = "")
plot(data, color = :red,
 label = "값", title = "브라운모션")

Korean can be rendered by setting the plot() option fontfamily = "" or using default(fontfamily = ""). However, even if the specific font name is changed, it is confirmed that it does not recognize them properly, and when saving, it ends up not finding the font, resulting in the text being displayed as a blank space instead of being garbled as shown in the first image.

result1.png result2.png

Plots.plotly() 2

Plots.plotly()
plot(data, color = :black,
 label = "값", title = "브라운모션")
savefig("result.html")

Using the plotly backend does render the Korean characters. However, it cannot save directly to *.png. Instead, it requires outputting to *.html first and then saving separately.

result3.png

Code

using Plots
#Plots.gr()

data = cumsum(randn(100))
plot(data, color = :black,
 label = "값", title = "브라운모션")

plot(data, color = :black,
 label = "값", title = "브라운모션", fontfamily = "")

default(fontfamily = "")
plot(data, color = :red,
 label = "값", title = "브라운모션")

savefig("result.png")

Plots.plotly()
plot(data, color = :black,
 label = "값", title = "브라운모션")
savefig("result.html")