text.usetex option hack pyplot (#2893)
* text.usetex option hack * pyplot ticklabel fixes
This commit is contained in:
parent
ba09334845
commit
fc54177029
@ -727,7 +727,15 @@ function py_set_lims(ax, sp::Subplot, axis::Axis)
|
||||
getproperty(ax, Symbol("set_", letter, "lim"))(lfrom, lto)
|
||||
end
|
||||
|
||||
py_surround_latextext(latexstring, env) = PyPlot.LaTeXStrings.latexstring(env, "{",latexstring[2:end-1],"}")
|
||||
function py_surround_latextext(latexstring, env)
|
||||
if latexstring[1] == '$' && latexstring[end] == '$'
|
||||
unenclosed = latexstring[2:end-1]
|
||||
else
|
||||
unenclosed = latexstring
|
||||
end
|
||||
PyPlot.LaTeXStrings.latexstring(env, "{", unenclosed, "}")
|
||||
end
|
||||
|
||||
|
||||
function py_set_ticks(ax, ticks, letter, env)
|
||||
ticks == :auto && return
|
||||
@ -746,7 +754,13 @@ function py_set_ticks(ax, ticks, letter, env)
|
||||
axis."set_ticks"(ticks)
|
||||
elseif ttype == :ticks_and_labels
|
||||
axis."set_ticks"(ticks[1])
|
||||
tick_labels = [py_surround_latextext(ticklabel, env) for ticklabel in ticks[2]]
|
||||
|
||||
if pyrcparams["text.usetex"]
|
||||
tick_labels = ticks[2]
|
||||
else
|
||||
tick_labels = [py_surround_latextext(ticklabel, env) for ticklabel in ticks[2]]
|
||||
end
|
||||
|
||||
axis."set_ticklabels"(tick_labels)
|
||||
else
|
||||
error("Invalid input for $(letter)ticks: $ticks")
|
||||
@ -1009,7 +1023,7 @@ function _before_layout_calcs(plt::Plot{PyPlotBackend})
|
||||
# Set ticks
|
||||
fontProperties = PyPlot.PyCall.PyDict(Dict("family" => axis[:tickfontfamily],
|
||||
"size" => py_thickness_scale(plt, axis[:tickfontsize]),
|
||||
"useTex" => false,
|
||||
# "useTex" => false,
|
||||
"rotation" => axis[:tickfontrotation]))
|
||||
getproperty(ax, Symbol("set_",letter,"ticklabels"))(getproperty(ax, Symbol("get_",letter,"ticks"))(), fontProperties)
|
||||
|
||||
@ -1019,8 +1033,11 @@ function _before_layout_calcs(plt::Plot{PyPlotBackend})
|
||||
|
||||
# Tick marks
|
||||
intensity = 0.5 # This value corresponds to scaling of other grid elements
|
||||
pyaxis."set_tick_params"(direction = axis[:tick_direction] == :out ? "out" : "in", width=py_thickness_scale(plt, intensity),
|
||||
length= 5 * py_thickness_scale(plt, intensity))
|
||||
pyaxis."set_tick_params"(
|
||||
direction = axis[:tick_direction] == :out ? "out" : "in",
|
||||
width=py_thickness_scale(plt, intensity),
|
||||
length= 5 * py_thickness_scale(plt, intensity)
|
||||
)
|
||||
|
||||
getproperty(ax, Symbol("set_", letter, "label"))(axis[:guide])
|
||||
if get(axis.plotattributes, :flip, false)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user