commit
dfb556339f
@ -70,7 +70,7 @@ const _arg_desc = KW(
|
|||||||
:dpi => "Number. Dots Per Inch of output figures",
|
:dpi => "Number. Dots Per Inch of output figures",
|
||||||
:thickness_scaling => "Number. Scale for the thickness of all line elements like lines, borders, axes, grid lines, ... defaults to 1.",
|
:thickness_scaling => "Number. Scale for the thickness of all line elements like lines, borders, axes, grid lines, ... defaults to 1.",
|
||||||
:display_type => "Symbol (`:auto`, `:gui`, or `:inline`). When supported, `display` will either open a GUI window or plot inline.",
|
:display_type => "Symbol (`:auto`, `:gui`, or `:inline`). When supported, `display` will either open a GUI window or plot inline.",
|
||||||
:extra_kwargs => "Either one of (`:plot`, `:subplot`, `:series`) to specify for which element extra keyword args are collected or a KW (Dict{Symbol,Any}) to pass a map of extra keyword args which may be specific to a backend. Default: `:series`.\n Example: `pgfplotsx(); scatter(1:5, extra_kwargs=Dict(:subplot=>Dict("axis line shift" => "10pt"))`",
|
:extra_kwargs => "Either one of (`:plot`, `:subplot`, `:series`) to specify for which element extra keyword args are collected or a KW (Dict{Symbol,Any}) to pass a map of extra keyword args which may be specific to a backend. Default: `:series`.\n Example: `pgfplotsx(); scatter(1:5, extra_kwargs=Dict(:subplot=>Dict(\"axis line shift\" => \"10pt\"))`",
|
||||||
:fontfamily => "String or Symbol. Default font family for title, legend entries, tick labels and guides",
|
:fontfamily => "String or Symbol. Default font family for title, legend entries, tick labels and guides",
|
||||||
:warn_on_unsupported => "Bool. Warn on unsupported attributes, series types and marker shapes",
|
:warn_on_unsupported => "Bool. Warn on unsupported attributes, series types and marker shapes",
|
||||||
|
|
||||||
|
|||||||
@ -228,7 +228,9 @@ function gr_polaraxes(rmin::Real, rmax::Real, sp::Subplot)
|
|||||||
|
|
||||||
#draw angular grid
|
#draw angular grid
|
||||||
if xaxis[:grid]
|
if xaxis[:grid]
|
||||||
gr_set_line(xaxis[:gridlinewidth], xaxis[:gridstyle], xaxis[:foreground_color_grid])
|
gr_set_line(
|
||||||
|
xaxis[:gridlinewidth], xaxis[:gridstyle], xaxis[:foreground_color_grid], sp
|
||||||
|
)
|
||||||
gr_set_transparency(xaxis[:foreground_color_grid], xaxis[:gridalpha])
|
gr_set_transparency(xaxis[:foreground_color_grid], xaxis[:gridalpha])
|
||||||
for i in eachindex(α)
|
for i in eachindex(α)
|
||||||
GR.polyline([sinf[i], 0], [cosf[i], 0])
|
GR.polyline([sinf[i], 0], [cosf[i], 0])
|
||||||
@ -237,7 +239,9 @@ function gr_polaraxes(rmin::Real, rmax::Real, sp::Subplot)
|
|||||||
|
|
||||||
#draw radial grid
|
#draw radial grid
|
||||||
if yaxis[:grid]
|
if yaxis[:grid]
|
||||||
gr_set_line(yaxis[:gridlinewidth], yaxis[:gridstyle], yaxis[:foreground_color_grid])
|
gr_set_line(
|
||||||
|
yaxis[:gridlinewidth], yaxis[:gridstyle], yaxis[:foreground_color_grid], sp
|
||||||
|
)
|
||||||
gr_set_transparency(yaxis[:foreground_color_grid], yaxis[:gridalpha])
|
gr_set_transparency(yaxis[:foreground_color_grid], yaxis[:gridalpha])
|
||||||
for i in eachindex(rtick_values)
|
for i in eachindex(rtick_values)
|
||||||
r = (rtick_values[i] - rmin) / (rmax - rmin)
|
r = (rtick_values[i] - rmin) / (rmax - rmin)
|
||||||
@ -301,7 +305,7 @@ function gr_draw_marker(series, xi, yi, clims, i, msize, strokewidth, shape::Sha
|
|||||||
sx, sy = coords(shape)
|
sx, sy = coords(shape)
|
||||||
# convert to ndc coords (percentages of window)
|
# convert to ndc coords (percentages of window)
|
||||||
GR.selntran(0)
|
GR.selntran(0)
|
||||||
w, h = gr_plot_size
|
w, h = get_size(series)
|
||||||
f = msize / (w + h)
|
f = msize / (w + h)
|
||||||
xi, yi = GR.wctondc(xi, yi)
|
xi, yi = GR.wctondc(xi, yi)
|
||||||
xs = xi .+ sx .* f
|
xs = xi .+ sx .* f
|
||||||
@ -315,14 +319,14 @@ function gr_draw_marker(series, xi, yi, clims, i, msize, strokewidth, shape::Sha
|
|||||||
|
|
||||||
# draw the shapes
|
# draw the shapes
|
||||||
msc = get_markerstrokecolor(series, i)
|
msc = get_markerstrokecolor(series, i)
|
||||||
gr_set_line(strokewidth, :solid, msc)
|
gr_set_line(strokewidth, :solid, msc, series)
|
||||||
gr_set_transparency(msc, get_markerstrokealpha(series, i))
|
gr_set_transparency(msc, get_markerstrokealpha(series, i))
|
||||||
GR.polyline(xs, ys)
|
GR.polyline(xs, ys)
|
||||||
GR.selntran(1)
|
GR.selntran(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
function nominal_size()
|
function nominal_size(s)
|
||||||
w, h = gr_plot_size
|
w, h = get_size(s)
|
||||||
min(w, h) / 500
|
min(w, h) / 500
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -333,7 +337,7 @@ function gr_draw_marker(series, xi, yi, clims, i, msize, strokewidth, shape::Sym
|
|||||||
gr_set_markercolor(get_markercolor(series, clims, i));
|
gr_set_markercolor(get_markercolor(series, clims, i));
|
||||||
gr_set_transparency(get_markeralpha(series, i))
|
gr_set_transparency(get_markeralpha(series, i))
|
||||||
GR.setmarkertype(gr_markertype(shape))
|
GR.setmarkertype(gr_markertype(shape))
|
||||||
GR.setmarkersize(0.3msize / nominal_size())
|
GR.setmarkersize(0.3msize / nominal_size(series))
|
||||||
GR.polymarker([xi], [yi])
|
GR.polymarker([xi], [yi])
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -354,8 +358,8 @@ function gr_draw_markers(
|
|||||||
shapes = series[:markershape]
|
shapes = series[:markershape]
|
||||||
if shapes != :none
|
if shapes != :none
|
||||||
for i in eachindex(x)
|
for i in eachindex(x)
|
||||||
ms = _gr_thickness_scaling[1] * _cycle(msize, i)
|
ms = get_thickness_scaling(series) * _cycle(msize, i)
|
||||||
msw = _gr_thickness_scaling[1] * _cycle(strokewidth, i)
|
msw = get_thickness_scaling(series) * _cycle(strokewidth, i)
|
||||||
shape = _cycle(shapes, i)
|
shape = _cycle(shapes, i)
|
||||||
gr_draw_marker(series, x[i], y[i], clims, i, ms, msw, shape)
|
gr_draw_marker(series, x[i], y[i], clims, i, ms, msw, shape)
|
||||||
end
|
end
|
||||||
@ -364,11 +368,10 @@ end
|
|||||||
|
|
||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
|
|
||||||
function gr_set_line(lw, style, c) #, a)
|
function gr_set_line(lw, style, c, s) # s can be Subplot or Series
|
||||||
GR.setlinetype(gr_linetype(style))
|
GR.setlinetype(gr_linetype(style))
|
||||||
w, h = gr_plot_size
|
GR.setlinewidth(get_thickness_scaling(s) * max(0, lw / nominal_size(s)))
|
||||||
GR.setlinewidth(_gr_thickness_scaling[1] * max(0, lw / nominal_size()))
|
gr_set_linecolor(c)
|
||||||
gr_set_linecolor(c) #, a)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -378,15 +381,15 @@ function gr_set_fill(c) #, a)
|
|||||||
GR.setfillintstyle(GR.INTSTYLE_SOLID)
|
GR.setfillintstyle(GR.INTSTYLE_SOLID)
|
||||||
end
|
end
|
||||||
|
|
||||||
# this stores the conversion from a font pointsize to "percentage of window height" (which is what GR uses)
|
# this stores the conversion from a font pointsize to "percentage of window height"
|
||||||
const _gr_point_mult = 0.0018 * ones(1)
|
# (which is what GR uses). `s` can be a Series, Subplot or Plot
|
||||||
const _gr_thickness_scaling = ones(1)
|
gr_point_mult(s) = 1.5 * get_thickness_scaling(s) * px / pt / maximum(get_size(s))
|
||||||
|
|
||||||
# set the font attributes... assumes _gr_point_mult has been populated already
|
# set the font attributes.
|
||||||
function gr_set_font(f::Font; halign = f.halign, valign = f.valign,
|
function gr_set_font(f::Font, s; halign = f.halign, valign = f.valign,
|
||||||
color = f.color, rotation = f.rotation)
|
color = f.color, rotation = f.rotation)
|
||||||
family = lowercase(f.family)
|
family = lowercase(f.family)
|
||||||
GR.setcharheight(_gr_point_mult[1] * f.pointsize)
|
GR.setcharheight(gr_point_mult(s) * f.pointsize)
|
||||||
GR.setcharup(sind(-rotation), cosd(-rotation))
|
GR.setcharup(sind(-rotation), cosd(-rotation))
|
||||||
if haskey(gr_font_family, family)
|
if haskey(gr_font_family, family)
|
||||||
GR.settextfontprec(100 + gr_font_family[family], GR.TEXT_PRECISION_STRING)
|
GR.settextfontprec(100 + gr_font_family[family], GR.TEXT_PRECISION_STRING)
|
||||||
@ -413,14 +416,6 @@ end
|
|||||||
|
|
||||||
# --------------------------------------------------------------------------------------
|
# --------------------------------------------------------------------------------------
|
||||||
# viewport plot area
|
# viewport plot area
|
||||||
|
|
||||||
# this stays constant for a given subplot while displaying that subplot.
|
|
||||||
# values are [xmin, xmax, ymin, ymax]. they range [0,1].
|
|
||||||
const viewport_plotarea = zeros(4)
|
|
||||||
|
|
||||||
# the size of the current plot in pixels
|
|
||||||
const gr_plot_size = [600.0, 400.0]
|
|
||||||
|
|
||||||
function gr_viewport_from_bbox(sp::Subplot{GRBackend}, bb::BoundingBox, w, h, viewport_canvas)
|
function gr_viewport_from_bbox(sp::Subplot{GRBackend}, bb::BoundingBox, w, h, viewport_canvas)
|
||||||
viewport = zeros(4)
|
viewport = zeros(4)
|
||||||
viewport[1] = viewport_canvas[2] * (left(bb) / w)
|
viewport[1] = viewport_canvas[2] * (left(bb) / w)
|
||||||
@ -434,7 +429,7 @@ function gr_viewport_from_bbox(sp::Subplot{GRBackend}, bb::BoundingBox, w, h, vi
|
|||||||
end
|
end
|
||||||
|
|
||||||
# change so we're focused on the viewport area
|
# change so we're focused on the viewport area
|
||||||
function gr_set_viewport_cmap(sp::Subplot)
|
function gr_set_viewport_cmap(sp::Subplot, viewport_plotarea)
|
||||||
GR.setviewport(
|
GR.setviewport(
|
||||||
viewport_plotarea[2] + (RecipesPipeline.is3d(sp) ? 0.07 : 0.02),
|
viewport_plotarea[2] + (RecipesPipeline.is3d(sp) ? 0.07 : 0.02),
|
||||||
viewport_plotarea[2] + (RecipesPipeline.is3d(sp) ? 0.10 : 0.05),
|
viewport_plotarea[2] + (RecipesPipeline.is3d(sp) ? 0.10 : 0.05),
|
||||||
@ -443,17 +438,7 @@ function gr_set_viewport_cmap(sp::Subplot)
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
# reset the viewport to the plot area
|
function gr_set_viewport_polar(viewport_plotarea)
|
||||||
function gr_set_viewport_plotarea()
|
|
||||||
GR.setviewport(
|
|
||||||
viewport_plotarea[1],
|
|
||||||
viewport_plotarea[2],
|
|
||||||
viewport_plotarea[3],
|
|
||||||
viewport_plotarea[4]
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
function gr_set_viewport_polar()
|
|
||||||
xmin, xmax, ymin, ymax = viewport_plotarea
|
xmin, xmax, ymin, ymax = viewport_plotarea
|
||||||
ymax -= 0.05 * (xmax - xmin)
|
ymax -= 0.05 * (xmax - xmin)
|
||||||
xcenter = 0.5 * (xmin + xmax)
|
xcenter = 0.5 * (xmin + xmax)
|
||||||
@ -518,11 +503,11 @@ function _cbar_unique(values, propname)
|
|||||||
end
|
end
|
||||||
|
|
||||||
# add the colorbar
|
# add the colorbar
|
||||||
function gr_draw_colorbar(cbar::GRColorbar, sp::Subplot, clims)
|
function gr_draw_colorbar(cbar::GRColorbar, sp::Subplot, clims, viewport_plotarea)
|
||||||
GR.savestate()
|
GR.savestate()
|
||||||
xmin, xmax = gr_xy_axislims(sp)[1:2]
|
xmin, xmax = gr_xy_axislims(sp)[1:2]
|
||||||
zmin, zmax = clims[1:2]
|
zmin, zmax = clims[1:2]
|
||||||
gr_set_viewport_cmap(sp)
|
gr_set_viewport_cmap(sp, viewport_plotarea)
|
||||||
GR.setscale(0)
|
GR.setscale(0)
|
||||||
GR.setwindow(xmin, xmax, zmin, zmax)
|
GR.setwindow(xmin, xmax, zmin, zmax)
|
||||||
if !isempty(cbar.gradients)
|
if !isempty(cbar.gradients)
|
||||||
@ -555,9 +540,12 @@ function gr_draw_colorbar(cbar::GRColorbar, sp::Subplot, clims)
|
|||||||
if !isempty(cbar.lines)
|
if !isempty(cbar.lines)
|
||||||
series = cbar.lines
|
series = cbar.lines
|
||||||
gr_set_gradient(_cbar_unique(get_colorgradient.(series),"color"))
|
gr_set_gradient(_cbar_unique(get_colorgradient.(series),"color"))
|
||||||
gr_set_line(_cbar_unique(get_linewidth.(series), "line width"),
|
gr_set_line(
|
||||||
_cbar_unique(get_linestyle.(series), "line style"),
|
_cbar_unique(get_linewidth.(series), "line width"),
|
||||||
_cbar_unique(get_linecolor.(series, Ref(clims)), "line color"))
|
_cbar_unique(get_linestyle.(series), "line style"),
|
||||||
|
_cbar_unique(get_linecolor.(series, Ref(clims)), "line color"),
|
||||||
|
sp,
|
||||||
|
)
|
||||||
gr_set_transparency(_cbar_unique(get_linealpha.(series), "line alpha"))
|
gr_set_transparency(_cbar_unique(get_linealpha.(series), "line alpha"))
|
||||||
levels = _cbar_unique(contour_levels.(series, Ref(clims)), "levels")
|
levels = _cbar_unique(contour_levels.(series, Ref(clims)), "levels")
|
||||||
colors = gr_colorbar_colors(last(series), clims)
|
colors = gr_colorbar_colors(last(series), clims)
|
||||||
@ -568,24 +556,25 @@ function gr_draw_colorbar(cbar::GRColorbar, sp::Subplot, clims)
|
|||||||
end
|
end
|
||||||
|
|
||||||
ztick = 0.5 * GR.tick(zmin, zmax)
|
ztick = 0.5 * GR.tick(zmin, zmax)
|
||||||
gr_set_line(1, :solid, plot_color(:black))
|
gr_set_line(1, :solid, plot_color(:black), sp)
|
||||||
GR.axes(0, ztick, xmax, zmin, 0, 1, 0.005)
|
GR.axes(0, ztick, xmax, zmin, 0, 1, 0.005)
|
||||||
|
|
||||||
gr_set_font(guidefont(sp[:yaxis]))
|
gr_set_font(guidefont(sp[:yaxis]), sp)
|
||||||
GR.settextalign(GR.TEXT_HALIGN_CENTER, GR.TEXT_VALIGN_TOP)
|
GR.settextalign(GR.TEXT_HALIGN_CENTER, GR.TEXT_VALIGN_TOP)
|
||||||
GR.setcharup(-1, 0)
|
GR.setcharup(-1, 0)
|
||||||
gr_text(viewport_plotarea[2] + 0.1,
|
gr_text(
|
||||||
gr_view_ycenter(), sp[:colorbar_title])
|
viewport_plotarea[2] + 0.1, gr_view_ycenter(viewport_plotarea), sp[:colorbar_title]
|
||||||
|
)
|
||||||
|
|
||||||
GR.restorestate()
|
GR.restorestate()
|
||||||
end
|
end
|
||||||
|
|
||||||
gr_view_xcenter() = 0.5 * (viewport_plotarea[1] + viewport_plotarea[2])
|
gr_view_xcenter(viewport_plotarea) = 0.5 * (viewport_plotarea[1] + viewport_plotarea[2])
|
||||||
gr_view_ycenter() = 0.5 * (viewport_plotarea[3] + viewport_plotarea[4])
|
gr_view_ycenter(viewport_plotarea) = 0.5 * (viewport_plotarea[3] + viewport_plotarea[4])
|
||||||
|
|
||||||
function gr_legend_pos(sp::Subplot, w, h)
|
function gr_legend_pos(sp::Subplot, w, h, viewport_plotarea)
|
||||||
s = sp[:legend]
|
s = sp[:legend]
|
||||||
typeof(s) <: Symbol || return gr_legend_pos(s, w, h)
|
typeof(s) <: Symbol || return gr_legend_pos(s, w, h, viewport_plotarea)
|
||||||
str = string(s)
|
str = string(s)
|
||||||
if str == "best"
|
if str == "best"
|
||||||
str = "topright"
|
str = "topright"
|
||||||
@ -629,7 +618,7 @@ function gr_legend_pos(sp::Subplot, w, h)
|
|||||||
(xpos,ypos)
|
(xpos,ypos)
|
||||||
end
|
end
|
||||||
|
|
||||||
function gr_legend_pos(v::Tuple{S,T},w,h) where {S<:Real, T<:Real}
|
function gr_legend_pos(v::Tuple{S,T}, w, h, viewport_plotarea) where {S<:Real, T<:Real}
|
||||||
xpos = v[1] * (viewport_plotarea[2] - viewport_plotarea[1]) + viewport_plotarea[1]
|
xpos = v[1] * (viewport_plotarea[2] - viewport_plotarea[1]) + viewport_plotarea[1]
|
||||||
ypos = v[2] * (viewport_plotarea[4] - viewport_plotarea[3]) + viewport_plotarea[3]
|
ypos = v[2] * (viewport_plotarea[4] - viewport_plotarea[3]) + viewport_plotarea[3]
|
||||||
(xpos,ypos)
|
(xpos,ypos)
|
||||||
@ -655,7 +644,6 @@ end
|
|||||||
function gr_display(plt::Plot, fmt="")
|
function gr_display(plt::Plot, fmt="")
|
||||||
GR.clearws()
|
GR.clearws()
|
||||||
|
|
||||||
_gr_thickness_scaling[1] = plt[:thickness_scaling]
|
|
||||||
dpi_factor = plt[:dpi] / Plots.DPI
|
dpi_factor = plt[:dpi] / Plots.DPI
|
||||||
if fmt == "svg"
|
if fmt == "svg"
|
||||||
dpi_factor *= 4
|
dpi_factor *= 4
|
||||||
@ -668,8 +656,7 @@ function gr_display(plt::Plot, fmt="")
|
|||||||
|
|
||||||
# compute the viewport_canvas, normalized to the larger dimension
|
# compute the viewport_canvas, normalized to the larger dimension
|
||||||
viewport_canvas = Float64[0,1,0,1]
|
viewport_canvas = Float64[0,1,0,1]
|
||||||
w, h = plt[:size]
|
w, h = get_size(plt)
|
||||||
gr_plot_size[:] = [w, h]
|
|
||||||
if w > h
|
if w > h
|
||||||
ratio = float(h) / w
|
ratio = float(h) / w
|
||||||
msize = display_width_ratio * w * dpi_factor
|
msize = display_width_ratio * w * dpi_factor
|
||||||
@ -689,10 +676,6 @@ function gr_display(plt::Plot, fmt="")
|
|||||||
# fill in the viewport_canvas background
|
# fill in the viewport_canvas background
|
||||||
gr_fill_viewport(viewport_canvas, plt[:background_color_outside])
|
gr_fill_viewport(viewport_canvas, plt[:background_color_outside])
|
||||||
|
|
||||||
# update point mult
|
|
||||||
px_per_pt = px / pt
|
|
||||||
_gr_point_mult[1] = 1.5 * _gr_thickness_scaling[1] * px_per_pt / max(h,w)
|
|
||||||
|
|
||||||
# subplots:
|
# subplots:
|
||||||
for sp in plt.subplots
|
for sp in plt.subplots
|
||||||
gr_display(sp, w*px, h*px, viewport_canvas)
|
gr_display(sp, w*px, h*px, viewport_canvas)
|
||||||
@ -705,10 +688,13 @@ end
|
|||||||
function gr_set_xticks_font(sp)
|
function gr_set_xticks_font(sp)
|
||||||
flip = sp[:yaxis][:flip]
|
flip = sp[:yaxis][:flip]
|
||||||
mirror = sp[:xaxis][:mirror]
|
mirror = sp[:xaxis][:mirror]
|
||||||
gr_set_font(tickfont(sp[:xaxis]),
|
gr_set_font(
|
||||||
halign = (:left, :hcenter, :right)[sign(sp[:xaxis][:rotation]) + 2],
|
tickfont(sp[:xaxis]),
|
||||||
valign = (mirror ? :bottom : :top),
|
sp,
|
||||||
rotation = sp[:xaxis][:rotation])
|
halign = (:left, :hcenter, :right)[sign(sp[:xaxis][:rotation]) + 2],
|
||||||
|
valign = (mirror ? :bottom : :top),
|
||||||
|
rotation = sp[:xaxis][:rotation],
|
||||||
|
)
|
||||||
return flip, mirror
|
return flip, mirror
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -716,10 +702,13 @@ end
|
|||||||
function gr_set_yticks_font(sp)
|
function gr_set_yticks_font(sp)
|
||||||
flip = sp[:xaxis][:flip]
|
flip = sp[:xaxis][:flip]
|
||||||
mirror = sp[:yaxis][:mirror]
|
mirror = sp[:yaxis][:mirror]
|
||||||
gr_set_font(tickfont(sp[:yaxis]),
|
gr_set_font(
|
||||||
halign = (mirror ? :left : :right),
|
tickfont(sp[:yaxis]),
|
||||||
valign = (:top, :vcenter, :bottom)[sign(sp[:yaxis][:rotation]) + 2],
|
sp,
|
||||||
rotation = sp[:yaxis][:rotation])
|
halign = (mirror ? :left : :right),
|
||||||
|
valign = (:top, :vcenter, :bottom)[sign(sp[:yaxis][:rotation]) + 2],
|
||||||
|
rotation = sp[:yaxis][:rotation],
|
||||||
|
)
|
||||||
return flip, mirror
|
return flip, mirror
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -774,24 +763,28 @@ function gr_convert_sci_tick_label(label)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function gr_axis_height(sp, axis)
|
function gr_axis_height(sp, axis)
|
||||||
|
GR.savestate()
|
||||||
ticks = get_ticks(sp, axis)
|
ticks = get_ticks(sp, axis)
|
||||||
gr_set_font(tickfont(axis))
|
gr_set_font(tickfont(axis), sp)
|
||||||
h = (ticks in (nothing, false, :none) ? 0 : last(gr_get_ticks_size(ticks, axis[:rotation])))
|
h = (ticks in (nothing, false, :none) ? 0 : last(gr_get_ticks_size(ticks, axis[:rotation])))
|
||||||
if axis[:guide] != ""
|
if axis[:guide] != ""
|
||||||
gr_set_font(guidefont(axis))
|
gr_set_font(guidefont(axis), sp)
|
||||||
h += last(gr_text_size(axis[:guide]))
|
h += last(gr_text_size(axis[:guide]))
|
||||||
end
|
end
|
||||||
|
GR.restorestate()
|
||||||
return h
|
return h
|
||||||
end
|
end
|
||||||
|
|
||||||
function gr_axis_width(sp, axis)
|
function gr_axis_width(sp, axis)
|
||||||
|
GR.savestate()
|
||||||
ticks = get_ticks(sp, axis)
|
ticks = get_ticks(sp, axis)
|
||||||
gr_set_font(tickfont(axis))
|
gr_set_font(tickfont(axis), sp)
|
||||||
w = (ticks in (nothing, false, :none) ? 0 : first(gr_get_ticks_size(ticks, axis[:rotation])))
|
w = (ticks in (nothing, false, :none) ? 0 : first(gr_get_ticks_size(ticks, axis[:rotation])))
|
||||||
if axis[:guide] != ""
|
if axis[:guide] != ""
|
||||||
gr_set_font(guidefont(axis))
|
gr_set_font(guidefont(axis), sp)
|
||||||
w += last(gr_text_size(axis[:guide]))
|
w += last(gr_text_size(axis[:guide]))
|
||||||
end
|
end
|
||||||
|
GR.restorestate()
|
||||||
return w
|
return w
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -810,9 +803,9 @@ function _update_min_padding!(sp::Subplot{GRBackend})
|
|||||||
bottompad = 2mm + sp[:bottom_margin]
|
bottompad = 2mm + sp[:bottom_margin]
|
||||||
# Add margin for title
|
# Add margin for title
|
||||||
if sp[:title] != ""
|
if sp[:title] != ""
|
||||||
gr_set_font(titlefont(sp))
|
gr_set_font(titlefont(sp), sp)
|
||||||
l = last(last(gr_text_size(sp[:title])))
|
l = last(last(gr_text_size(sp[:title])))
|
||||||
h = 1mm + gr_plot_size[2] * l * px
|
h = 1mm + get_size(sp)[2] * l * px
|
||||||
toppad += h
|
toppad += h
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -826,20 +819,22 @@ function _update_min_padding!(sp::Subplot{GRBackend})
|
|||||||
tickfont(xaxis),
|
tickfont(xaxis),
|
||||||
halign = (:left, :hcenter, :right)[sign(xaxis[:rotation]) + 2],
|
halign = (:left, :hcenter, :right)[sign(xaxis[:rotation]) + 2],
|
||||||
valign = (xaxis[:mirror] ? :bottom : :top),
|
valign = (xaxis[:mirror] ? :bottom : :top),
|
||||||
rotation = xaxis[:rotation]
|
rotation = xaxis[:rotation],
|
||||||
|
sp
|
||||||
)
|
)
|
||||||
l = 0.01 + last(gr_get_ticks_size(xticks, xaxis[:rotation]))
|
l = 0.01 + last(gr_get_ticks_size(xticks, xaxis[:rotation]))
|
||||||
h = max(h, 1mm + gr_plot_size[2] * l * px)
|
h = max(h, 1mm + get_size(sp)[2] * l * px)
|
||||||
end
|
end
|
||||||
if !(yticks in (nothing, false, :none))
|
if !(yticks in (nothing, false, :none))
|
||||||
gr_set_font(
|
gr_set_font(
|
||||||
tickfont(yaxis),
|
tickfont(yaxis),
|
||||||
halign = (:left, :hcenter, :right)[sign(yaxis[:rotation]) + 2],
|
halign = (:left, :hcenter, :right)[sign(yaxis[:rotation]) + 2],
|
||||||
valign = (yaxis[:mirror] ? :bottom : :top),
|
valign = (yaxis[:mirror] ? :bottom : :top),
|
||||||
rotation = yaxis[:rotation]
|
rotation = yaxis[:rotation],
|
||||||
|
sp
|
||||||
)
|
)
|
||||||
l = 0.01 + last(gr_get_ticks_size(yticks, yaxis[:rotation]))
|
l = 0.01 + last(gr_get_ticks_size(yticks, yaxis[:rotation]))
|
||||||
h = max(h, 1mm + gr_plot_size[2] * l * px)
|
h = max(h, 1mm + get_size(sp)[2] * l * px)
|
||||||
end
|
end
|
||||||
if h > 0mm
|
if h > 0mm
|
||||||
if xaxis[:mirror] || yaxis[:mirror]
|
if xaxis[:mirror] || yaxis[:mirror]
|
||||||
@ -857,9 +852,10 @@ function _update_min_padding!(sp::Subplot{GRBackend})
|
|||||||
valign = (:top, :vcenter, :bottom)[sign(zaxis[:rotation]) + 2],
|
valign = (:top, :vcenter, :bottom)[sign(zaxis[:rotation]) + 2],
|
||||||
rotation = zaxis[:rotation],
|
rotation = zaxis[:rotation],
|
||||||
color = zaxis[:tickfontcolor],
|
color = zaxis[:tickfontcolor],
|
||||||
|
sp
|
||||||
)
|
)
|
||||||
l = 0.01 + first(gr_get_ticks_size(zticks, zaxis[:rotation]))
|
l = 0.01 + first(gr_get_ticks_size(zticks, zaxis[:rotation]))
|
||||||
w = 1mm + gr_plot_size[1] * l * px
|
w = 1mm + get_size(sp)[1] * l * px
|
||||||
if zaxis[:mirror]
|
if zaxis[:mirror]
|
||||||
rightpad += w
|
rightpad += w
|
||||||
else
|
else
|
||||||
@ -870,14 +866,14 @@ function _update_min_padding!(sp::Subplot{GRBackend})
|
|||||||
# Add margin for x or y label
|
# Add margin for x or y label
|
||||||
h = 0mm
|
h = 0mm
|
||||||
if xaxis[:guide] != ""
|
if xaxis[:guide] != ""
|
||||||
gr_set_font(guidefont(sp[:xaxis]))
|
gr_set_font(guidefont(sp[:xaxis]), sp)
|
||||||
l = last(gr_text_size(sp[:xaxis][:guide]))
|
l = last(gr_text_size(sp[:xaxis][:guide]))
|
||||||
h = max(h, 1mm + gr_plot_size[2] * l * px)
|
h = max(h, 1mm + get_size(sp)[2] * l * px)
|
||||||
end
|
end
|
||||||
if yaxis[:guide] != ""
|
if yaxis[:guide] != ""
|
||||||
gr_set_font(guidefont(sp[:yaxis]))
|
gr_set_font(guidefont(sp[:yaxis]), sp)
|
||||||
l = last(gr_text_size(sp[:yaxis][:guide]))
|
l = last(gr_text_size(sp[:yaxis][:guide]))
|
||||||
h = max(h, 1mm + gr_plot_size[2] * l * px)
|
h = max(h, 1mm + get_size(sp)[2] * l * px)
|
||||||
end
|
end
|
||||||
if h > 0mm
|
if h > 0mm
|
||||||
if xaxis[:guide_position] == :top || (xaxis[:guide_position] == :auto && xaxis[:mirror] == true)
|
if xaxis[:guide_position] == :top || (xaxis[:guide_position] == :auto && xaxis[:mirror] == true)
|
||||||
@ -888,9 +884,9 @@ function _update_min_padding!(sp::Subplot{GRBackend})
|
|||||||
end
|
end
|
||||||
# Add margin for z label
|
# Add margin for z label
|
||||||
if zaxis[:guide] != ""
|
if zaxis[:guide] != ""
|
||||||
gr_set_font(guidefont(sp[:zaxis]))
|
gr_set_font(guidefont(sp[:zaxis]), sp)
|
||||||
l = last(gr_text_size(sp[:zaxis][:guide]))
|
l = last(gr_text_size(sp[:zaxis][:guide]))
|
||||||
w = 1mm + gr_plot_size[2] * l * px
|
w = 1mm + get_size(sp)[2] * l * px
|
||||||
if zaxis[:guide_position] == :right || (zaxis[:guide_position] == :auto && zaxis[:mirror] == true)
|
if zaxis[:guide_position] == :right || (zaxis[:guide_position] == :auto && zaxis[:mirror] == true)
|
||||||
rightpad += w
|
rightpad += w
|
||||||
else
|
else
|
||||||
@ -903,7 +899,7 @@ function _update_min_padding!(sp::Subplot{GRBackend})
|
|||||||
if !(xticks in (nothing, false, :none))
|
if !(xticks in (nothing, false, :none))
|
||||||
flip, mirror = gr_set_xticks_font(sp)
|
flip, mirror = gr_set_xticks_font(sp)
|
||||||
l = 0.01 + last(gr_get_ticks_size(xticks, sp[:xaxis][:rotation]))
|
l = 0.01 + last(gr_get_ticks_size(xticks, sp[:xaxis][:rotation]))
|
||||||
h = 1mm + gr_plot_size[2] * l * px
|
h = 1mm + get_size(sp)[2] * l * px
|
||||||
if mirror
|
if mirror
|
||||||
toppad += h
|
toppad += h
|
||||||
else
|
else
|
||||||
@ -913,7 +909,7 @@ function _update_min_padding!(sp::Subplot{GRBackend})
|
|||||||
if !(yticks in (nothing, false, :none))
|
if !(yticks in (nothing, false, :none))
|
||||||
flip, mirror = gr_set_yticks_font(sp)
|
flip, mirror = gr_set_yticks_font(sp)
|
||||||
l = 0.01 + first(gr_get_ticks_size(yticks, sp[:yaxis][:rotation]))
|
l = 0.01 + first(gr_get_ticks_size(yticks, sp[:yaxis][:rotation]))
|
||||||
w = 1mm + gr_plot_size[1] * l * px
|
w = 1mm + get_size(sp)[1] * l * px
|
||||||
if mirror
|
if mirror
|
||||||
rightpad += w
|
rightpad += w
|
||||||
else
|
else
|
||||||
@ -923,9 +919,9 @@ function _update_min_padding!(sp::Subplot{GRBackend})
|
|||||||
|
|
||||||
# Add margin for x label
|
# Add margin for x label
|
||||||
if sp[:xaxis][:guide] != ""
|
if sp[:xaxis][:guide] != ""
|
||||||
gr_set_font(guidefont(sp[:xaxis]))
|
gr_set_font(guidefont(sp[:xaxis]), sp)
|
||||||
l = last(gr_text_size(sp[:xaxis][:guide]))
|
l = last(gr_text_size(sp[:xaxis][:guide]))
|
||||||
h = 1mm + gr_plot_size[2] * l * px
|
h = 1mm + get_size(sp)[2] * l * px
|
||||||
if sp[:xaxis][:guide_position] == :top || (sp[:xaxis][:guide_position] == :auto && sp[:xaxis][:mirror] == true)
|
if sp[:xaxis][:guide_position] == :top || (sp[:xaxis][:guide_position] == :auto && sp[:xaxis][:mirror] == true)
|
||||||
toppad += h
|
toppad += h
|
||||||
else
|
else
|
||||||
@ -934,9 +930,9 @@ function _update_min_padding!(sp::Subplot{GRBackend})
|
|||||||
end
|
end
|
||||||
# Add margin for y label
|
# Add margin for y label
|
||||||
if sp[:yaxis][:guide] != ""
|
if sp[:yaxis][:guide] != ""
|
||||||
gr_set_font(guidefont(sp[:yaxis]))
|
gr_set_font(guidefont(sp[:yaxis]), sp)
|
||||||
l = last(gr_text_size(sp[:yaxis][:guide]))
|
l = last(gr_text_size(sp[:yaxis][:guide]))
|
||||||
w = 1mm + gr_plot_size[2] * l * px
|
w = 1mm + get_size(sp)[2] * l * px
|
||||||
if sp[:yaxis][:guide_position] == :right || (sp[:yaxis][:guide_position] == :auto && sp[:yaxis][:mirror] == true)
|
if sp[:yaxis][:guide_position] == :right || (sp[:yaxis][:guide_position] == :auto && sp[:yaxis][:mirror] == true)
|
||||||
rightpad += w
|
rightpad += w
|
||||||
else
|
else
|
||||||
@ -960,7 +956,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
|
|
||||||
# the viewports for this subplot
|
# the viewports for this subplot
|
||||||
viewport_subplot = gr_viewport_from_bbox(sp, bbox(sp), w, h, viewport_canvas)
|
viewport_subplot = gr_viewport_from_bbox(sp, bbox(sp), w, h, viewport_canvas)
|
||||||
viewport_plotarea[:] = gr_viewport_from_bbox(sp, plotarea(sp), w, h, viewport_canvas)
|
viewport_plotarea = gr_viewport_from_bbox(sp, plotarea(sp), w, h, viewport_canvas)
|
||||||
# get data limits
|
# get data limits
|
||||||
data_lims = gr_xy_axislims(sp)
|
data_lims = gr_xy_axislims(sp)
|
||||||
xy_lims = data_lims
|
xy_lims = data_lims
|
||||||
@ -994,12 +990,12 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
GR.selntran(0)
|
GR.selntran(0)
|
||||||
GR.setscale(0)
|
GR.setscale(0)
|
||||||
if sp[:legendtitle] !== nothing
|
if sp[:legendtitle] !== nothing
|
||||||
gr_set_font(legendtitlefont(sp))
|
gr_set_font(legendtitlefont(sp), sp)
|
||||||
tbx, tby = gr_inqtext(0, 0, string(sp[:legendtitle]))
|
tbx, tby = gr_inqtext(0, 0, string(sp[:legendtitle]))
|
||||||
legendw = tbx[3] - tbx[1]
|
legendw = tbx[3] - tbx[1]
|
||||||
legendn += 1
|
legendn += 1
|
||||||
end
|
end
|
||||||
gr_set_font(legendfont(sp))
|
gr_set_font(legendfont(sp), sp)
|
||||||
for series in series_list(sp)
|
for series in series_list(sp)
|
||||||
should_add_to_legend(series) || continue
|
should_add_to_legend(series) || continue
|
||||||
legendn += 1
|
legendn += 1
|
||||||
@ -1013,7 +1009,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
GR.restorestate()
|
GR.restorestate()
|
||||||
end
|
end
|
||||||
|
|
||||||
dy = _gr_point_mult[1] * sp[:legendfontsize] * 1.75
|
dy = gr_point_mult(sp) * sp[:legendfontsize] * 1.75
|
||||||
legendh = dy * legendn
|
legendh = dy * legendn
|
||||||
leg_str = string(sp[:legend])
|
leg_str = string(sp[:legend])
|
||||||
if occursin("outer", leg_str)
|
if occursin("outer", leg_str)
|
||||||
@ -1061,7 +1057,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
end
|
end
|
||||||
|
|
||||||
# set our plot area view
|
# set our plot area view
|
||||||
gr_set_viewport_plotarea()
|
GR.setviewport(viewport_plotarea...)
|
||||||
|
|
||||||
# these are the Axis objects, which hold scale, lims, etc
|
# these are the Axis objects, which hold scale, lims, etc
|
||||||
xaxis = sp[:xaxis]
|
xaxis = sp[:xaxis]
|
||||||
@ -1102,7 +1098,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
end
|
end
|
||||||
|
|
||||||
# draw the axes
|
# draw the axes
|
||||||
gr_set_font(tickfont(xaxis))
|
gr_set_font(tickfont(xaxis), sp)
|
||||||
GR.setlinewidth(sp.plt[:thickness_scaling])
|
GR.setlinewidth(sp.plt[:thickness_scaling])
|
||||||
|
|
||||||
if RecipesPipeline.is3d(sp)
|
if RecipesPipeline.is3d(sp)
|
||||||
@ -1121,33 +1117,63 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
|
|
||||||
# draw the grid lines
|
# draw the grid lines
|
||||||
if xaxis[:grid]
|
if xaxis[:grid]
|
||||||
gr_set_line(xaxis[:gridlinewidth], xaxis[:gridstyle], xaxis[:foreground_color_grid])
|
gr_set_line(
|
||||||
|
xaxis[:gridlinewidth],
|
||||||
|
xaxis[:gridstyle],
|
||||||
|
xaxis[:foreground_color_grid],
|
||||||
|
sp
|
||||||
|
)
|
||||||
gr_set_transparency(xaxis[:foreground_color_grid], xaxis[:gridalpha])
|
gr_set_transparency(xaxis[:foreground_color_grid], xaxis[:gridalpha])
|
||||||
gr_polyline3d(coords(xgrid_segs)...)
|
gr_polyline3d(coords(xgrid_segs)...)
|
||||||
end
|
end
|
||||||
if yaxis[:grid]
|
if yaxis[:grid]
|
||||||
gr_set_line(yaxis[:gridlinewidth], yaxis[:gridstyle], yaxis[:foreground_color_grid])
|
gr_set_line(
|
||||||
|
yaxis[:gridlinewidth],
|
||||||
|
yaxis[:gridstyle],
|
||||||
|
yaxis[:foreground_color_grid],
|
||||||
|
sp
|
||||||
|
)
|
||||||
gr_set_transparency(yaxis[:foreground_color_grid], yaxis[:gridalpha])
|
gr_set_transparency(yaxis[:foreground_color_grid], yaxis[:gridalpha])
|
||||||
gr_polyline3d(coords(ygrid_segs)...)
|
gr_polyline3d(coords(ygrid_segs)...)
|
||||||
end
|
end
|
||||||
if zaxis[:grid]
|
if zaxis[:grid]
|
||||||
gr_set_line(zaxis[:gridlinewidth], zaxis[:gridstyle], zaxis[:foreground_color_grid])
|
gr_set_line(
|
||||||
|
zaxis[:gridlinewidth],
|
||||||
|
zaxis[:gridstyle],
|
||||||
|
zaxis[:foreground_color_grid],
|
||||||
|
sp
|
||||||
|
)
|
||||||
gr_set_transparency(zaxis[:foreground_color_grid], zaxis[:gridalpha])
|
gr_set_transparency(zaxis[:foreground_color_grid], zaxis[:gridalpha])
|
||||||
gr_polyline3d(coords(zgrid_segs)...)
|
gr_polyline3d(coords(zgrid_segs)...)
|
||||||
end
|
end
|
||||||
|
|
||||||
if xaxis[:minorgrid]
|
if xaxis[:minorgrid]
|
||||||
gr_set_line(xaxis[:minorgridlinewidth], xaxis[:minorgridstyle], xaxis[:foreground_color_minor_grid])
|
gr_set_line(
|
||||||
|
xaxis[:minorgridlinewidth],
|
||||||
|
xaxis[:minorgridstyle],
|
||||||
|
xaxis[:foreground_color_minor_grid],
|
||||||
|
sp
|
||||||
|
)
|
||||||
gr_set_transparency(xaxis[:foreground_color_minor_grid], xaxis[:minorgridalpha])
|
gr_set_transparency(xaxis[:foreground_color_minor_grid], xaxis[:minorgridalpha])
|
||||||
gr_polyline3d(coords(xminorgrid_segs)...)
|
gr_polyline3d(coords(xminorgrid_segs)...)
|
||||||
end
|
end
|
||||||
if yaxis[:minorgrid]
|
if yaxis[:minorgrid]
|
||||||
gr_set_line(yaxis[:minorgridlinewidth], yaxis[:minorgridstyle], yaxis[:foreground_color_minor_grid])
|
gr_set_line(
|
||||||
|
yaxis[:minorgridlinewidth],
|
||||||
|
yaxis[:minorgridstyle],
|
||||||
|
yaxis[:foreground_color_minor_grid],
|
||||||
|
sp
|
||||||
|
)
|
||||||
gr_set_transparency(yaxis[:foreground_color_minor_grid], yaxis[:minorgridalpha])
|
gr_set_transparency(yaxis[:foreground_color_minor_grid], yaxis[:minorgridalpha])
|
||||||
gr_polyline3d(coords(yminorgrid_segs)...)
|
gr_polyline3d(coords(yminorgrid_segs)...)
|
||||||
end
|
end
|
||||||
if zaxis[:minorgrid]
|
if zaxis[:minorgrid]
|
||||||
gr_set_line(zaxis[:minorgridlinewidth], zaxis[:minorgridstyle], zaxis[:foreground_color_minor_grid])
|
gr_set_line(
|
||||||
|
zaxis[:minorgridlinewidth],
|
||||||
|
zaxis[:minorgridstyle],
|
||||||
|
zaxis[:foreground_color_minor_grid],
|
||||||
|
sp
|
||||||
|
)
|
||||||
gr_set_transparency(zaxis[:foreground_color_minor_grid], zaxis[:minorgridalpha])
|
gr_set_transparency(zaxis[:foreground_color_minor_grid], zaxis[:minorgridalpha])
|
||||||
gr_polyline3d(coords(zminorgrid_segs)...)
|
gr_polyline3d(coords(zminorgrid_segs)...)
|
||||||
end
|
end
|
||||||
@ -1155,17 +1181,17 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
|
|
||||||
# axis lines
|
# axis lines
|
||||||
if xaxis[:showaxis]
|
if xaxis[:showaxis]
|
||||||
gr_set_line(1, :solid, xaxis[:foreground_color_border])
|
gr_set_line(1, :solid, xaxis[:foreground_color_border], sp)
|
||||||
GR.setclip(0)
|
GR.setclip(0)
|
||||||
gr_polyline3d(coords(xaxis_segs)...)
|
gr_polyline3d(coords(xaxis_segs)...)
|
||||||
end
|
end
|
||||||
if yaxis[:showaxis]
|
if yaxis[:showaxis]
|
||||||
gr_set_line(1, :solid, yaxis[:foreground_color_border])
|
gr_set_line(1, :solid, yaxis[:foreground_color_border], sp)
|
||||||
GR.setclip(0)
|
GR.setclip(0)
|
||||||
gr_polyline3d(coords(yaxis_segs)...)
|
gr_polyline3d(coords(yaxis_segs)...)
|
||||||
end
|
end
|
||||||
if zaxis[:showaxis]
|
if zaxis[:showaxis]
|
||||||
gr_set_line(1, :solid, zaxis[:foreground_color_border])
|
gr_set_line(1, :solid, zaxis[:foreground_color_border], sp)
|
||||||
GR.setclip(0)
|
GR.setclip(0)
|
||||||
gr_polyline3d(coords(zaxis_segs)...)
|
gr_polyline3d(coords(zaxis_segs)...)
|
||||||
end
|
end
|
||||||
@ -1174,30 +1200,39 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
# axis ticks
|
# axis ticks
|
||||||
if xaxis[:showaxis]
|
if xaxis[:showaxis]
|
||||||
if sp[:framestyle] in (:zerolines, :grid)
|
if sp[:framestyle] in (:zerolines, :grid)
|
||||||
gr_set_line(1, :solid, xaxis[:foreground_color_grid])
|
gr_set_line(1, :solid, xaxis[:foreground_color_grid], sp)
|
||||||
gr_set_transparency(xaxis[:foreground_color_grid], xaxis[:tick_direction] == :out ? xaxis[:gridalpha] : 0)
|
gr_set_transparency(
|
||||||
|
xaxis[:foreground_color_grid],
|
||||||
|
xaxis[:tick_direction] == :out ? xaxis[:gridalpha] : 0
|
||||||
|
)
|
||||||
else
|
else
|
||||||
gr_set_line(1, :solid, xaxis[:foreground_color_axis])
|
gr_set_line(1, :solid, xaxis[:foreground_color_axis], sp)
|
||||||
end
|
end
|
||||||
GR.setclip(0)
|
GR.setclip(0)
|
||||||
gr_polyline3d(coords(xtick_segs)...)
|
gr_polyline3d(coords(xtick_segs)...)
|
||||||
end
|
end
|
||||||
if yaxis[:showaxis]
|
if yaxis[:showaxis]
|
||||||
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], sp)
|
||||||
gr_set_transparency(yaxis[:foreground_color_grid], yaxis[:tick_direction] == :out ? yaxis[:gridalpha] : 0)
|
gr_set_transparency(
|
||||||
|
yaxis[:foreground_color_grid],
|
||||||
|
yaxis[:tick_direction] == :out ? yaxis[:gridalpha] : 0
|
||||||
|
)
|
||||||
else
|
else
|
||||||
gr_set_line(1, :solid, yaxis[:foreground_color_axis])
|
gr_set_line(1, :solid, yaxis[:foreground_color_axis], sp)
|
||||||
end
|
end
|
||||||
GR.setclip(0)
|
GR.setclip(0)
|
||||||
gr_polyline3d(coords(ytick_segs)...)
|
gr_polyline3d(coords(ytick_segs)...)
|
||||||
end
|
end
|
||||||
if zaxis[:showaxis]
|
if zaxis[:showaxis]
|
||||||
if sp[:framestyle] in (:zerolines, :grid)
|
if sp[:framestyle] in (:zerolines, :grid)
|
||||||
gr_set_line(1, :solid, zaxis[:foreground_color_grid])
|
gr_set_line(1, :solid, zaxis[:foreground_color_grid], sp)
|
||||||
gr_set_transparency(zaxis[:foreground_color_grid], zaxis[:tick_direction] == :out ? zaxis[:gridalpha] : 0)
|
gr_set_transparency(
|
||||||
|
zaxis[:foreground_color_grid],
|
||||||
|
zaxis[:tick_direction] == :out ? zaxis[:gridalpha] : 0
|
||||||
|
)
|
||||||
else
|
else
|
||||||
gr_set_line(1, :solid, zaxis[:foreground_color_axis])
|
gr_set_line(1, :solid, zaxis[:foreground_color_axis], sp)
|
||||||
end
|
end
|
||||||
GR.setclip(0)
|
GR.setclip(0)
|
||||||
gr_polyline3d(coords(ztick_segs)...)
|
gr_polyline3d(coords(ztick_segs)...)
|
||||||
@ -1213,6 +1248,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
valign = (xaxis[:mirror] ? :bottom : :top),
|
valign = (xaxis[:mirror] ? :bottom : :top),
|
||||||
rotation = xaxis[:rotation],
|
rotation = xaxis[:rotation],
|
||||||
color = xaxis[:tickfontcolor],
|
color = xaxis[:tickfontcolor],
|
||||||
|
sp
|
||||||
)
|
)
|
||||||
yt = if sp[:framestyle] == :origin
|
yt = if sp[:framestyle] == :origin
|
||||||
0
|
0
|
||||||
@ -1244,6 +1280,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
valign = (yaxis[:mirror] ? :bottom : :top),
|
valign = (yaxis[:mirror] ? :bottom : :top),
|
||||||
rotation = yaxis[:rotation],
|
rotation = yaxis[:rotation],
|
||||||
color = yaxis[:tickfontcolor],
|
color = yaxis[:tickfontcolor],
|
||||||
|
sp
|
||||||
)
|
)
|
||||||
xt = if sp[:framestyle] == :origin
|
xt = if sp[:framestyle] == :origin
|
||||||
0
|
0
|
||||||
@ -1275,6 +1312,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
valign = (:top, :vcenter, :bottom)[sign(zaxis[:rotation]) + 2],
|
valign = (:top, :vcenter, :bottom)[sign(zaxis[:rotation]) + 2],
|
||||||
rotation = zaxis[:rotation],
|
rotation = zaxis[:rotation],
|
||||||
color = zaxis[:tickfontcolor],
|
color = zaxis[:tickfontcolor],
|
||||||
|
sp
|
||||||
)
|
)
|
||||||
xt = if sp[:framestyle] == :origin
|
xt = if sp[:framestyle] == :origin
|
||||||
0
|
0
|
||||||
@ -1300,16 +1338,16 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
# # border
|
# # border
|
||||||
# intensity = sp[:framestyle] == :semi ? 0.5 : 1.0
|
# intensity = sp[:framestyle] == :semi ? 0.5 : 1.0
|
||||||
# if sp[:framestyle] in (:box, :semi)
|
# if sp[:framestyle] in (:box, :semi)
|
||||||
# gr_set_line(intensity, :solid, xaxis[:foreground_color_border])
|
# gr_set_line(intensity, :solid, xaxis[:foreground_color_border], sp)
|
||||||
# gr_set_transparency(xaxis[:foreground_color_border], intensity)
|
# gr_set_transparency(xaxis[:foreground_color_border], intensity)
|
||||||
# gr_polyline3d(coords(xborder_segs)...)
|
# gr_polyline3d(coords(xborder_segs)...)
|
||||||
# gr_set_line(intensity, :solid, yaxis[:foreground_color_border])
|
# gr_set_line(intensity, :solid, yaxis[:foreground_color_border], sp)
|
||||||
# gr_set_transparency(yaxis[:foreground_color_border], intensity)
|
# gr_set_transparency(yaxis[:foreground_color_border], intensity)
|
||||||
# gr_polyline3d(coords(yborder_segs)...)
|
# gr_polyline3d(coords(yborder_segs)...)
|
||||||
# end
|
# end
|
||||||
|
|
||||||
elseif ispolar(sp)
|
elseif ispolar(sp)
|
||||||
r = gr_set_viewport_polar()
|
r = gr_set_viewport_polar(viewport_plotarea)
|
||||||
#rmin, rmax = GR.adjustrange(ignorenan_minimum(r), ignorenan_maximum(r))
|
#rmin, rmax = GR.adjustrange(ignorenan_minimum(r), ignorenan_maximum(r))
|
||||||
rmin, rmax = axis_limits(sp, :y)
|
rmin, rmax = axis_limits(sp, :y)
|
||||||
gr_polaraxes(rmin, rmax, sp)
|
gr_polaraxes(rmin, rmax, sp)
|
||||||
@ -1323,26 +1361,43 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
|
|
||||||
# draw the grid lines
|
# draw the grid lines
|
||||||
if xaxis[:grid]
|
if xaxis[:grid]
|
||||||
# gr_set_linecolor(sp[:foreground_color_grid])
|
|
||||||
# GR.grid(xtick, ytick, 0, 0, majorx, majory)
|
# GR.grid(xtick, ytick, 0, 0, majorx, majory)
|
||||||
gr_set_line(xaxis[:gridlinewidth], xaxis[:gridstyle], xaxis[:foreground_color_grid])
|
gr_set_line(
|
||||||
|
xaxis[:gridlinewidth],
|
||||||
|
xaxis[:gridstyle],
|
||||||
|
xaxis[:foreground_color_grid],
|
||||||
|
sp
|
||||||
|
)
|
||||||
gr_set_transparency(xaxis[:foreground_color_grid], xaxis[:gridalpha])
|
gr_set_transparency(xaxis[:foreground_color_grid], xaxis[:gridalpha])
|
||||||
gr_polyline(coords(xgrid_segs)...)
|
gr_polyline(coords(xgrid_segs)...)
|
||||||
end
|
end
|
||||||
if yaxis[:grid]
|
if yaxis[:grid]
|
||||||
gr_set_line(yaxis[:gridlinewidth], yaxis[:gridstyle], yaxis[:foreground_color_grid])
|
gr_set_line(
|
||||||
|
yaxis[:gridlinewidth],
|
||||||
|
yaxis[:gridstyle],
|
||||||
|
yaxis[:foreground_color_grid],
|
||||||
|
sp
|
||||||
|
)
|
||||||
gr_set_transparency(yaxis[:foreground_color_grid], yaxis[:gridalpha])
|
gr_set_transparency(yaxis[:foreground_color_grid], yaxis[:gridalpha])
|
||||||
gr_polyline(coords(ygrid_segs)...)
|
gr_polyline(coords(ygrid_segs)...)
|
||||||
end
|
end
|
||||||
if xaxis[:minorgrid]
|
if xaxis[:minorgrid]
|
||||||
# gr_set_linecolor(sp[:foreground_color_grid])
|
gr_set_line(
|
||||||
# GR.grid(xtick, ytick, 0, 0, majorx, majory)
|
xaxis[:minorgridlinewidth],
|
||||||
gr_set_line(xaxis[:minorgridlinewidth], xaxis[:minorgridstyle], xaxis[:foreground_color_minor_grid])
|
xaxis[:minorgridstyle],
|
||||||
|
xaxis[:foreground_color_minor_grid],
|
||||||
|
sp
|
||||||
|
)
|
||||||
gr_set_transparency(xaxis[:foreground_color_minor_grid], xaxis[:minorgridalpha])
|
gr_set_transparency(xaxis[:foreground_color_minor_grid], xaxis[:minorgridalpha])
|
||||||
gr_polyline(coords(xminorgrid_segs)...)
|
gr_polyline(coords(xminorgrid_segs)...)
|
||||||
end
|
end
|
||||||
if yaxis[:minorgrid]
|
if yaxis[:minorgrid]
|
||||||
gr_set_line(yaxis[:minorgridlinewidth], yaxis[:minorgridstyle], yaxis[:foreground_color_minor_grid])
|
gr_set_line(
|
||||||
|
yaxis[:minorgridlinewidth],
|
||||||
|
yaxis[:minorgridstyle],
|
||||||
|
yaxis[:foreground_color_minor_grid],
|
||||||
|
sp
|
||||||
|
)
|
||||||
gr_set_transparency(yaxis[:foreground_color_minor_grid], yaxis[:minorgridalpha])
|
gr_set_transparency(yaxis[:foreground_color_minor_grid], yaxis[:minorgridalpha])
|
||||||
gr_polyline(coords(yminorgrid_segs)...)
|
gr_polyline(coords(yminorgrid_segs)...)
|
||||||
end
|
end
|
||||||
@ -1350,12 +1405,12 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
|
|
||||||
# axis lines
|
# axis lines
|
||||||
if xaxis[:showaxis]
|
if xaxis[:showaxis]
|
||||||
gr_set_line(1, :solid, xaxis[:foreground_color_border])
|
gr_set_line(1, :solid, xaxis[:foreground_color_border], sp)
|
||||||
GR.setclip(0)
|
GR.setclip(0)
|
||||||
gr_polyline(coords(xspine_segs)...)
|
gr_polyline(coords(xspine_segs)...)
|
||||||
end
|
end
|
||||||
if yaxis[:showaxis]
|
if yaxis[:showaxis]
|
||||||
gr_set_line(1, :solid, yaxis[:foreground_color_border])
|
gr_set_line(1, :solid, yaxis[:foreground_color_border], sp)
|
||||||
GR.setclip(0)
|
GR.setclip(0)
|
||||||
gr_polyline(coords(yspine_segs)...)
|
gr_polyline(coords(yspine_segs)...)
|
||||||
end
|
end
|
||||||
@ -1364,20 +1419,26 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
# axis ticks
|
# axis ticks
|
||||||
if xaxis[:showaxis]
|
if xaxis[:showaxis]
|
||||||
if sp[:framestyle] in (:zerolines, :grid)
|
if sp[:framestyle] in (:zerolines, :grid)
|
||||||
gr_set_line(1, :solid, xaxis[:foreground_color_grid])
|
gr_set_line(1, :solid, xaxis[:foreground_color_grid], sp)
|
||||||
gr_set_transparency(xaxis[:foreground_color_grid], xaxis[:tick_direction] == :out ? xaxis[:gridalpha] : 0)
|
gr_set_transparency(
|
||||||
|
xaxis[:foreground_color_grid],
|
||||||
|
xaxis[:tick_direction] == :out ? xaxis[:gridalpha] : 0
|
||||||
|
)
|
||||||
else
|
else
|
||||||
gr_set_line(1, :solid, xaxis[:foreground_color_axis])
|
gr_set_line(1, :solid, xaxis[:foreground_color_axis], sp)
|
||||||
end
|
end
|
||||||
GR.setclip(0)
|
GR.setclip(0)
|
||||||
gr_polyline(coords(xtick_segs)...)
|
gr_polyline(coords(xtick_segs)...)
|
||||||
end
|
end
|
||||||
if yaxis[:showaxis]
|
if yaxis[:showaxis]
|
||||||
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], sp)
|
||||||
gr_set_transparency(yaxis[:foreground_color_grid], yaxis[:tick_direction] == :out ? yaxis[:gridalpha] : 0)
|
gr_set_transparency(
|
||||||
|
yaxis[:foreground_color_grid],
|
||||||
|
yaxis[:tick_direction] == :out ? yaxis[:gridalpha] : 0
|
||||||
|
)
|
||||||
else
|
else
|
||||||
gr_set_line(1, :solid, yaxis[:foreground_color_axis])
|
gr_set_line(1, :solid, yaxis[:foreground_color_axis], sp)
|
||||||
end
|
end
|
||||||
GR.setclip(0)
|
GR.setclip(0)
|
||||||
gr_polyline(coords(ytick_segs)...)
|
gr_polyline(coords(ytick_segs)...)
|
||||||
@ -1410,10 +1471,10 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
intensity = sp[:framestyle] == :semi ? 0.5 : 1
|
intensity = sp[:framestyle] == :semi ? 0.5 : 1
|
||||||
if sp[:framestyle] in (:box, :semi)
|
if sp[:framestyle] in (:box, :semi)
|
||||||
GR.setclip(0)
|
GR.setclip(0)
|
||||||
gr_set_line(intensity, :solid, xaxis[:foreground_color_border])
|
gr_set_line(intensity, :solid, xaxis[:foreground_color_border], sp)
|
||||||
gr_set_transparency(xaxis[:foreground_color_border], intensity)
|
gr_set_transparency(xaxis[:foreground_color_border], intensity)
|
||||||
gr_polyline(coords(xborder_segs)...)
|
gr_polyline(coords(xborder_segs)...)
|
||||||
gr_set_line(intensity, :solid, yaxis[:foreground_color_border])
|
gr_set_line(intensity, :solid, yaxis[:foreground_color_border], sp)
|
||||||
gr_set_transparency(yaxis[:foreground_color_border], intensity)
|
gr_set_transparency(yaxis[:foreground_color_border], intensity)
|
||||||
gr_polyline(coords(yborder_segs)...)
|
gr_polyline(coords(yborder_segs)...)
|
||||||
GR.setclip(1)
|
GR.setclip(1)
|
||||||
@ -1424,7 +1485,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
# add the guides
|
# add the guides
|
||||||
GR.savestate()
|
GR.savestate()
|
||||||
if sp[:title] != ""
|
if sp[:title] != ""
|
||||||
gr_set_font(titlefont(sp))
|
gr_set_font(titlefont(sp), sp)
|
||||||
loc = sp[:titlelocation]
|
loc = sp[:titlelocation]
|
||||||
if loc == :left
|
if loc == :left
|
||||||
xpos = viewport_plotarea[1]
|
xpos = viewport_plotarea[1]
|
||||||
@ -1433,7 +1494,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
xpos = viewport_plotarea[2]
|
xpos = viewport_plotarea[2]
|
||||||
halign = GR.TEXT_HALIGN_RIGHT
|
halign = GR.TEXT_HALIGN_RIGHT
|
||||||
else
|
else
|
||||||
xpos = gr_view_xcenter()
|
xpos = gr_view_xcenter(viewport_plotarea)
|
||||||
halign = GR.TEXT_HALIGN_CENTER
|
halign = GR.TEXT_HALIGN_CENTER
|
||||||
end
|
end
|
||||||
GR.settextalign(halign, GR.TEXT_VALIGN_TOP)
|
GR.settextalign(halign, GR.TEXT_VALIGN_TOP)
|
||||||
@ -1445,7 +1506,8 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
guidefont(xaxis),
|
guidefont(xaxis),
|
||||||
halign = (:left, :hcenter, :right)[sign(xaxis[:rotation]) + 2],
|
halign = (:left, :hcenter, :right)[sign(xaxis[:rotation]) + 2],
|
||||||
valign = (xaxis[:mirror] ? :bottom : :top),
|
valign = (xaxis[:mirror] ? :bottom : :top),
|
||||||
rotation = xaxis[:rotation]
|
rotation = xaxis[:rotation],
|
||||||
|
sp
|
||||||
)
|
)
|
||||||
yg = xor(xaxis[:mirror], yaxis[:flip]) ? ymax : ymin
|
yg = xor(xaxis[:mirror], yaxis[:flip]) ? ymax : ymin
|
||||||
zg = xor(xaxis[:mirror], zaxis[:flip]) ? zmax : zmin
|
zg = xor(xaxis[:mirror], zaxis[:flip]) ? zmax : zmin
|
||||||
@ -1460,7 +1522,8 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
guidefont(yaxis),
|
guidefont(yaxis),
|
||||||
halign = (:left, :hcenter, :right)[sign(yaxis[:rotation]) + 2],
|
halign = (:left, :hcenter, :right)[sign(yaxis[:rotation]) + 2],
|
||||||
valign = (yaxis[:mirror] ? :bottom : :top),
|
valign = (yaxis[:mirror] ? :bottom : :top),
|
||||||
rotation = yaxis[:rotation]
|
rotation = yaxis[:rotation],
|
||||||
|
sp
|
||||||
)
|
)
|
||||||
xg = xor(yaxis[:mirror], xaxis[:flip]) ? xmin : xmax
|
xg = xor(yaxis[:mirror], xaxis[:flip]) ? xmin : xmax
|
||||||
yg = (ymin + ymax) / 2
|
yg = (ymin + ymax) / 2
|
||||||
@ -1475,7 +1538,8 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
guidefont(zaxis),
|
guidefont(zaxis),
|
||||||
halign = (:left, :hcenter, :right)[sign(zaxis[:rotation]) + 2],
|
halign = (:left, :hcenter, :right)[sign(zaxis[:rotation]) + 2],
|
||||||
valign = (zaxis[:mirror] ? :bottom : :top),
|
valign = (zaxis[:mirror] ? :bottom : :top),
|
||||||
rotation = zaxis[:rotation]
|
rotation = zaxis[:rotation],
|
||||||
|
sp
|
||||||
)
|
)
|
||||||
xg = xor(zaxis[:mirror], xaxis[:flip]) ? xmax : xmin
|
xg = xor(zaxis[:mirror], xaxis[:flip]) ? xmax : xmin
|
||||||
yg = xor(zaxis[:mirror], yaxis[:flip]) ? ymax : ymin
|
yg = xor(zaxis[:mirror], yaxis[:flip]) ? ymax : ymin
|
||||||
@ -1488,32 +1552,32 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
else
|
else
|
||||||
if xaxis[:guide] != ""
|
if xaxis[:guide] != ""
|
||||||
h = 0.01 + gr_axis_height(sp, xaxis)
|
h = 0.01 + gr_axis_height(sp, xaxis)
|
||||||
gr_set_font(guidefont(xaxis))
|
gr_set_font(guidefont(xaxis), sp)
|
||||||
if xaxis[:guide_position] == :top || (xaxis[:guide_position] == :auto && xaxis[:mirror] == true)
|
if xaxis[:guide_position] == :top || (xaxis[:guide_position] == :auto && xaxis[:mirror] == true)
|
||||||
GR.settextalign(GR.TEXT_HALIGN_CENTER, GR.TEXT_VALIGN_TOP)
|
GR.settextalign(GR.TEXT_HALIGN_CENTER, GR.TEXT_VALIGN_TOP)
|
||||||
gr_text(gr_view_xcenter(), viewport_plotarea[4] + h, xaxis[:guide])
|
gr_text(gr_view_xcenter(viewport_plotarea), viewport_plotarea[4] + h, xaxis[:guide])
|
||||||
else
|
else
|
||||||
GR.settextalign(GR.TEXT_HALIGN_CENTER, GR.TEXT_VALIGN_BOTTOM)
|
GR.settextalign(GR.TEXT_HALIGN_CENTER, GR.TEXT_VALIGN_BOTTOM)
|
||||||
gr_text(gr_view_xcenter(), viewport_plotarea[3] - h, xaxis[:guide])
|
gr_text(gr_view_xcenter(viewport_plotarea), viewport_plotarea[3] - h, xaxis[:guide])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if yaxis[:guide] != ""
|
if yaxis[:guide] != ""
|
||||||
w = 0.02 + gr_axis_width(sp, yaxis)
|
w = 0.02 + gr_axis_width(sp, yaxis)
|
||||||
gr_set_font(guidefont(yaxis))
|
gr_set_font(guidefont(yaxis), sp)
|
||||||
GR.setcharup(-1, 0)
|
GR.setcharup(-1, 0)
|
||||||
if yaxis[:guide_position] == :right || (yaxis[:guide_position] == :auto && yaxis[:mirror] == true)
|
if yaxis[:guide_position] == :right || (yaxis[:guide_position] == :auto && yaxis[:mirror] == true)
|
||||||
GR.settextalign(GR.TEXT_HALIGN_CENTER, GR.TEXT_VALIGN_BOTTOM)
|
GR.settextalign(GR.TEXT_HALIGN_CENTER, GR.TEXT_VALIGN_BOTTOM)
|
||||||
gr_text(viewport_plotarea[2] + w, gr_view_ycenter(), yaxis[:guide])
|
gr_text(viewport_plotarea[2] + w, gr_view_ycenter(viewport_plotarea), yaxis[:guide])
|
||||||
else
|
else
|
||||||
GR.settextalign(GR.TEXT_HALIGN_CENTER, GR.TEXT_VALIGN_TOP)
|
GR.settextalign(GR.TEXT_HALIGN_CENTER, GR.TEXT_VALIGN_TOP)
|
||||||
gr_text(viewport_plotarea[1] - w, gr_view_ycenter(), yaxis[:guide])
|
gr_text(viewport_plotarea[1] - w, gr_view_ycenter(viewport_plotarea), yaxis[:guide])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
GR.restorestate()
|
GR.restorestate()
|
||||||
|
|
||||||
gr_set_font(tickfont(xaxis))
|
gr_set_font(tickfont(xaxis), sp)
|
||||||
|
|
||||||
# this needs to be here to point the colormap to the right indices
|
# this needs to be here to point the colormap to the right indices
|
||||||
GR.setcolormap(1000 + GR.COLORMAP_COOLWARM)
|
GR.setcolormap(1000 + GR.COLORMAP_COOLWARM)
|
||||||
@ -1528,7 +1592,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
|
|
||||||
# update the bounding window
|
# update the bounding window
|
||||||
if ispolar(sp)
|
if ispolar(sp)
|
||||||
gr_set_viewport_polar()
|
gr_set_viewport_polar(viewport_plotarea)
|
||||||
else
|
else
|
||||||
xmin, xmax, ymin, ymax = data_lims
|
xmin, xmax, ymin, ymax = data_lims
|
||||||
if xmax > xmin && ymax > ymin
|
if xmax > xmin && ymax > ymin
|
||||||
@ -1581,7 +1645,9 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
if st in (:path, :straightline)
|
if st in (:path, :straightline)
|
||||||
for (i, rng) in enumerate(segments)
|
for (i, rng) in enumerate(segments)
|
||||||
lc = get_linecolor(series, clims, i)
|
lc = get_linecolor(series, clims, i)
|
||||||
gr_set_line(get_linewidth(series, i), get_linestyle(series, i), lc) #, series[:linealpha])
|
gr_set_line(
|
||||||
|
get_linewidth(series, i), get_linestyle(series, i), lc, sp
|
||||||
|
)
|
||||||
arrowside = isa(series[:arrow], Arrow) ? series[:arrow].side : :none
|
arrowside = isa(series[:arrow], Arrow) ? series[:arrow].side : :none
|
||||||
arrowstyle = isa(series[:arrow], Arrow) ? series[:arrow].style : :simple
|
arrowstyle = isa(series[:arrow], Arrow) ? series[:arrow].style : :simple
|
||||||
gr_set_fillcolor(lc)
|
gr_set_fillcolor(lc)
|
||||||
@ -1598,7 +1664,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
elseif st == :contour
|
elseif st == :contour
|
||||||
GR.setspace(clims[1], clims[2], 0, 90)
|
GR.setspace(clims[1], clims[2], 0, 90)
|
||||||
GR.setlinetype(gr_linetype(get_linestyle(series)))
|
GR.setlinetype(gr_linetype(get_linestyle(series)))
|
||||||
GR.setlinewidth(max(0, get_linewidth(series)) / nominal_size())
|
GR.setlinewidth(max(0, get_linewidth(series)) / nominal_size(sp))
|
||||||
is_lc_black = let black=plot_color(:black)
|
is_lc_black = let black=plot_color(:black)
|
||||||
plot_color(series[:linecolor]) in (black,[black])
|
plot_color(series[:linecolor]) in (black,[black])
|
||||||
end
|
end
|
||||||
@ -1688,7 +1754,9 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
segments = iter_segments(series)
|
segments = iter_segments(series)
|
||||||
for (i, rng) in enumerate(segments)
|
for (i, rng) in enumerate(segments)
|
||||||
lc = get_linecolor(series, clims, i)
|
lc = get_linecolor(series, clims, i)
|
||||||
gr_set_line(get_linewidth(series, i), get_linestyle(series, i), lc) #, series[:linealpha])
|
gr_set_line(
|
||||||
|
get_linewidth(series, i), get_linestyle(series, i), lc, sp
|
||||||
|
)
|
||||||
gr_set_transparency(lc, get_linealpha(series, i))
|
gr_set_transparency(lc, get_linealpha(series, i))
|
||||||
GR.polyline3d(x[rng], y[rng], z[rng])
|
GR.polyline3d(x[rng], y[rng], z[rng])
|
||||||
end
|
end
|
||||||
@ -1719,7 +1787,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
|
|
||||||
# draw the shapes
|
# draw the shapes
|
||||||
lc = get_linecolor(series, clims, i)
|
lc = get_linecolor(series, clims, i)
|
||||||
gr_set_line(get_linewidth(series, i), get_linestyle(series, i), lc)
|
gr_set_line(get_linewidth(series, i), get_linestyle(series, i), lc, sp)
|
||||||
gr_set_transparency(lc, get_linealpha(series, i))
|
gr_set_transparency(lc, get_linealpha(series, i))
|
||||||
GR.polyline(xseg, yseg)
|
GR.polyline(xseg, yseg)
|
||||||
end
|
end
|
||||||
@ -1739,12 +1807,12 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
# this is all we need to add the series_annotations text
|
# this is all we need to add the series_annotations text
|
||||||
anns = series[:series_annotations]
|
anns = series[:series_annotations]
|
||||||
for (xi,yi,str,fnt) in EachAnn(anns, x, y)
|
for (xi,yi,str,fnt) in EachAnn(anns, x, y)
|
||||||
gr_set_font(fnt)
|
gr_set_font(fnt, sp)
|
||||||
gr_text(GR.wctondc(xi, yi)..., str)
|
gr_text(GR.wctondc(xi, yi)..., str)
|
||||||
end
|
end
|
||||||
|
|
||||||
if sp[:legend] == :inline && should_add_to_legend(series)
|
if sp[:legend] == :inline && should_add_to_legend(series)
|
||||||
gr_set_font(legendfont(sp))
|
gr_set_font(legendfont(sp), sp)
|
||||||
gr_set_textcolor(plot_color(sp[:legendfontcolor]))
|
gr_set_textcolor(plot_color(sp[:legendfontcolor]))
|
||||||
if sp[:yaxis][:mirror]
|
if sp[:yaxis][:mirror]
|
||||||
(_,i) = sp[:xaxis][:flip] ? findmax(x) : findmin(x)
|
(_,i) = sp[:xaxis][:flip] ? findmax(x) : findmin(x)
|
||||||
@ -1762,39 +1830,39 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
end
|
end
|
||||||
|
|
||||||
# draw the colorbar
|
# draw the colorbar
|
||||||
hascolorbar(sp) && gr_draw_colorbar(cbar, sp, get_clims(sp))
|
hascolorbar(sp) && gr_draw_colorbar(cbar, sp, get_clims(sp), viewport_plotarea)
|
||||||
|
|
||||||
# add the legend
|
# add the legend
|
||||||
if !(sp[:legend] in(:none, :inline))
|
if !(sp[:legend] in(:none, :inline))
|
||||||
GR.savestate()
|
GR.savestate()
|
||||||
GR.selntran(0)
|
GR.selntran(0)
|
||||||
GR.setscale(0)
|
GR.setscale(0)
|
||||||
gr_set_font(legendfont(sp))
|
gr_set_font(legendfont(sp), sp)
|
||||||
w = legendw
|
w = legendw
|
||||||
n = legendn
|
n = legendn
|
||||||
if w > 0
|
if w > 0
|
||||||
dy = _gr_point_mult[1] * sp[:legendfontsize] * 1.75
|
dy = gr_point_mult(sp) * sp[:legendfontsize] * 1.75
|
||||||
h = dy*n
|
h = dy*n
|
||||||
xpos, ypos = gr_legend_pos(sp, w, h)
|
xpos, ypos = gr_legend_pos(sp, w, h, viewport_plotarea)
|
||||||
GR.setfillintstyle(GR.INTSTYLE_SOLID)
|
GR.setfillintstyle(GR.INTSTYLE_SOLID)
|
||||||
gr_set_fillcolor(sp[:background_color_legend])
|
gr_set_fillcolor(sp[:background_color_legend])
|
||||||
GR.fillrect(xpos - 0.08, xpos + w + 0.02, ypos + dy, ypos - dy * n)
|
GR.fillrect(xpos - 0.08, xpos + w + 0.02, ypos + dy, ypos - dy * n)
|
||||||
gr_set_line(1, :solid, sp[:foreground_color_legend])
|
gr_set_line(1, :solid, sp[:foreground_color_legend], sp)
|
||||||
GR.drawrect(xpos - 0.08, xpos + w + 0.02, ypos + dy, ypos - dy * n)
|
GR.drawrect(xpos - 0.08, xpos + w + 0.02, ypos + dy, ypos - dy * n)
|
||||||
i = 0
|
i = 0
|
||||||
if sp[:legendtitle] !== nothing
|
if sp[:legendtitle] !== nothing
|
||||||
GR.settextalign(GR.TEXT_HALIGN_CENTER, GR.TEXT_VALIGN_HALF)
|
GR.settextalign(GR.TEXT_HALIGN_CENTER, GR.TEXT_VALIGN_HALF)
|
||||||
gr_set_font(legendtitlefont(sp))
|
gr_set_font(legendtitlefont(sp), sp)
|
||||||
gr_text(xpos - 0.03 + 0.5*w, ypos, string(sp[:legendtitle]))
|
gr_text(xpos - 0.03 + 0.5*w, ypos, string(sp[:legendtitle]))
|
||||||
ypos -= dy
|
ypos -= dy
|
||||||
gr_set_font(legendfont(sp))
|
gr_set_font(legendfont(sp), sp)
|
||||||
end
|
end
|
||||||
for series in series_list(sp)
|
for series in series_list(sp)
|
||||||
clims = get_clims(sp, series)
|
clims = get_clims(sp, series)
|
||||||
should_add_to_legend(series) || continue
|
should_add_to_legend(series) || continue
|
||||||
st = series[:seriestype]
|
st = series[:seriestype]
|
||||||
lc = get_linecolor(series, clims)
|
lc = get_linecolor(series, clims)
|
||||||
gr_set_line(sp[:legendfontsize] / 8, get_linestyle(series), lc) #, series[:linealpha])
|
gr_set_line(sp[:legendfontsize] / 8, get_linestyle(series), lc, sp)
|
||||||
|
|
||||||
if (st == :shape || series[:fillrange] !== nothing) && series[:ribbon] === nothing
|
if (st == :shape || series[:fillrange] !== nothing) && series[:ribbon] === nothing
|
||||||
fc = get_fillcolor(series, clims)
|
fc = get_fillcolor(series, clims)
|
||||||
@ -1807,7 +1875,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
gr_polyline(x, y, GR.fillarea)
|
gr_polyline(x, y, GR.fillarea)
|
||||||
lc = get_linecolor(series, clims)
|
lc = get_linecolor(series, clims)
|
||||||
gr_set_transparency(lc, get_linealpha(series))
|
gr_set_transparency(lc, get_linealpha(series))
|
||||||
gr_set_line(get_linewidth(series), get_linestyle(series), lc)
|
gr_set_line(get_linewidth(series), get_linestyle(series), lc, sp)
|
||||||
st == :shape && gr_polyline(x, y)
|
st == :shape && gr_polyline(x, y)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1848,7 +1916,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
GR.savestate()
|
GR.savestate()
|
||||||
# update the bounding window
|
# update the bounding window
|
||||||
if ispolar(sp)
|
if ispolar(sp)
|
||||||
gr_set_viewport_polar()
|
gr_set_viewport_polar(viewport_plotarea)
|
||||||
else
|
else
|
||||||
xmin, xmax, ymin, ymax = data_lims
|
xmin, xmax, ymin, ymax = data_lims
|
||||||
if xmax > xmin && ymax > ymin
|
if xmax > xmin && ymax > ymin
|
||||||
@ -1862,7 +1930,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
else
|
else
|
||||||
GR.wctondc(x, y)
|
GR.wctondc(x, y)
|
||||||
end
|
end
|
||||||
gr_set_font(val.font)
|
gr_set_font(val.font, sp)
|
||||||
gr_text(x, y, val.str)
|
gr_text(x, y, val.str)
|
||||||
end
|
end
|
||||||
GR.restorestate()
|
GR.restorestate()
|
||||||
|
|||||||
11
src/utils.jl
11
src/utils.jl
@ -624,6 +624,17 @@ function get_aspect_ratio(sp)
|
|||||||
return aspect_ratio
|
return aspect_ratio
|
||||||
end
|
end
|
||||||
|
|
||||||
|
get_size(kw) = get(kw, :size, default(:size))
|
||||||
|
get_size(plt::Plot) = get_size(plt.attr)
|
||||||
|
get_size(sp::Subplot) = get_size(sp.plt)
|
||||||
|
get_size(series::Series) = get_size(series.plotattributes[:subplot])
|
||||||
|
|
||||||
|
get_thickness_scaling(kw) = get(kw, :thickness_scaling, default(:thickness_scaling))
|
||||||
|
get_thickness_scaling(plt::Plot) = get_thickness_scaling(plt.attr)
|
||||||
|
get_thickness_scaling(sp::Subplot) = get_thickness_scaling(sp.plt)
|
||||||
|
get_thickness_scaling(series::Series) =
|
||||||
|
get_thickness_scaling(series.plotattributes[:subplot])
|
||||||
|
|
||||||
# ---------------------------------------------------------------
|
# ---------------------------------------------------------------
|
||||||
|
|
||||||
makekw(; kw...) = KW(kw)
|
makekw(; kw...) = KW(kw)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user