working on layout
This commit is contained in:
parent
35ff449dc3
commit
61107b8577
@ -199,7 +199,7 @@ _plotDefaults[:size] = (600,400)
|
|||||||
_plotDefaults[:pos] = (0,0)
|
_plotDefaults[:pos] = (0,0)
|
||||||
_plotDefaults[:windowtitle] = "Plots.jl"
|
_plotDefaults[:windowtitle] = "Plots.jl"
|
||||||
_plotDefaults[:show] = false
|
_plotDefaults[:show] = false
|
||||||
_plotDefaults[:layout] = nothing
|
_plotDefaults[:layout] = :auto
|
||||||
_plotDefaults[:n] = -1
|
_plotDefaults[:n] = -1
|
||||||
_plotDefaults[:nr] = -1
|
_plotDefaults[:nr] = -1
|
||||||
_plotDefaults[:nc] = -1
|
_plotDefaults[:nc] = -1
|
||||||
|
|||||||
@ -35,6 +35,7 @@ supportedArgs(::PyPlotBackend) = [
|
|||||||
:polar,
|
:polar,
|
||||||
:normalize, :weights, :contours, :aspect_ratio,
|
:normalize, :weights, :contours, :aspect_ratio,
|
||||||
:match_dimensions,
|
:match_dimensions,
|
||||||
|
:subplot,
|
||||||
]
|
]
|
||||||
supportedAxes(::PyPlotBackend) = _allAxes
|
supportedAxes(::PyPlotBackend) = _allAxes
|
||||||
supportedTypes(::PyPlotBackend) = [
|
supportedTypes(::PyPlotBackend) = [
|
||||||
@ -333,7 +334,8 @@ end
|
|||||||
# each backend should set up the subplot here
|
# each backend should set up the subplot here
|
||||||
function _initialize_subplot(plt::Plot{PyPlotBackend}, sp::Subplot{PyPlotBackend})
|
function _initialize_subplot(plt::Plot{PyPlotBackend}, sp::Subplot{PyPlotBackend})
|
||||||
fig = plt.o
|
fig = plt.o
|
||||||
ax = fig[:add_axes]([0,0,1,1])
|
# add a new axis, and force it to create a new one by setting a distinct label
|
||||||
|
ax = fig[:add_axes]([0,0,1,1], label = string(gensym()))
|
||||||
for axis in (:xaxis, :yaxis)
|
for axis in (:xaxis, :yaxis)
|
||||||
ax[axis][:_autolabelpos] = false
|
ax[axis][:_autolabelpos] = false
|
||||||
end
|
end
|
||||||
|
|||||||
10
src/plot.jl
10
src/plot.jl
@ -60,7 +60,9 @@ function plot(args...; kw...)
|
|||||||
|
|
||||||
plt.layout, plt.subplots, plt.spmap = build_layout(pop!(d, :layout, :auto))
|
plt.layout, plt.subplots, plt.spmap = build_layout(pop!(d, :layout, :auto))
|
||||||
for sp in plt.subplots
|
for sp in plt.subplots
|
||||||
|
@show sp.o
|
||||||
_initialize_subplot(plt, sp)
|
_initialize_subplot(plt, sp)
|
||||||
|
@show sp.o
|
||||||
end
|
end
|
||||||
|
|
||||||
# now update the plot
|
# now update the plot
|
||||||
@ -275,12 +277,12 @@ function _plot!(plt::Plot, d::KW, args...)
|
|||||||
# merge plot args... this is where we combine all the plot args from the user and
|
# merge plot args... this is where we combine all the plot args from the user and
|
||||||
# from the recipes... axis info, colors, etc
|
# from the recipes... axis info, colors, etc
|
||||||
# TODO: why do i need to check for the subplot key?
|
# TODO: why do i need to check for the subplot key?
|
||||||
if !haskey(d, :subplot)
|
# if !haskey(d, :subplot)
|
||||||
for kw in vcat(kw_list, d)
|
for kw in vcat(kw_list, d)
|
||||||
_add_plotargs!(plt, kw)
|
_add_plotargs!(plt, kw)
|
||||||
end
|
end
|
||||||
handlePlotColors(plt.backend, plt.plotargs)
|
handlePlotColors(plt.backend, plt.plotargs)
|
||||||
end
|
# end
|
||||||
|
|
||||||
# for kw in kw_list
|
# for kw in kw_list
|
||||||
# @show typeof((kw[:x], kw[:y], kw[:z]))
|
# @show typeof((kw[:x], kw[:y], kw[:z]))
|
||||||
@ -334,10 +336,10 @@ function _plot!(plt::Plot, d::KW, args...)
|
|||||||
|
|
||||||
# add title, axis labels, ticks, etc
|
# add title, axis labels, ticks, etc
|
||||||
# TODO: do we really need this subplot check?
|
# TODO: do we really need this subplot check?
|
||||||
if !haskey(d, :subplot)
|
# if !haskey(d, :subplot)
|
||||||
# merge!(plt.plotargs, d) # this shouldn't be needed since we merged the keys earlier
|
# merge!(plt.plotargs, d) # this shouldn't be needed since we merged the keys earlier
|
||||||
_update_plot(plt, plt.plotargs)
|
_update_plot(plt, plt.plotargs)
|
||||||
end
|
# end
|
||||||
|
|
||||||
current(plt)
|
current(plt)
|
||||||
|
|
||||||
|
|||||||
@ -14,9 +14,9 @@ function _add_defaults!(d::KW, plt::Plot, commandIndex::Int)
|
|||||||
setDictValue(d, d, k, commandIndex, _seriesDefaults)
|
setDictValue(d, d, k, commandIndex, _seriesDefaults)
|
||||||
end
|
end
|
||||||
|
|
||||||
if d[:subplot_index] == :auto
|
if d[:subplot] == :auto
|
||||||
# TODO: something useful
|
# TODO: something useful
|
||||||
d[:subplot_index] = 1
|
d[:subplot] = 1
|
||||||
end
|
end
|
||||||
|
|
||||||
aliasesAndAutopick(d, :axis, _axesAliases, supportedAxes(pkg), plotIndex)
|
aliasesAndAutopick(d, :axis, _axesAliases, supportedAxes(pkg), plotIndex)
|
||||||
@ -66,7 +66,7 @@ function _add_defaults!(d::KW, plt::Plot, commandIndex::Int)
|
|||||||
label = string(label, " (R)")
|
label = string(label, " (R)")
|
||||||
end
|
end
|
||||||
d[:label] = label
|
d[:label] = label
|
||||||
|
|
||||||
d
|
d
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -149,16 +149,22 @@ function update_bboxes!(layout::GridLayout) #, parent_bbox::BoundingBox = Boundi
|
|||||||
|
|
||||||
# TODO: this should really track used/free space for each row/column so that we can align plot areas properly
|
# TODO: this should really track used/free space for each row/column so that we can align plot areas properly
|
||||||
|
|
||||||
l, b = 0.0, 0.0
|
# l, b = 0.0, 0.0
|
||||||
|
rights = zeros(nc)
|
||||||
|
tops = zeros(nr)
|
||||||
for r=1:nr, c=1:nc
|
for r=1:nr, c=1:nc
|
||||||
# compute the child's bounding box relative to the parent
|
# compute the child's bounding box relative to the parent
|
||||||
child = layout[r,c]
|
child = layout[r,c]
|
||||||
usedw, usedh = used_size(child)
|
usedw, usedh = used_size(child)
|
||||||
child_bbox = BoundingBox(
|
|
||||||
l, b,
|
left = (c == 1 ? 0 : rights[c-1])
|
||||||
l + usedw + freew * layout.widths[c],
|
bottom = (r == 1 ? 0 : tops[r-1])
|
||||||
b + usedh + freeh * layout.heights[r]
|
right = left + usedw + freew * layout.widths[c]
|
||||||
)
|
top = bottom + usedh + freeh * layout.heights[r]
|
||||||
|
child_bbox = BoundingBox(left, bottom, right, top)
|
||||||
|
|
||||||
|
rights[c] = right
|
||||||
|
tops[r] = top
|
||||||
|
|
||||||
# then compute the bounding box relative to the canvas, and cache it in the child object
|
# then compute the bounding box relative to the canvas, and cache it in the child object
|
||||||
bbox!(child, crop(bbox(layout), child_bbox))
|
bbox!(child, crop(bbox(layout), child_bbox))
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user