diff --git a/src/Plots.jl b/src/Plots.jl index 69bed9f2..ece760c4 100644 --- a/src/Plots.jl +++ b/src/Plots.jl @@ -29,13 +29,13 @@ import RecipesBase: plot, plot!, animate, is_explicit using Base.Meta @reexport using PlotUtils @reexport using PlotThemes -import Showoff +import UnicodeFun import StatsBase import Downloads +import Showoff import JSON using Requires -import UnicodeFun: to_latex #! format: off export diff --git a/src/backends/inspectdr.jl b/src/backends/inspectdr.jl index 1fe7d7b1..08777975 100644 --- a/src/backends/inspectdr.jl +++ b/src/backends/inspectdr.jl @@ -70,7 +70,7 @@ function _inspectdr_add_annotations(plot, x, y, val::PlotText) color = _inspectdr_mapcolor(val.font.color), ) ann = InspectDR.atext( - tex2unicode(val.str), + texmath2unicode(val.str), x = x, y = y, font = fnt, @@ -384,9 +384,9 @@ function _inspectdr_setupsubplot(sp::Subplot{InspectDRBackend}) _inspectdr_setticks(sp, plot, strip, xaxis, yaxis) a = plot.annotation - a.title = tex2unicode(sp[:title]) - a.xlabel = tex2unicode(xaxis[:guide]) - a.ylabels = [tex2unicode(yaxis[:guide])] + a.title = texmath2unicode(sp[:title]) + a.xlabel = texmath2unicode(xaxis[:guide]) + a.ylabels = [texmath2unicode(yaxis[:guide])] #Modify base layout of new object: l = plot.layout.defaults = deepcopy(InspectDR.defaults.plotlayout) diff --git a/src/backends/unicodeplots.jl b/src/backends/unicodeplots.jl index 0e97f8b2..1eabfc8c 100644 --- a/src/backends/unicodeplots.jl +++ b/src/backends/unicodeplots.jl @@ -42,9 +42,9 @@ function unicodeplots_rebuild(plt::Plot{UnicodePlotsBackend}) kw = ( compact = true, - title = tex2unicode(sp[:title]), - xlabel = tex2unicode(xaxis[:guide]), - ylabel = tex2unicode(yaxis[:guide]), + title = texmath2unicode(sp[:title]), + xlabel = texmath2unicode(xaxis[:guide]), + ylabel = texmath2unicode(yaxis[:guide]), xscale = xaxis[:scale], yscale = yaxis[:scale], border = isijulia() ? :ascii : :solid, @@ -63,7 +63,7 @@ function unicodeplots_rebuild(plt::Plot{UnicodePlotsBackend}) o, x, y, - tex2unicode(val.str); + texmath2unicode(val.str); color = up_color(val.font.color), halign = val.font.halign, valign = val.font.valign, diff --git a/src/utils.jl b/src/utils.jl index 248cb2d2..c181f89e 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -1241,4 +1241,4 @@ const _attrsymbolcache = Dict{Symbol,Dict{Symbol,Symbol}}() get_attr_symbol(letter::Symbol, keyword::String) = get_attr_symbol(letter, Symbol(keyword)) get_attr_symbol(letter::Symbol, keyword::Symbol) = _attrsymbolcache[letter][keyword] -tex2unicode(s::AbstractString, pat=r"\$([^$]+)\$") = replace(s, pat => m->to_latex(m[2:(length(m)-1)])) +texmath2unicode(s::AbstractString, pat=r"\$([^$]+)\$") = replace(s, pat => m->UnicodeFun.to_latex(m[2:(length(m)-1)])) diff --git a/test/runtests.jl b/test/runtests.jl index af71a2a7..9f3c4113 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -201,7 +201,7 @@ end Plots.process_clims(:auto) @test (==)( - Plots.tex2unicode(raw"Equation $y = \\alpha \\cdot x + \β$ and eqn $y = \\sin(x)^2$"), + Plots.texmath2unicode(raw"Equation $y = \alpha \cdot x + \beta$ and eqn $y = \sin(x)^2$"), raw"Equation y = α ⋅ x + β and eqn y = sin(x)²" ) end