discrete value fixes; margin args; check for fillrange in contourf; skip test 6
This commit is contained in:
parent
0a00d1fbf3
commit
90e22f179e
13
src/args.jl
13
src/args.jl
@ -205,6 +205,11 @@ const _subplot_defaults = KW(
|
|||||||
# :polar => false,
|
# :polar => false,
|
||||||
:projection => :none, # can also be :polar or :3d
|
:projection => :none, # can also be :polar or :3d
|
||||||
:aspect_ratio => :none, # choose from :none or :equal
|
:aspect_ratio => :none, # choose from :none or :equal
|
||||||
|
:margin => 2mm,
|
||||||
|
:left_margin => :match,
|
||||||
|
:top_margin => :match,
|
||||||
|
:right_margin => :match,
|
||||||
|
:bottom_margin => :match,
|
||||||
)
|
)
|
||||||
|
|
||||||
const _axis_defaults = KW(
|
const _axis_defaults = KW(
|
||||||
@ -393,7 +398,7 @@ add_aliases(:aspect_ratio, :aspectratio, :axis_ratio, :axisratio, :ratio)
|
|||||||
add_aliases(:match_dimensions, :transpose, :transpose_z)
|
add_aliases(:match_dimensions, :transpose, :transpose_z)
|
||||||
add_aliases(:subplot, :sp, :subplt, :splt)
|
add_aliases(:subplot, :sp, :subplt, :splt)
|
||||||
add_aliases(:projection, :proj)
|
add_aliases(:projection, :proj)
|
||||||
add_aliases(:title_location, :title_loc, :titleloc)
|
add_aliases(:title_location, :title_loc, :titleloc, :title_position, :title_pos, :titlepos, :titleposition, :title_align, :title_alignment)
|
||||||
add_aliases(:series_annotations, :series_ann, :seriesann, :series_anns, :seriesanns, :series_annotation)
|
add_aliases(:series_annotations, :series_ann, :seriesann, :series_anns, :seriesanns, :series_annotation)
|
||||||
|
|
||||||
|
|
||||||
@ -955,6 +960,12 @@ function _update_subplot_args(plt::Plot, sp::Subplot, d_in::KW, subplot_index::I
|
|||||||
color_or_match!(spargs, :foreground_color_grid, fg)
|
color_or_match!(spargs, :foreground_color_grid, fg)
|
||||||
color_or_match!(spargs, :foreground_color_title, fg)
|
color_or_match!(spargs, :foreground_color_title, fg)
|
||||||
|
|
||||||
|
for k in (:left_margin, :top_margin, :right_margin, :bottom_margin)
|
||||||
|
if spargs[k] == :match
|
||||||
|
spargs[k] = spargs[:margin]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# info("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
|
# info("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
|
||||||
# DD(spargs, "before loop")
|
# DD(spargs, "before loop")
|
||||||
|
|
||||||
|
|||||||
31
src/axes.jl
31
src/axes.jl
@ -10,8 +10,10 @@ function Axis(letter::Symbol, args...; kw...)
|
|||||||
d = KW(
|
d = KW(
|
||||||
:letter => letter,
|
:letter => letter,
|
||||||
:extrema => (Inf, -Inf),
|
:extrema => (Inf, -Inf),
|
||||||
:discrete_map => Dict(), # map discrete values to continuous plot values
|
:discrete_map => Dict(), # map discrete values to discrete indices
|
||||||
:discrete_values => Tuple{Float64,Any}[],
|
# :discrete_values => Tuple{Float64,Any}[],
|
||||||
|
:discrete_values => [],
|
||||||
|
:continuous_values => zeros(0),
|
||||||
:use_minor => false,
|
:use_minor => false,
|
||||||
:show => true, # show or hide the axis? (useful for linked subplots)
|
:show => true, # show or hide the axis? (useful for linked subplots)
|
||||||
)
|
)
|
||||||
@ -89,7 +91,8 @@ function get_ticks(a::Axis)
|
|||||||
ticks = a[:ticks]
|
ticks = a[:ticks]
|
||||||
dvals = a[:discrete_values]
|
dvals = a[:discrete_values]
|
||||||
if !isempty(dvals) && ticks == :auto
|
if !isempty(dvals) && ticks == :auto
|
||||||
vals, labels = unzip(dvals)
|
# vals, labels = unzip(dvals)
|
||||||
|
a[:continuous_values], dvals
|
||||||
else
|
else
|
||||||
ticks
|
ticks
|
||||||
end
|
end
|
||||||
@ -114,20 +117,28 @@ end
|
|||||||
# these methods track the discrete values which correspond to axis continuous values (cv)
|
# these methods track the discrete values which correspond to axis continuous values (cv)
|
||||||
# whenever we have discrete values, we automatically set the ticks to match.
|
# whenever we have discrete values, we automatically set the ticks to match.
|
||||||
# we return (continuous_value, discrete_index)
|
# we return (continuous_value, discrete_index)
|
||||||
function discrete_value!(a::Axis, v)
|
function discrete_value!(a::Axis, dv)
|
||||||
cv_idx = get(a[:discrete_map], v, 0)
|
cv_idx = get(a[:discrete_map], dv, -1)
|
||||||
if cv_idx == 0
|
if cv_idx == -1
|
||||||
emin, emax = a[:extrema]
|
emin, emax = a[:extrema]
|
||||||
cv = max(0.5, emax + 1.0)
|
cv = max(0.5, emax + 1.0)
|
||||||
expand_extrema!(a, cv)
|
expand_extrema!(a, cv)
|
||||||
a[:discrete_map][v] = cv
|
push!(a[:discrete_values], dv)
|
||||||
push!(a[:discrete_values], (cv, v))
|
push!(a[:continuous_values], cv)
|
||||||
cv, length(a[:discrete_values])
|
cv_idx = length(a[:discrete_values])
|
||||||
|
a[:discrete_map][dv] = cv_idx
|
||||||
|
cv, cv_idx
|
||||||
else
|
else
|
||||||
a[:discrete_values][cv_idx][1], cv_idx
|
cv = a[:continuous_values][cv_idx]
|
||||||
|
cv, cv_idx
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# continuous value... just pass back with a negative index
|
||||||
|
function discrete_value!(a::Axis, cv::Number)
|
||||||
|
cv, -1
|
||||||
|
end
|
||||||
|
|
||||||
# add the discrete value for each item. return the continuous values and the indices
|
# add the discrete value for each item. return the continuous values and the indices
|
||||||
function discrete_value!(a::Axis, v::AVec)
|
function discrete_value!(a::Axis, v::AVec)
|
||||||
n = length(v)
|
n = length(v)
|
||||||
|
|||||||
@ -461,7 +461,11 @@ function _update_min_padding!(sp::Subplot{PyPlotBackend})
|
|||||||
|
|
||||||
# TODO: this should initialize to the margin from sp.attr
|
# TODO: this should initialize to the margin from sp.attr
|
||||||
# figure out how much the axis components and title "stick out" from the plot area
|
# figure out how much the axis components and title "stick out" from the plot area
|
||||||
leftpad = toppad = rightpad = bottompad = 1mm
|
# leftpad = toppad = rightpad = bottompad = 1mm
|
||||||
|
leftpad = sp.attr[:left_margin]
|
||||||
|
toppad = sp.attr[:top_margin]
|
||||||
|
rightpad = sp.attr[:right_margin]
|
||||||
|
bottompad = sp.attr[:bottom_margin]
|
||||||
for bb in (py_bbox_axis(ax, "x"), py_bbox_axis(ax, "y"), py_bbox_title(ax))
|
for bb in (py_bbox_axis(ax, "x"), py_bbox_axis(ax, "y"), py_bbox_title(ax))
|
||||||
if ispositive(width(bb)) && ispositive(height(bb))
|
if ispositive(width(bb)) && ispositive(height(bb))
|
||||||
leftpad = max(leftpad, left(plotbb) - left(bb))
|
leftpad = max(leftpad, left(plotbb) - left(bb))
|
||||||
@ -717,7 +721,7 @@ function _series_added(plt::Plot{PyPlotBackend}, series::Series)
|
|||||||
push!(handles, handle)
|
push!(handles, handle)
|
||||||
|
|
||||||
# contour fills
|
# contour fills
|
||||||
# if st == :contour
|
if d[:fillrange] != nothing
|
||||||
handle = ax[:contourf](x, y, z, levelargs...;
|
handle = ax[:contourf](x, y, z, levelargs...;
|
||||||
label = d[:label],
|
label = d[:label],
|
||||||
zorder = plt.n + 0.5,
|
zorder = plt.n + 0.5,
|
||||||
@ -725,7 +729,7 @@ function _series_added(plt::Plot{PyPlotBackend}, series::Series)
|
|||||||
extrakw...
|
extrakw...
|
||||||
)
|
)
|
||||||
push!(handles, handle)
|
push!(handles, handle)
|
||||||
# end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if st in (:surface, :wireframe)
|
if st in (:surface, :wireframe)
|
||||||
@ -837,13 +841,12 @@ function _series_added(plt::Plot{PyPlotBackend}, series::Series)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if st == :pie
|
if st == :pie
|
||||||
|
|
||||||
handle = ax[:pie](y;
|
handle = ax[:pie](y;
|
||||||
# label = d[:label],
|
|
||||||
# colors = # a vector of colors?
|
# colors = # a vector of colors?
|
||||||
# labels = x
|
|
||||||
labels = if haskey(d,:x_discrete_indices)
|
labels = if haskey(d,:x_discrete_indices)
|
||||||
dvals = sp.attr[:xaxis].d[:discrete_values]
|
dvals = sp.attr[:xaxis].d[:discrete_values]
|
||||||
[dvals[idx][2] for idx in d[:x_discrete_indices]]
|
[dvals[idx] for idx in d[:x_discrete_indices]]
|
||||||
else
|
else
|
||||||
d[:x]
|
d[:x]
|
||||||
end
|
end
|
||||||
|
|||||||
@ -119,10 +119,11 @@ function _apply_series_recipe(plt::Plot, d::KW)
|
|||||||
axis = sp.attr[symbol(letter, "axis")]
|
axis = sp.attr[symbol(letter, "axis")]
|
||||||
if eltype(data) <: Number
|
if eltype(data) <: Number
|
||||||
expand_extrema!(axis, data)
|
expand_extrema!(axis, data)
|
||||||
else
|
elseif data != nothing
|
||||||
# TODO: need more here... gotta track the discrete reference value
|
# TODO: need more here... gotta track the discrete reference value
|
||||||
# as well as any coord offset (think of boxplot shape coords... they all
|
# as well as any coord offset (think of boxplot shape coords... they all
|
||||||
# correspond to the same x-value)
|
# correspond to the same x-value)
|
||||||
|
# @show letter,eltype(data),typeof(data)
|
||||||
d[letter], d[symbol(letter,"_discrete_indices")] = discrete_value!(axis, data)
|
d[letter], d[symbol(letter,"_discrete_indices")] = discrete_value!(axis, data)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -16,21 +16,21 @@ facts("Gadfly") do
|
|||||||
@fact plot(sort(rand(10)), rand(Int, 10, 3)) --> not(nothing)
|
@fact plot(sort(rand(10)), rand(Int, 10, 3)) --> not(nothing)
|
||||||
@fact plot!(rand(10,3), rand(10,3)) --> not(nothing)
|
@fact plot!(rand(10,3), rand(10,3)) --> not(nothing)
|
||||||
|
|
||||||
image_comparison_facts(:gadfly, skip=[4,6,19,23,24,27], eps=img_eps)
|
image_comparison_facts(:gadfly, skip=[4,6,23,24,27], eps=img_eps)
|
||||||
end
|
end
|
||||||
|
|
||||||
facts("PyPlot") do
|
facts("PyPlot") do
|
||||||
@fact pyplot() --> Plots.PyPlotBackend()
|
@fact pyplot() --> Plots.PyPlotBackend()
|
||||||
@fact backend() --> Plots.PyPlotBackend()
|
@fact backend() --> Plots.PyPlotBackend()
|
||||||
|
|
||||||
image_comparison_facts(:pyplot, skip=[19], eps=img_eps)
|
image_comparison_facts(:pyplot, skip=[6], eps=img_eps)
|
||||||
end
|
end
|
||||||
|
|
||||||
facts("GR") do
|
facts("GR") do
|
||||||
@fact gr() --> Plots.GRBackend()
|
@fact gr() --> Plots.GRBackend()
|
||||||
@fact backend() --> Plots.GRBackend()
|
@fact backend() --> Plots.GRBackend()
|
||||||
|
|
||||||
@linux_only image_comparison_facts(:gr, skip=[24], eps=img_eps)
|
@linux_only image_comparison_facts(:gr, skip=[6,24], eps=img_eps)
|
||||||
end
|
end
|
||||||
|
|
||||||
facts("Plotly") do
|
facts("Plotly") do
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user