fix LaTeXStrings support for UnicodePlots and InspectDR
This commit is contained in:
parent
c487a10f79
commit
070741052f
@ -31,6 +31,7 @@ Showoff = "992d4aef-0814-514b-bc4d-f2e9a6c4116f"
|
||||
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
|
||||
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
|
||||
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
|
||||
UnicodeFun = "1cfade01-22cf-5700-b092-accc4b62d6e1"
|
||||
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
|
||||
|
||||
[compat]
|
||||
@ -52,6 +53,7 @@ Requires = "1"
|
||||
Scratch = "1"
|
||||
Showoff = "0.3.1, 1.0"
|
||||
StatsBase = "0.32 - 0.33"
|
||||
UnicodeFun = "0.4"
|
||||
UnicodePlots = "2.4"
|
||||
julia = "1.5"
|
||||
|
||||
|
||||
@ -35,6 +35,7 @@ import Downloads
|
||||
import JSON
|
||||
|
||||
using Requires
|
||||
import UnicodeFun: to_latex
|
||||
|
||||
#! format: off
|
||||
export
|
||||
|
||||
@ -70,7 +70,7 @@ function _inspectdr_add_annotations(plot, x, y, val::PlotText)
|
||||
color = _inspectdr_mapcolor(val.font.color),
|
||||
)
|
||||
ann = InspectDR.atext(
|
||||
val.str,
|
||||
tex2unicode(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 = sp[:title]
|
||||
a.xlabel = xaxis[:guide]
|
||||
a.ylabels = [yaxis[:guide]]
|
||||
a.title = tex2unicode(sp[:title])
|
||||
a.xlabel = tex2unicode(xaxis[:guide])
|
||||
a.ylabels = [tex2unicode(yaxis[:guide])]
|
||||
|
||||
#Modify base layout of new object:
|
||||
l = plot.layout.defaults = deepcopy(InspectDR.defaults.plotlayout)
|
||||
|
||||
@ -42,9 +42,9 @@ function unicodeplots_rebuild(plt::Plot{UnicodePlotsBackend})
|
||||
|
||||
kw = (
|
||||
compact = true,
|
||||
title = sp[:title],
|
||||
xlabel = xaxis[:guide],
|
||||
ylabel = yaxis[:guide],
|
||||
title = tex2unicode(sp[:title]),
|
||||
xlabel = tex2unicode(xaxis[:guide]),
|
||||
ylabel = tex2unicode(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,
|
||||
val.str;
|
||||
tex2unicode(val.str);
|
||||
color = up_color(val.font.color),
|
||||
halign = val.font.halign,
|
||||
valign = val.font.valign,
|
||||
|
||||
@ -1209,6 +1209,7 @@ function mesh3d_triangles(x, y, z, cns::Tuple{Array,Array,Array})
|
||||
end
|
||||
return X, Y, Z
|
||||
end
|
||||
|
||||
function mesh3d_triangles(x, y, z, cns::AbstractVector{NTuple{3,Int}})
|
||||
X = zeros(eltype(x), 4length(cns))
|
||||
Y = zeros(eltype(y), 4length(cns))
|
||||
@ -1239,3 +1240,5 @@ 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)]))
|
||||
|
||||
@ -199,6 +199,11 @@ end
|
||||
@test Plots.process_clims(nothing) ==
|
||||
Plots.process_clims(missing) ==
|
||||
Plots.process_clims(:auto)
|
||||
|
||||
@test (==)(
|
||||
Plots.tex2unicode(raw"Equation $y = \\alpha \\cdot x + \β$ and eqn $y = \\sin(x)^2$"),
|
||||
raw"Equation y = α ⋅ x + β and eqn y = sin(x)²"
|
||||
)
|
||||
end
|
||||
|
||||
@testset "Backends" begin
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user