commit
001cb80cfe
@ -110,10 +110,11 @@ const _arg_desc = KW(
|
|||||||
:foreground_color_text => "Color Type or `:match` (matches `:foreground_color_subplot`). Color of tick labels.",
|
:foreground_color_text => "Color Type or `:match` (matches `:foreground_color_subplot`). Color of tick labels.",
|
||||||
:foreground_color_guide => "Color Type or `:match` (matches `:foreground_color_subplot`). Color of axis guides (axis labels).",
|
:foreground_color_guide => "Color Type or `:match` (matches `:foreground_color_subplot`). Color of axis guides (axis labels).",
|
||||||
:mirror => "Bool. Switch the side of the tick labels (right or top).",
|
:mirror => "Bool. Switch the side of the tick labels (right or top).",
|
||||||
:grid => "Bool, Symbol, String or `nothing`. Show the grid lines? `:x`, `:y`, `:z`, `:xy`, ..., `:all`, `:none`, `:off`",
|
:grid => "Bool, Symbol, String or `nothing`. Show the grid lines? `true`, `false`, `:show`, `:hide`, `:yes`, `:no`, `:x`, `:y`, `:z`, `:xy`, ..., `:all`, `:none`, `:off`",
|
||||||
:foreground_color_grid => "Color Type or `:match` (matches `:foreground_color_subplot`). Color of grid lines.",
|
:foreground_color_grid => "Color Type or `:match` (matches `:foreground_color_subplot`). Color of grid lines.",
|
||||||
:gridalpha => "Number in [0,1]. The alpha/opacity override for the grid lines.",
|
:gridalpha => "Number in [0,1]. The alpha/opacity override for the grid lines.",
|
||||||
:gridstyle => "Symbol. Style of the grid lines. Choose from $(_allStyles)",
|
:gridstyle => "Symbol. Style of the grid lines. Choose from $(_allStyles)",
|
||||||
:gridlinewidth => "Number. Width of the grid lines (in pixels)",
|
:gridlinewidth => "Number. Width of the grid lines (in pixels)",
|
||||||
:tick_direction => "Symbol. Direction of the ticks. `:in` or `:out`"
|
:tick_direction => "Symbol. Direction of the ticks. `:in` or `:out`",
|
||||||
|
:showaxis => "Bool, Symbol or String. Show the axis. `true`, `false`, `:show`, `:hide`, `:yes`, `:no`, `:x`, `:y`, `:z`, `:xy`, ..., `:all`, `:off`"
|
||||||
)
|
)
|
||||||
|
|||||||
48
src/args.jl
48
src/args.jl
@ -170,8 +170,8 @@ const _scaleAliases = Dict{Symbol,Symbol}(
|
|||||||
const _allGridSyms = [:x, :y, :z,
|
const _allGridSyms = [:x, :y, :z,
|
||||||
:xy, :xz, :yx, :yz, :zx, :zy,
|
:xy, :xz, :yx, :yz, :zx, :zy,
|
||||||
:xyz, :xzy, :yxz, :yzx, :zxy, :zyx,
|
:xyz, :xzy, :yxz, :yzx, :zxy, :zyx,
|
||||||
:all, :both, :on,
|
:all, :both, :on, :yes, :show,
|
||||||
:none, :off,]
|
:none, :off, :no, :hide]
|
||||||
const _allGridArgs = [_allGridSyms; string.(_allGridSyms); nothing]
|
const _allGridArgs = [_allGridSyms; string.(_allGridSyms); nothing]
|
||||||
hasgrid(arg::Void, letter) = false
|
hasgrid(arg::Void, letter) = false
|
||||||
hasgrid(arg::Bool, letter) = arg
|
hasgrid(arg::Bool, letter) = arg
|
||||||
@ -185,6 +185,24 @@ function hasgrid(arg::Symbol, letter)
|
|||||||
end
|
end
|
||||||
hasgrid(arg::AbstractString, letter) = hasgrid(Symbol(arg), letter)
|
hasgrid(arg::AbstractString, letter) = hasgrid(Symbol(arg), letter)
|
||||||
|
|
||||||
|
const _allShowaxisSyms = [:x, :y, :z,
|
||||||
|
:xy, :xz, :yx, :yz, :zx, :zy,
|
||||||
|
:xyz, :xzy, :yxz, :yzx, :zxy, :zyx,
|
||||||
|
:all, :both, :on, :yes, :show,
|
||||||
|
:off, :no, :hide]
|
||||||
|
const _allShowaxisArgs = [_allGridSyms; string.(_allGridSyms)]
|
||||||
|
showaxis(arg::Void, letter) = false
|
||||||
|
showaxis(arg::Bool, letter) = arg
|
||||||
|
function showaxis(arg::Symbol, letter)
|
||||||
|
if arg in _allGridSyms
|
||||||
|
arg in (:all, :both, :on, :yes) || contains(string(arg), string(letter))
|
||||||
|
else
|
||||||
|
warn("Unknown showaxis argument $arg; $(Symbol(letter, :showaxis)) was set to `true` instead.")
|
||||||
|
true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
showaxis(arg::AbstractString, letter) = hasgrid(Symbol(arg), letter)
|
||||||
|
|
||||||
const _allFramestyles = [:box, :semi, :axes, :origin, :zerolines, :grid, :none]
|
const _allFramestyles = [:box, :semi, :axes, :origin, :zerolines, :grid, :none]
|
||||||
const _framestyleAliases = Dict{Symbol, Symbol}(
|
const _framestyleAliases = Dict{Symbol, Symbol}(
|
||||||
:frame => :box,
|
:frame => :box,
|
||||||
@ -322,7 +340,8 @@ const _axis_defaults = KW(
|
|||||||
:gridalpha => 0.1,
|
:gridalpha => 0.1,
|
||||||
:gridstyle => :solid,
|
:gridstyle => :solid,
|
||||||
:gridlinewidth => 0.5,
|
:gridlinewidth => 0.5,
|
||||||
:tick_direction => :in,
|
:tick_direction => :in,
|
||||||
|
:showaxis => true,
|
||||||
)
|
)
|
||||||
|
|
||||||
const _suppress_warnings = Set{Symbol}([
|
const _suppress_warnings = Set{Symbol}([
|
||||||
@ -710,7 +729,7 @@ function processGridArg!(d::KW, arg, letter)
|
|||||||
d[Symbol(letter, :gridlinewidth)] = arg
|
d[Symbol(letter, :gridlinewidth)] = arg
|
||||||
|
|
||||||
# color
|
# color
|
||||||
elseif !handleColors!(d, arg, Symbol(letter, :foreground_color_grid))
|
elseif !handleColors!(d, arg, Symbol(letter, :foreground_color_grid))
|
||||||
warn("Skipped grid arg $arg.")
|
warn("Skipped grid arg $arg.")
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -735,13 +754,13 @@ function preprocessArgs!(d::KW)
|
|||||||
replaceAliases!(d, _keyAliases)
|
replaceAliases!(d, _keyAliases)
|
||||||
|
|
||||||
# clear all axis stuff
|
# clear all axis stuff
|
||||||
if haskey(d, :axis) && d[:axis] in (:none, nothing, false)
|
# if haskey(d, :axis) && d[:axis] in (:none, nothing, false)
|
||||||
d[:ticks] = nothing
|
# d[:ticks] = nothing
|
||||||
d[:foreground_color_border] = RGBA(0,0,0,0)
|
# d[:foreground_color_border] = RGBA(0,0,0,0)
|
||||||
d[:foreground_color_axis] = RGBA(0,0,0,0)
|
# d[:foreground_color_axis] = RGBA(0,0,0,0)
|
||||||
d[:grid] = false
|
# d[:grid] = false
|
||||||
delete!(d, :axis)
|
# delete!(d, :axis)
|
||||||
end
|
# end
|
||||||
# for letter in (:x, :y, :z)
|
# for letter in (:x, :y, :z)
|
||||||
# asym = Symbol(letter, :axis)
|
# asym = Symbol(letter, :axis)
|
||||||
# if haskey(d, asym) || d[asym] in (:none, nothing, false)
|
# if haskey(d, asym) || d[asym] in (:none, nothing, false)
|
||||||
@ -750,6 +769,13 @@ function preprocessArgs!(d::KW)
|
|||||||
# end
|
# end
|
||||||
# end
|
# end
|
||||||
|
|
||||||
|
# handle axis args common to all axis
|
||||||
|
args = pop!(d, :axis, ())
|
||||||
|
for arg in wraptuple(args)
|
||||||
|
for letter in (:x, :y, :z)
|
||||||
|
process_axis_arg!(d, arg, letter)
|
||||||
|
end
|
||||||
|
end
|
||||||
# handle axis args
|
# handle axis args
|
||||||
for letter in (:x, :y, :z)
|
for letter in (:x, :y, :z)
|
||||||
asym = Symbol(letter, :axis)
|
asym = Symbol(letter, :axis)
|
||||||
|
|||||||
65
src/axes.jl
65
src/axes.jl
@ -70,13 +70,16 @@ function process_axis_arg!(d::KW, arg, letter = "")
|
|||||||
elseif arg == nothing
|
elseif arg == nothing
|
||||||
d[Symbol(letter,:ticks)] = []
|
d[Symbol(letter,:ticks)] = []
|
||||||
|
|
||||||
|
elseif T <: Bool || arg in _allShowaxisArgs
|
||||||
|
d[Symbol(letter,:showaxis)] = showaxis(arg, letter)
|
||||||
|
|
||||||
elseif typeof(arg) <: Number
|
elseif typeof(arg) <: Number
|
||||||
d[Symbol(letter,:rotation)] = arg
|
d[Symbol(letter,:rotation)] = arg
|
||||||
|
|
||||||
elseif typeof(arg) <: Function
|
elseif typeof(arg) <: Function
|
||||||
d[Symbol(letter,:formatter)] = arg
|
d[Symbol(letter,:formatter)] = arg
|
||||||
|
|
||||||
else
|
elseif !handleColors!(d, arg, Symbol(letter, :foreground_color_axis))
|
||||||
warn("Skipped $(letter)axis arg $arg")
|
warn("Skipped $(letter)axis arg $arg")
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -517,16 +520,18 @@ function axis_drawing_info(sp::Subplot)
|
|||||||
|
|
||||||
if !(sp[:framestyle] == :none)
|
if !(sp[:framestyle] == :none)
|
||||||
# xaxis
|
# xaxis
|
||||||
sp[:framestyle] in (:grid, :origin, :zerolines) || push!(xaxis_segs, (xmin,ymin), (xmax,ymin)) # bottom spine / xaxis
|
if xaxis[:showaxis]
|
||||||
if sp[:framestyle] in (:origin, :zerolines)
|
sp[:framestyle] in (:grid, :origin, :zerolines) || push!(xaxis_segs, (xmin,ymin), (xmax,ymin)) # bottom spine / xaxis
|
||||||
push!(xaxis_segs, (xmin, 0.0), (xmax, 0.0))
|
if sp[:framestyle] in (:origin, :zerolines)
|
||||||
# don't show the 0 tick label for the origin framestyle
|
push!(xaxis_segs, (xmin, 0.0), (xmax, 0.0))
|
||||||
if sp[:framestyle] == :origin && length(xticks) > 1
|
# don't show the 0 tick label for the origin framestyle
|
||||||
showticks = xticks[1] .!= 0
|
if sp[:framestyle] == :origin && length(xticks) > 1
|
||||||
xticks = (xticks[1][showticks], xticks[2][showticks])
|
showticks = xticks[1] .!= 0
|
||||||
|
xticks = (xticks[1][showticks], xticks[2][showticks])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
sp[:framestyle] in (:semi, :box) && push!(xborder_segs, (xmin,ymax), (xmax,ymax)) # top spine
|
||||||
end
|
end
|
||||||
sp[:framestyle] in (:semi, :box) && push!(xborder_segs, (xmin,ymax), (xmax,ymax)) # top spine
|
|
||||||
if !(xaxis[:ticks] in (nothing, false))
|
if !(xaxis[:ticks] in (nothing, false))
|
||||||
f = scalefunc(yaxis[:scale])
|
f = scalefunc(yaxis[:scale])
|
||||||
invf = invscalefunc(yaxis[:scale])
|
invf = invscalefunc(yaxis[:scale])
|
||||||
@ -536,28 +541,32 @@ function axis_drawing_info(sp::Subplot)
|
|||||||
t3 = invf(f(0) + 0.015 * (f(ymax) - f(ymin)) * ticks_in)
|
t3 = invf(f(0) + 0.015 * (f(ymax) - f(ymin)) * ticks_in)
|
||||||
|
|
||||||
for xtick in xticks[1]
|
for xtick in xticks[1]
|
||||||
tick_start, tick_stop = if sp[:framestyle] == :origin
|
if xaxis[:showaxis]
|
||||||
(0, t3)
|
tick_start, tick_stop = if sp[:framestyle] == :origin
|
||||||
else
|
(0, t3)
|
||||||
xaxis[:mirror] ? (ymax, t2) : (ymin, t1)
|
else
|
||||||
|
xaxis[:mirror] ? (ymax, t2) : (ymin, t1)
|
||||||
|
end
|
||||||
|
push!(xtick_segs, (xtick, tick_start), (xtick, tick_stop)) # bottom tick
|
||||||
end
|
end
|
||||||
push!(xtick_segs, (xtick, tick_start), (xtick, tick_stop)) # bottom tick
|
|
||||||
# sp[:draw_axes_border] && push!(xaxis_segs, (xtick, ymax), (xtick, t2)) # top tick
|
# sp[:draw_axes_border] && push!(xaxis_segs, (xtick, ymax), (xtick, t2)) # top tick
|
||||||
xaxis[:grid] && push!(xgrid_segs, (xtick, t1), (xtick, t2)) # vertical grid
|
xaxis[:grid] && push!(xgrid_segs, (xtick, t1), (xtick, t2)) # vertical grid
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# yaxis
|
# yaxis
|
||||||
sp[:framestyle] in (:grid, :origin, :zerolines) || push!(yaxis_segs, (xmin,ymin), (xmin,ymax)) # left spine / yaxis
|
if yaxis[:showaxis]
|
||||||
if sp[:framestyle] in (:origin, :zerolines)
|
sp[:framestyle] in (:grid, :origin, :zerolines) || push!(yaxis_segs, (xmin,ymin), (xmin,ymax)) # left spine / yaxis
|
||||||
push!(yaxis_segs, (0.0, ymin), (0.0, ymax))
|
if sp[:framestyle] in (:origin, :zerolines)
|
||||||
# don't show the 0 tick label for the origin framestyle
|
push!(yaxis_segs, (0.0, ymin), (0.0, ymax))
|
||||||
if sp[:framestyle] == :origin && length(yticks) > 1
|
# don't show the 0 tick label for the origin framestyle
|
||||||
showticks = yticks[1] .!= 0
|
if sp[:framestyle] == :origin && length(yticks) > 1
|
||||||
yticks = (yticks[1][showticks], yticks[2][showticks])
|
showticks = yticks[1] .!= 0
|
||||||
|
yticks = (yticks[1][showticks], yticks[2][showticks])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
sp[:framestyle] in (:semi, :box) && push!(yborder_segs, (xmax,ymin), (xmax,ymax)) # right spine
|
||||||
end
|
end
|
||||||
sp[:framestyle] in (:semi, :box) && push!(yborder_segs, (xmax,ymin), (xmax,ymax)) # right spine
|
|
||||||
if !(yaxis[:ticks] in (nothing, false))
|
if !(yaxis[:ticks] in (nothing, false))
|
||||||
f = scalefunc(xaxis[:scale])
|
f = scalefunc(xaxis[:scale])
|
||||||
invf = invscalefunc(xaxis[:scale])
|
invf = invscalefunc(xaxis[:scale])
|
||||||
@ -567,12 +576,14 @@ function axis_drawing_info(sp::Subplot)
|
|||||||
t3 = invf(f(0) + 0.015 * (f(xmax) - f(xmin)) * ticks_in)
|
t3 = invf(f(0) + 0.015 * (f(xmax) - f(xmin)) * ticks_in)
|
||||||
|
|
||||||
for ytick in yticks[1]
|
for ytick in yticks[1]
|
||||||
tick_start, tick_stop = if sp[:framestyle] == :origin
|
if yaxis[:showaxis]
|
||||||
(0, t3)
|
tick_start, tick_stop = if sp[:framestyle] == :origin
|
||||||
else
|
(0, t3)
|
||||||
yaxis[:mirror] ? (xmax, t2) : (xmin, t1)
|
else
|
||||||
|
yaxis[:mirror] ? (xmax, t2) : (xmin, t1)
|
||||||
|
end
|
||||||
|
push!(ytick_segs, (tick_start, ytick), (tick_stop, ytick)) # left tick
|
||||||
end
|
end
|
||||||
push!(ytick_segs, (tick_start, ytick), (tick_stop, ytick)) # left tick
|
|
||||||
# sp[:draw_axes_border] && push!(yaxis_segs, (xmax, ytick), (t2, ytick)) # right tick
|
# sp[:draw_axes_border] && push!(yaxis_segs, (xmax, ytick), (t2, ytick)) # right tick
|
||||||
yaxis[:grid] && push!(ygrid_segs, (t1, ytick), (t2, ytick)) # horizontal grid
|
yaxis[:grid] && push!(ygrid_segs, (t1, ytick), (t2, ytick)) # horizontal grid
|
||||||
end
|
end
|
||||||
|
|||||||
@ -732,15 +732,25 @@ function gl_draw_axes_2d(sp::Plots.Subplot{Plots.GLVisualizeBackend}, model, are
|
|||||||
xlim = Plots.axis_limits(xaxis)
|
xlim = Plots.axis_limits(xaxis)
|
||||||
ylim = Plots.axis_limits(yaxis)
|
ylim = Plots.axis_limits(yaxis)
|
||||||
|
|
||||||
if !(xaxis[:ticks] in (nothing, false, :none)) && !(sp[:framestyle] == :none)
|
if !(xaxis[:ticks] in (nothing, false, :none)) && !(sp[:framestyle] == :none) && xaxis[:showaxis]
|
||||||
ticklabels = map(model) do m
|
ticklabels = map(model) do m
|
||||||
mirror = xaxis[:mirror]
|
mirror = xaxis[:mirror]
|
||||||
t, positions, offsets = draw_ticks(xaxis, xticks, true, sp[:framestyle] == :origin, ylim, m)
|
t, positions, offsets = draw_ticks(xaxis, xticks, true, sp[:framestyle] == :origin, ylim, m)
|
||||||
mirror = xaxis[:mirror]
|
end
|
||||||
t, positions, offsets = draw_ticks(
|
kw_args = Dict{Symbol, Any}(
|
||||||
yaxis, yticks, false, sp[:framestyle] == :origin, xlim, m,
|
:position => map(x-> x[2], ticklabels),
|
||||||
t, positions, offsets
|
:offset => map(last, ticklabels),
|
||||||
)
|
:color => fcolor,
|
||||||
|
:relative_scale => pointsize(xaxis[:tickfont]),
|
||||||
|
:scale_primitive => false
|
||||||
|
)
|
||||||
|
push!(axis_vis, visualize(map(first, ticklabels), Style(:default), kw_args))
|
||||||
|
end
|
||||||
|
|
||||||
|
if !(yaxis[:ticks] in (nothing, false, :none)) && !(sp[:framestyle] == :none) && yaxis[:showaxis]
|
||||||
|
ticklabels = map(model) do m
|
||||||
|
mirror = yaxis[:mirror]
|
||||||
|
t, positions, offsets = draw_ticks(yaxis, yticks, false, sp[:framestyle] == :origin, xlim, m)
|
||||||
end
|
end
|
||||||
kw_args = Dict{Symbol, Any}(
|
kw_args = Dict{Symbol, Any}(
|
||||||
:position => map(x-> x[2], ticklabels),
|
:position => map(x-> x[2], ticklabels),
|
||||||
|
|||||||
@ -793,35 +793,43 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
GR.settransparency(1.0)
|
GR.settransparency(1.0)
|
||||||
|
|
||||||
# axis lines
|
# axis lines
|
||||||
gr_set_line(1, :solid, xaxis[:foreground_color_axis])
|
if xaxis[:showaxis]
|
||||||
GR.setclip(0)
|
gr_set_line(1, :solid, xaxis[:foreground_color_axis])
|
||||||
gr_polyline(coords(xspine_segs)...)
|
GR.setclip(0)
|
||||||
gr_set_line(1, :solid, yaxis[:foreground_color_axis])
|
gr_polyline(coords(xspine_segs)...)
|
||||||
GR.setclip(0)
|
end
|
||||||
gr_polyline(coords(yspine_segs)...)
|
if yaxis[:showaxis]
|
||||||
|
gr_set_line(1, :solid, yaxis[:foreground_color_axis])
|
||||||
|
GR.setclip(0)
|
||||||
|
gr_polyline(coords(yspine_segs)...)
|
||||||
|
end
|
||||||
GR.setclip(1)
|
GR.setclip(1)
|
||||||
|
|
||||||
# axis ticks
|
# axis ticks
|
||||||
if sp[:framestyle] in (:zerolines, :grid)
|
if xaxis[:showaxis]
|
||||||
gr_set_line(1, :solid, xaxis[:foreground_color_grid])
|
if sp[:framestyle] in (:zerolines, :grid)
|
||||||
GR.settransparency(xaxis[:gridalpha])
|
gr_set_line(1, :solid, xaxis[:foreground_color_grid])
|
||||||
else
|
GR.settransparency(xaxis[:gridalpha])
|
||||||
gr_set_line(1, :solid, xaxis[:foreground_color_axis])
|
else
|
||||||
|
gr_set_line(1, :solid, xaxis[:foreground_color_axis])
|
||||||
|
end
|
||||||
|
GR.setclip(0)
|
||||||
|
gr_polyline(coords(xtick_segs)...)
|
||||||
end
|
end
|
||||||
GR.setclip(0)
|
if yaxis[:showaxis]
|
||||||
gr_polyline(coords(xtick_segs)...)
|
if sp[:framestyle] in (:zerolines, :grid)
|
||||||
if sp[:framestyle] in (:zerolines, :grid)
|
gr_set_line(1, :solid, yaxis[:foreground_color_grid])
|
||||||
gr_set_line(1, :solid, yaxis[:foreground_color_grid])
|
GR.settransparency(yaxis[:gridalpha])
|
||||||
GR.settransparency(yaxis[:gridalpha])
|
else
|
||||||
else
|
gr_set_line(1, :solid, yaxis[:foreground_color_axis])
|
||||||
gr_set_line(1, :solid, yaxis[:foreground_color_axis])
|
end
|
||||||
|
GR.setclip(0)
|
||||||
|
gr_polyline(coords(ytick_segs)...)
|
||||||
end
|
end
|
||||||
GR.setclip(0)
|
|
||||||
gr_polyline(coords(ytick_segs)...)
|
|
||||||
GR.setclip(1)
|
GR.setclip(1)
|
||||||
|
|
||||||
# tick marks
|
# tick marks
|
||||||
if !(xticks in (:none, nothing, false))
|
if !(xticks in (:none, nothing, false)) && xaxis[:showaxis]
|
||||||
# x labels
|
# x labels
|
||||||
flip, mirror = gr_set_xticks_font(sp)
|
flip, mirror = gr_set_xticks_font(sp)
|
||||||
for (cv, dv) in zip(xticks...)
|
for (cv, dv) in zip(xticks...)
|
||||||
@ -832,7 +840,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if !(yticks in (:none, nothing, false))
|
if !(yticks in (:none, nothing, false)) && yaxis[:showaxis]
|
||||||
# y labels
|
# y labels
|
||||||
flip, mirror = gr_set_yticks_font(sp)
|
flip, mirror = gr_set_yticks_font(sp)
|
||||||
for (cv, dv) in zip(yticks...)
|
for (cv, dv) in zip(yticks...)
|
||||||
|
|||||||
@ -32,6 +32,7 @@ const _pgfplots_attr = merge_with_base_supported([
|
|||||||
:aspect_ratio,
|
:aspect_ratio,
|
||||||
# :match_dimensions,
|
# :match_dimensions,
|
||||||
:tick_direction,
|
:tick_direction,
|
||||||
|
:framestyle,
|
||||||
])
|
])
|
||||||
const _pgfplots_seriestype = [:path, :path3d, :scatter, :steppre, :stepmid, :steppost, :histogram2d, :ysticks, :xsticks, :contour, :shape]
|
const _pgfplots_seriestype = [:path, :path3d, :scatter, :steppre, :stepmid, :steppost, :histogram2d, :ysticks, :xsticks, :contour, :shape]
|
||||||
const _pgfplots_style = [:auto, :solid, :dash, :dot, :dashdot, :dashdotdot]
|
const _pgfplots_style = [:auto, :solid, :dash, :dot, :dashdot, :dashdotdot]
|
||||||
@ -107,6 +108,18 @@ const _pgf_annotation_halign = KW(
|
|||||||
:right => "left"
|
:right => "left"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const _pgf_framestyles = [:box, :axes, :origin, :zerolines, :grid, :none]
|
||||||
|
const _pgf_framestyle_defaults = Dict(:semi => :box)
|
||||||
|
function pgf_framestyle(style::Symbol)
|
||||||
|
if style in _pgf_framestyles
|
||||||
|
return style
|
||||||
|
else
|
||||||
|
default_style = get(_pgf_framestyle_defaults, style, :axes)
|
||||||
|
warn("Framestyle :$style is not (yet) supported by the PGFPlots backend. :$default_style was cosen instead.")
|
||||||
|
default_style
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# --------------------------------------------------------------------------------------
|
# --------------------------------------------------------------------------------------
|
||||||
|
|
||||||
# takes in color,alpha, and returns color and alpha appropriate for pgf style
|
# takes in color,alpha, and returns color and alpha appropriate for pgf style
|
||||||
@ -246,6 +259,9 @@ function pgf_axis(sp::Subplot, letter)
|
|||||||
style = []
|
style = []
|
||||||
kw = KW()
|
kw = KW()
|
||||||
|
|
||||||
|
# set to supported framestyle
|
||||||
|
framestyle = pgf_framestyle(sp[:framestyle])
|
||||||
|
|
||||||
# axis guide
|
# axis guide
|
||||||
kw[Symbol(letter,:label)] = axis[:guide]
|
kw[Symbol(letter,:label)] = axis[:guide]
|
||||||
|
|
||||||
@ -263,12 +279,12 @@ function pgf_axis(sp::Subplot, letter)
|
|||||||
end
|
end
|
||||||
|
|
||||||
# ticks on or off
|
# ticks on or off
|
||||||
if axis[:ticks] in (nothing, false)
|
if axis[:ticks] in (nothing, false) || framestyle == :none
|
||||||
push!(style, "$(letter)majorticks=false")
|
push!(style, "$(letter)majorticks=false")
|
||||||
end
|
end
|
||||||
|
|
||||||
# grid on or off
|
# grid on or off
|
||||||
if axis[:grid]
|
if axis[:grid] && framestyle != :none
|
||||||
push!(style, "$(letter)majorgrids = true")
|
push!(style, "$(letter)majorgrids = true")
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -280,13 +296,37 @@ function pgf_axis(sp::Subplot, letter)
|
|||||||
kw[Symbol(letter,:max)] = lims[2]
|
kw[Symbol(letter,:max)] = lims[2]
|
||||||
end
|
end
|
||||||
|
|
||||||
if !(axis[:ticks] in (nothing, false, :none))
|
if !(axis[:ticks] in (nothing, false, :none)) && framestyle != :none
|
||||||
ticks = get_ticks(axis)
|
ticks = get_ticks(axis)
|
||||||
push!(style, string(letter, "tick = {", join(ticks[1],","), "}"))
|
push!(style, string(letter, "tick = {", join(ticks[1],","), "}"))
|
||||||
push!(style, string(letter, "ticklabels = {", join(ticks[2],","), "}"))
|
if axis[:showaxis]
|
||||||
|
push!(style, string(letter, "ticklabels = {", join(ticks[2],","), "}"))
|
||||||
|
else
|
||||||
|
push!(style, string(letter, "ticklabels = {}"))
|
||||||
|
end
|
||||||
push!(style, string(letter, "tick align = ", (axis[:tick_direction] == :out ? "outside" : "inside")))
|
push!(style, string(letter, "tick align = ", (axis[:tick_direction] == :out ? "outside" : "inside")))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# framestyle
|
||||||
|
if framestyle in (:axes, :origin)
|
||||||
|
axispos = framestyle == :axes ? "left" : "middle"
|
||||||
|
# the * after lines disables the arrows at the axes
|
||||||
|
push!(style, string("axis lines* = ", axispos))
|
||||||
|
end
|
||||||
|
|
||||||
|
if framestyle == :zerolines
|
||||||
|
push!(style, string("extra ", letter, " ticks = 0"))
|
||||||
|
push!(style, string("extra ", letter, " tick labels = "))
|
||||||
|
push!(style, string("extra ", letter, " tick style = {grid = major, major grid style = {color = black, draw opacity=1.0, line width=0.5), solid}}"))
|
||||||
|
end
|
||||||
|
|
||||||
|
if !axis[:showaxis]
|
||||||
|
push!(style, "separate axis lines")
|
||||||
|
end
|
||||||
|
if !axis[:showaxis] || framestyle in (:zerolines, :grid, :none)
|
||||||
|
push!(style, string(letter, " axis line style = {draw opacity = 0}"))
|
||||||
|
end
|
||||||
|
|
||||||
# return the style list and KW args
|
# return the style list and KW args
|
||||||
style, kw
|
style, kw
|
||||||
end
|
end
|
||||||
|
|||||||
@ -234,10 +234,11 @@ function plotly_axis(axis::Axis, sp::Subplot)
|
|||||||
:gridwidth => axis[:gridlinewidth],
|
:gridwidth => axis[:gridlinewidth],
|
||||||
:zeroline => framestyle == :zerolines,
|
:zeroline => framestyle == :zerolines,
|
||||||
:zerolinecolor => rgba_string(axis[:foreground_color_axis]),
|
:zerolinecolor => rgba_string(axis[:foreground_color_axis]),
|
||||||
:showline => framestyle in (:box, :axes),
|
:showline => framestyle in (:box, :axes) && axis[:showaxis],
|
||||||
:linecolor => rgba_string(plot_color(axis[:foreground_color_axis])),
|
:linecolor => rgba_string(plot_color(axis[:foreground_color_axis])),
|
||||||
:ticks => axis[:tick_direction] == :out ? "outside" : "inside",
|
:ticks => axis[:tick_direction] == :out ? "outside" : "inside",
|
||||||
:mirror => framestyle == :box,
|
:mirror => framestyle == :box,
|
||||||
|
:showticklabels => axis[:showaxis],
|
||||||
)
|
)
|
||||||
|
|
||||||
if letter in (:x,:y)
|
if letter in (:x,:y)
|
||||||
@ -251,7 +252,7 @@ function plotly_axis(axis::Axis, sp::Subplot)
|
|||||||
ax[:titlefont] = plotly_font(axis[:guidefont], axis[:foreground_color_guide])
|
ax[:titlefont] = plotly_font(axis[:guidefont], axis[:foreground_color_guide])
|
||||||
ax[:type] = plotly_scale(axis[:scale])
|
ax[:type] = plotly_scale(axis[:scale])
|
||||||
ax[:tickfont] = plotly_font(axis[:tickfont], axis[:foreground_color_text])
|
ax[:tickfont] = plotly_font(axis[:tickfont], axis[:foreground_color_text])
|
||||||
ax[:tickcolor] = framestyle in (:zerolines, :grid) ? rgba_string(invisible()) : rgb_string(axis[:foreground_color_axis])
|
ax[:tickcolor] = framestyle in (:zerolines, :grid) || !axis[:showaxis] ? rgba_string(invisible()) : rgb_string(axis[:foreground_color_axis])
|
||||||
ax[:linecolor] = rgba_string(axis[:foreground_color_axis])
|
ax[:linecolor] = rgba_string(axis[:foreground_color_axis])
|
||||||
|
|
||||||
# lims
|
# lims
|
||||||
|
|||||||
@ -1081,6 +1081,24 @@ function _before_layout_calcs(plt::Plot{PyPlotBackend})
|
|||||||
py_set_axis_colors(sp, ax, axis)
|
py_set_axis_colors(sp, ax, axis)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# showaxis
|
||||||
|
if !sp[:xaxis][:showaxis]
|
||||||
|
kw = KW()
|
||||||
|
for dir in (:top, :bottom)
|
||||||
|
ax[:spines][string(dir)][:set_visible](false)
|
||||||
|
kw[dir] = kw[Symbol(:label,dir)] = "off"
|
||||||
|
end
|
||||||
|
ax[:xaxis][:set_tick_params](; which="both", kw...)
|
||||||
|
end
|
||||||
|
if !sp[:yaxis][:showaxis]
|
||||||
|
kw = KW()
|
||||||
|
for dir in (:left, :right)
|
||||||
|
ax[:spines][string(dir)][:set_visible](false)
|
||||||
|
kw[dir] = kw[Symbol(:label,dir)] = "off"
|
||||||
|
end
|
||||||
|
ax[:yaxis][:set_tick_params](; which="both", kw...)
|
||||||
|
end
|
||||||
|
|
||||||
# aspect ratio
|
# aspect ratio
|
||||||
aratio = sp[:aspect_ratio]
|
aratio = sp[:aspect_ratio]
|
||||||
if aratio != :none
|
if aratio != :none
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user