Merge pull request #976 from daschw/ds-gr-legend
Line legend marker for ribbons in GR (fix #896)
This commit is contained in:
commit
9c8e879465
@ -272,6 +272,10 @@ function normalize_zvals(zv::AVec)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
gr_alpha(α::Void) = 1
|
||||||
|
gr_alpha(α::Real) = α
|
||||||
|
|
||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
|
|
||||||
# draw ONE Shape
|
# draw ONE Shape
|
||||||
@ -1042,6 +1046,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
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_textcolor(sp[:foreground_color_legend])
|
gr_set_textcolor(sp[:foreground_color_legend])
|
||||||
|
GR.settransparency(1)
|
||||||
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
|
||||||
end
|
end
|
||||||
@ -1049,16 +1054,26 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
should_add_to_legend(series) || continue
|
should_add_to_legend(series) || continue
|
||||||
st = series[:seriestype]
|
st = series[:seriestype]
|
||||||
gr_set_line(series[:linewidth], series[:linestyle], series[:linecolor]) #, series[:linealpha])
|
gr_set_line(series[:linewidth], series[:linestyle], series[:linecolor]) #, series[:linealpha])
|
||||||
if st == :path && series[:fillrange] == nothing
|
|
||||||
GR.polyline([xpos - 0.07, xpos - 0.01], [ypos, ypos])
|
if st == :shape || series[:fillrange] != nothing
|
||||||
elseif st == :shape || series[:fillrange] != nothing
|
|
||||||
gr_set_fill(series[:fillcolor]) #, series[:fillalpha])
|
gr_set_fill(series[:fillcolor]) #, series[:fillalpha])
|
||||||
l, r = xpos-0.07, xpos-0.01
|
l, r = xpos-0.07, xpos-0.01
|
||||||
b, t = ypos-0.4dy, ypos+0.4dy
|
b, t = ypos-0.4dy, ypos+0.4dy
|
||||||
x = [l, r, r, l, l]
|
x = [l, r, r, l, l]
|
||||||
y = [b, b, t, t, b]
|
y = [b, b, t, t, b]
|
||||||
|
GR.settransparency(gr_alpha(series[:fillalpha]))
|
||||||
gr_polyline(x, y, GR.fillarea)
|
gr_polyline(x, y, GR.fillarea)
|
||||||
gr_polyline(x, y)
|
GR.settransparency(gr_alpha(series[:linealpha]))
|
||||||
|
st == :shape && gr_polyline(x, y)
|
||||||
|
end
|
||||||
|
|
||||||
|
if st == :path
|
||||||
|
GR.settransparency(gr_alpha(series[:linealpha]))
|
||||||
|
if series[:fillrange] == nothing || series[:ribbon] != nothing
|
||||||
|
GR.polyline([xpos - 0.07, xpos - 0.01], [ypos, ypos])
|
||||||
|
else
|
||||||
|
GR.polyline([xpos - 0.07, xpos - 0.01], [ypos+0.4dy, ypos+0.4dy])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if series[:markershape] != :none
|
if series[:markershape] != :none
|
||||||
|
|||||||
@ -493,7 +493,7 @@ function make_fillrange_from_ribbon(kw::KW)
|
|||||||
y, rib = kw[:y], kw[:ribbon]
|
y, rib = kw[:y], kw[:ribbon]
|
||||||
rib = wraptuple(rib)
|
rib = wraptuple(rib)
|
||||||
rib1, rib2 = -first(rib), last(rib)
|
rib1, rib2 = -first(rib), last(rib)
|
||||||
kw[:ribbon] = nothing
|
# kw[:ribbon] = nothing
|
||||||
kw[:fillrange] = make_fillrange_side(y, rib1), make_fillrange_side(y, rib2)
|
kw[:fillrange] = make_fillrange_side(y, rib1), make_fillrange_side(y, rib2)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user