minimal working version

This commit is contained in:
Zhanibek 2021-03-11 16:55:57 +09:00
parent 297ab3ef7e
commit 820858576a
2 changed files with 9 additions and 2 deletions

View File

@ -978,14 +978,21 @@ function _before_layout_calcs(plt::Plot{PyPlotBackend})
cb."formatter".set_powerlimits((-Inf, Inf)) cb."formatter".set_powerlimits((-Inf, Inf))
cb."update_ticks"() cb."update_ticks"()
env = "\\mathregular" # matches the outer fonts https://matplotlib.org/tutorials/text/mathtext.html
ticks = get_colorbar_ticks(sp)
if sp[:colorbar] in (:top, :bottom) if sp[:colorbar] in (:top, :bottom)
axis = sp[:xaxis] # colorbar inherits from x axis axis = sp[:xaxis] # colorbar inherits from x axis
cbar_axis = cb."ax"."xaxis" cbar_axis = cb."ax"."xaxis"
ticks_letter=:x
else else
axis = sp[:yaxis] # colorbar inherits from y axis axis = sp[:yaxis] # colorbar inherits from y axis
cbar_axis = cb."ax"."yaxis" cbar_axis = cb."ax"."yaxis"
ticks_letter=:y
end end
sp[:colorbar_ticks] == :native ? nothing : py_set_ticks(cb.ax, ticks, ticks_letter, env)
for lab in cbar_axis."get_ticklabels"() for lab in cbar_axis."get_ticklabels"()
lab."set_fontsize"(py_thickness_scale(plt, axis[:tickfontsize])) lab."set_fontsize"(py_thickness_scale(plt, axis[:tickfontsize]))
lab."set_family"(axis[:tickfontfamily]) lab."set_family"(axis[:tickfontfamily])

View File

@ -130,7 +130,7 @@ function optimal_colorbar_ticks_and_labels(sp::Subplot, ticks = nothing)
unscaled_ticks = map(RecipesPipeline.inverse_scale_func(scale), scaled_ticks) unscaled_ticks = map(RecipesPipeline.inverse_scale_func(scale), scaled_ticks)
labels = if any(isfinite, unscaled_ticks) labels = if any(isfinite, unscaled_ticks)
formatter = ap[:colorbar_formatter] formatter = sp[:colorbar_formatter]
if formatter in (:auto, :plain, :scientific, :engineering) if formatter in (:auto, :plain, :scientific, :engineering)
map(labelfunc(scale, backend()), Showoff.showoff(scaled_ticks, formatter)) map(labelfunc(scale, backend()), Showoff.showoff(scaled_ticks, formatter))
elseif formatter == :latex elseif formatter == :latex
@ -205,5 +205,5 @@ _transform_ticks(ticks::AbstractArray{T}) where T <: Dates.TimeType = Dates.valu
_transform_ticks(ticks::NTuple{2, Any}) = (_transform_ticks(ticks[1]), ticks[2]) _transform_ticks(ticks::NTuple{2, Any}) = (_transform_ticks(ticks[1]), ticks[2])
function _update_subplot_colorbars(sp::Subplot) function _update_subplot_colorbars(sp::Subplot)
# Dynamic callback from the pipeline if needed
end end