remove const _gr_plot_size, _gr_point_mult and _gr_thickness_scaling

This commit is contained in:
Daniel Schwabeneder 2020-05-03 14:13:39 +02:00
parent ba8ca424cf
commit 712ef74b81
2 changed files with 215 additions and 128 deletions

View File

@ -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,10 +416,6 @@ end
# -------------------------------------------------------------------------------------- # --------------------------------------------------------------------------------------
# viewport plot area # viewport plot area
# 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)
@ -541,9 +540,12 @@ function gr_draw_colorbar(cbar::GRColorbar, sp::Subplot, clims, viewport_plotare
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)
@ -554,10 +556,10 @@ function gr_draw_colorbar(cbar::GRColorbar, sp::Subplot, clims, viewport_plotare
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( gr_text(
@ -642,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
@ -655,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
@ -676,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)
@ -692,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
@ -703,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
@ -762,10 +764,10 @@ end
function gr_axis_height(sp, axis) function gr_axis_height(sp, axis)
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
return h return h
@ -773,10 +775,10 @@ end
function gr_axis_width(sp, axis) function gr_axis_width(sp, axis)
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
return w return w
@ -797,9 +799,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
@ -813,20 +815,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]
@ -844,9 +848,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
@ -857,14 +862,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)
@ -875,9 +880,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
@ -890,7 +895,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
@ -900,7 +905,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
@ -910,9 +915,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
@ -921,9 +926,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
@ -981,12 +986,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
@ -1000,7 +1005,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)
@ -1089,7 +1094,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)
@ -1108,33 +1113,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
@ -1142,17 +1177,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
@ -1161,30 +1196,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)...)
@ -1200,6 +1244,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
@ -1231,6 +1276,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
@ -1262,6 +1308,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
@ -1287,10 +1334,10 @@ 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
@ -1310,26 +1357,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
@ -1337,12 +1401,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
@ -1351,20 +1415,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)...)
@ -1397,10 +1467,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)
@ -1411,7 +1481,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]
@ -1432,7 +1502,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
@ -1447,7 +1518,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
@ -1462,7 +1534,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
@ -1475,7 +1548,7 @@ 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), viewport_plotarea[4] + h, xaxis[:guide]) gr_text(gr_view_xcenter(viewport_plotarea), viewport_plotarea[4] + h, xaxis[:guide])
@ -1487,7 +1560,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
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)
@ -1500,7 +1573,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
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)
@ -1568,7 +1641,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)
@ -1585,7 +1660,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
@ -1675,7 +1750,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
@ -1706,7 +1783,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
@ -1726,12 +1803,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)
@ -1756,32 +1833,32 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
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, viewport_plotarea) 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)
@ -1794,7 +1871,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
@ -1849,7 +1926,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()

View File

@ -624,6 +624,16 @@ 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[:sp])
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[:sp])
# --------------------------------------------------------------- # ---------------------------------------------------------------
makekw(; kw...) = KW(kw) makekw(; kw...) = KW(kw)