Skip to content

Commit

Permalink
plot multiple lines according to size, shape, and alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
bjarthur committed Dec 31, 2021
1 parent 9245b75 commit 141c9f4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/geom/line.jl
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,16 @@ function Gadfly.Geom.render(geom::LineGeometry, theme::Gadfly.Theme, aes::Gadfly
default_aes.group = IndirectArray([1])
default_aes.color = [theme.default_color]
default_aes.linestyle = theme.line_style[1:1]
default_aes.size = Measure[theme.point_size]
default_aes.shape = Function[theme.point_shapes[1]]
default_aes.alpha = [theme.alphas[1]]
aes = inherit(aes, default_aes)

# Render lines, using multivariate groupings:
XT, YT = eltype(aes.x), eltype(aes.y)
GT, CT, LST = Int, eltype(aes.color), eltype(aes.linestyle)
groups = collect(Tuple{GT, CT, LST}, Compose.cyclezip(aes.group, aes.color, aes.linestyle))
GT, CT, LST, SzT, ShT, AT = Int, eltype(aes.color), eltype(aes.linestyle), eltype(aes.size), eltype(aes.shape), eltype(aes.alpha)
groups = collect(Tuple{GT, CT, LST, SzT, ShT, AT},
Compose.cyclezip(aes.group, aes.color, aes.linestyle, aes.size, aes.shape, aes.alpha))
ugroups = unique(groups)
nugroups = length(ugroups)
# Recycle groups
Expand Down
12 changes: 12 additions & 0 deletions test/testscripts/twolines_size_shape_alpha.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Gadfly

set_default_plot_size(12inch, 3inch)

p_size = plot(x=[1,2,3,1,2,3], y=[1,2,3,4,5,6], size=[1,1,1,2,2,2],
Geom.line, Geom.point, Scale.size_discrete2(n->range(3pt, 8pt, length=n)))
p_shape = plot(x=[1,2,3,1,2,3], y=[1,2,3,4,5,6], shape=[1,1,1,2,2,2],
Geom.line, Geom.point)
p_alpha = plot(x=[1,2,3,1,2,3], y=[1,2,3,4,5,6], alpha=[1,1,1,0.5,0.5,0.5],
Geom.line, Geom.point)

hstack(p_size, p_shape, p_alpha)

0 comments on commit 141c9f4

Please sign in to comment.