Partial attempt to fix label scaling to atomatically scientific notation.

Note, that the logic of replacing scientific notation in GR backend is a bit dodgy.
This commit is contained in:
Fedor Bezrukov 2018-03-18 17:25:45 +00:00
parent 047a13a8dc
commit c273bf6a7b
2 changed files with 4 additions and 4 deletions

View File

@ -212,7 +212,7 @@ function optimal_ticks_and_labels(axis::Axis, ticks = nothing)
formatter = axis[:formatter] formatter = axis[:formatter]
if formatter == :auto if formatter == :auto
# the default behavior is to make strings of the scaled values and then apply the labelfunc # the default behavior is to make strings of the scaled values and then apply the labelfunc
map(labelfunc(scale, backend()), Showoff.showoff(scaled_ticks, :plain)) map(labelfunc(scale, backend()), Showoff.showoff(scaled_ticks, :auto))
elseif formatter == :scientific elseif formatter == :scientific
Showoff.showoff(unscaled_ticks, :scientific) Showoff.showoff(unscaled_ticks, :scientific)
else else

View File

@ -223,7 +223,7 @@ function gr_polaraxes(rmin::Real, rmax::Real, sp::Subplot)
sinf = sind.(a) sinf = sind.(a)
cosf = cosd.(a) cosf = cosd.(a)
rtick_values, rtick_labels = get_ticks(yaxis) rtick_values, rtick_labels = get_ticks(yaxis)
if yaxis[:formatter] == :scientific && yaxis[:ticks] in (:auto, :native) if (yaxis[:formatter] == :scientific || contains(rtick_labels,"×10") )&& yaxis[:ticks] in (:auto, :native)
rtick_labels = convert_sci_unicode(rtick_labels) rtick_labels = convert_sci_unicode(rtick_labels)
end end
@ -889,7 +889,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
# ensure correct dispatch in gr_text for automatic log ticks # ensure correct dispatch in gr_text for automatic log ticks
if xaxis[:scale] in _logScales if xaxis[:scale] in _logScales
dv = string(dv, "\\ ") dv = string(dv, "\\ ")
elseif xaxis[:formatter] == :scientific elseif xaxis[:formatter] == :scientific || contains(dv,"×10")
dv = convert_sci_unicode(dv) dv = convert_sci_unicode(dv)
end end
end end
@ -908,7 +908,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
# ensure correct dispatch in gr_text for automatic log ticks # ensure correct dispatch in gr_text for automatic log ticks
if yaxis[:scale] in _logScales if yaxis[:scale] in _logScales
dv = string(dv, "\\ ") dv = string(dv, "\\ ")
elseif yaxis[:formatter] == :scientific elseif yaxis[:formatter] == :scientific || contains(dv,"×10")
dv = convert_sci_unicode(dv) dv = convert_sci_unicode(dv)
end end
end end