fix gaston layout
This commit is contained in:
parent
26ddb62a27
commit
4c9fd4e4b7
@ -11,8 +11,7 @@ const GNUPLOT_DPI = 72 # Compensate for DPI with increased resolution
|
|||||||
#
|
#
|
||||||
# Create the window/figure for this backend.
|
# Create the window/figure for this backend.
|
||||||
function _create_backend_figure(plt::Plot{GastonBackend})
|
function _create_backend_figure(plt::Plot{GastonBackend})
|
||||||
xsize = plt.attr[:size][1]
|
xsize, ysize = plt.attr[:size]
|
||||||
ysize = plt.attr[:size][2]
|
|
||||||
G.set(termopts="""size $xsize,$ysize""")
|
G.set(termopts="""size $xsize,$ysize""")
|
||||||
|
|
||||||
state_handle = G.nexthandle() # for now all the figures will be kept
|
state_handle = G.nexthandle() # for now all the figures will be kept
|
||||||
@ -23,12 +22,17 @@ end
|
|||||||
function _before_layout_calcs(plt::Plot{GastonBackend})
|
function _before_layout_calcs(plt::Plot{GastonBackend})
|
||||||
# Initialize all the subplots first
|
# Initialize all the subplots first
|
||||||
plt.o.subplots = G.SubPlot[]
|
plt.o.subplots = G.SubPlot[]
|
||||||
grid = size(plt.layout)
|
nr, nc = plt.o.layout = size(plt.layout)
|
||||||
plt.o.layout = grid
|
|
||||||
|
|
||||||
|
n = 0
|
||||||
|
sps = Array{Any}(undef, nr, nc)
|
||||||
|
for r ∈ 1:nr, c ∈ 1:nc # NOTE: row major
|
||||||
|
l = plt.layout.grid[r, c]
|
||||||
|
sps[r, c] = get(l.attr, :blank, false) ? nothing : plt.subplots[n += 1]
|
||||||
|
end
|
||||||
|
|
||||||
for sp in plt.subplots
|
for c ∈ 1:nc, r ∈ 1:nr # NOTE: col major
|
||||||
gaston_init_subplot(plt, sp)
|
gaston_init_subplot(plt, sps[r, c])
|
||||||
end
|
end
|
||||||
|
|
||||||
# Then add the series (curves in gaston)
|
# Then add the series (curves in gaston)
|
||||||
@ -102,18 +106,22 @@ end
|
|||||||
function _display(plt::Plot{GastonBackend})
|
function _display(plt::Plot{GastonBackend})
|
||||||
display(plt.o)
|
display(plt.o)
|
||||||
end
|
end
|
||||||
#
|
|
||||||
# --------------------------------------------
|
# --------------------------------------------
|
||||||
# These functions are gaston specific
|
# These functions are gaston specific
|
||||||
# --------------------------------------------
|
# --------------------------------------------
|
||||||
#
|
|
||||||
function gaston_init_subplot(plt::Plot{GastonBackend}, sp::Subplot{GastonBackend})
|
function gaston_init_subplot(plt::Plot{GastonBackend}, sp::Subplot{GastonBackend})
|
||||||
dims = RecipesPipeline.is3d(sp) ? 3 : 2
|
if sp === nothing
|
||||||
|
push!(plt.o.subplots, sp)
|
||||||
|
else
|
||||||
|
dims = RecipesPipeline.is3d(sp) ? 3 : 2
|
||||||
|
|
||||||
axesconf = gaston_parse_axes_args(plt, sp) # Gnuplot string
|
axesconf = gaston_parse_axes_args(plt, sp) # Gnuplot string
|
||||||
sp.o = GastonSubplot(dims=dims, axesconf = axesconf, curves = [])
|
sp.o = GastonSubplot(dims=dims, axesconf=axesconf, curves=[])
|
||||||
push!(plt.o.subplots, sp.o)
|
|
||||||
|
|
||||||
|
push!(plt.o.subplots, sp.o)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function gaston_add_series(plt::Plot{GastonBackend}, series::Series)
|
function gaston_add_series(plt::Plot{GastonBackend}, series::Series)
|
||||||
@ -261,7 +269,7 @@ end
|
|||||||
|
|
||||||
function gaston_set_legend!(axesconf, sp)
|
function gaston_set_legend!(axesconf, sp)
|
||||||
leg = sp[:legend]
|
leg = sp[:legend]
|
||||||
if !(sp[:legend] in(:none, :inline))
|
if sp[:legend] ∉ (:none, :inline)
|
||||||
if leg == :best
|
if leg == :best
|
||||||
leg = :topright
|
leg = :topright
|
||||||
end
|
end
|
||||||
@ -305,7 +313,7 @@ function gaston_marker(marker)
|
|||||||
marker == :pentagon && return 15
|
marker == :pentagon && return 15
|
||||||
marker == :pixel && return 0
|
marker == :pixel && return 0
|
||||||
|
|
||||||
@warn("Unsupported marker $marker")
|
@warn "Unsupported marker $marker"
|
||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -324,7 +332,6 @@ function gaston_enclose_tick_string(tick_string)
|
|||||||
return tick_string
|
return tick_string
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
base, power = split(tick_string, "^")
|
base, power = split(tick_string, "^")
|
||||||
power = string("{", power, "}")
|
power = string("{", power, "}")
|
||||||
return string(base, "^", power)
|
return string(base, "^", power)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user