Merge pull request #1443 from fedxa/fedxa-autosciaxis
Partial attempt to fix labeling to atomatically scientific notation
This commit is contained in:
commit
91cd6c1954
@ -212,12 +212,20 @@ 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, :auto))
|
||||||
|
elseif formatter == :plain
|
||||||
|
# Leave the numbers in plain format
|
||||||
map(labelfunc(scale, backend()), Showoff.showoff(scaled_ticks, :plain))
|
map(labelfunc(scale, backend()), Showoff.showoff(scaled_ticks, :plain))
|
||||||
elseif formatter == :scientific
|
elseif formatter == :scientific
|
||||||
Showoff.showoff(unscaled_ticks, :scientific)
|
Showoff.showoff(unscaled_ticks, :scientific)
|
||||||
else
|
else
|
||||||
# there was an override for the formatter... use that on the unscaled ticks
|
# there was an override for the formatter... use that on the unscaled ticks
|
||||||
map(formatter, unscaled_ticks)
|
map(formatter, unscaled_ticks)
|
||||||
|
# if the formatter left us with numbers, still apply the default formatter
|
||||||
|
# However it leave us with the problem of unicode number decoding by the backend
|
||||||
|
# if eltype(unscaled_ticks) <: Number
|
||||||
|
# Showoff.showoff(unscaled_ticks, :auto)
|
||||||
|
# end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
# no finite ticks to show...
|
# no finite ticks to show...
|
||||||
|
|||||||
@ -225,8 +225,8 @@ 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] in (:scientific, :auto) && yaxis[:ticks] in (:auto, :native)
|
||||||
rtick_labels = convert_sci_unicode(rtick_labels)
|
rtick_labels = convert_sci_unicode.(rtick_labels)
|
||||||
end
|
end
|
||||||
|
|
||||||
#draw angular grid
|
#draw angular grid
|
||||||
@ -888,7 +888,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] in (:scientific, :auto)
|
||||||
dv = convert_sci_unicode(dv)
|
dv = convert_sci_unicode(dv)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -907,7 +907,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] in (:scientific, :auto)
|
||||||
dv = convert_sci_unicode(dv)
|
dv = convert_sci_unicode(dv)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -425,7 +425,8 @@ function pgf_axis(sp::Subplot, letter)
|
|||||||
push!(style, string(letter, "ticklabels = {\$", join(tick_labels,"\$,\$"), "\$}"))
|
push!(style, string(letter, "ticklabels = {\$", join(tick_labels,"\$,\$"), "\$}"))
|
||||||
elseif axis[:showaxis]
|
elseif axis[:showaxis]
|
||||||
tick_labels = ispolar(sp) && letter == :x ? [ticks[2][3:end]..., "0", "45"] : ticks[2]
|
tick_labels = ispolar(sp) && letter == :x ? [ticks[2][3:end]..., "0", "45"] : ticks[2]
|
||||||
tick_labels = axis[:formatter] == :scientific ? string.("\$", convert_sci_unicode.(tick_labels), "\$") : tick_labels
|
tick_labels = ( axis[:formatter] in (:scientific, :auto) ?
|
||||||
|
string.("\$", convert_sci_unicode.(tick_labels), "\$") : tick_labels )
|
||||||
push!(style, string(letter, "ticklabels = {", join(tick_labels,","), "}"))
|
push!(style, string(letter, "ticklabels = {", join(tick_labels,","), "}"))
|
||||||
else
|
else
|
||||||
push!(style, string(letter, "ticklabels = {}"))
|
push!(style, string(letter, "ticklabels = {}"))
|
||||||
|
|||||||
@ -12,6 +12,7 @@ function standalone_html(plt::AbstractPlot; title::AbstractString = get(plt.attr
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>$title</title>
|
<title>$title</title>
|
||||||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||||
$(html_head(plt))
|
$(html_head(plt))
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user