Skip to content

Commit

Permalink
Apply theme transformations concept
Browse files Browse the repository at this point in the history
Quick implementation of `apply_theme_transformations!(geom::Geom.RectangularGeometry, stat::Stat.RectbinStatistic, aes::Aesthetics, theme::Theme)` concept.
  • Loading branch information
CiaranOMara committed Mar 31, 2019
1 parent 62ee5f6 commit db70c10
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
23 changes: 23 additions & 0 deletions src/Gadfly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,18 @@ function render_prepared(plot::Plot,
# IV. Geometries
themes = Theme[layer.theme === nothing ? plot.theme : layer.theme
for layer in plot.layers]

for (layer, stats, aes, theme) in zip(plot.layers, layer_stats, layer_aess, themes)

if length(stats)> 1
@warn "stats" stats
end

for stat in stats
apply_theme_transformations!(layer.geom, stat, aes, theme)
end
end

zips = trim_zip(plot.layers, layer_aess,
layer_subplot_aess,
layer_subplot_datas,
Expand Down Expand Up @@ -1102,6 +1114,17 @@ include("geometry.jl")
include("guide.jl")
include("statistics.jl")

function apply_theme_transformations!(geom::GeometryElement, stat::StatisticElement, aes::Aesthetics, theme::Theme)
# @info "apply_theme_transformations!" geom stat aes theme
end

function apply_theme_transformations!(geom::Geom.RectangularGeometry, stat::Stat.RectbinStatistic, aes::Aesthetics, theme::Theme)

@info "apply_theme_transformations! specific to geom::Geom.RectangularGeometry, stat::Stat.RectbinStatistic combination."

aes.xmax = aes.xmax .* cx .- theme.bar_spacing
aes.ymax = aes.ymax .* cy .- theme.bar_spacing
end

# All aesthetics must have a scale. If none is given, we use a default.
# The default depends on whether the input is discrete or continuous (i.e.,
Expand Down
15 changes: 9 additions & 6 deletions src/geom/rectbin.jl
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
function RectangularBinGeometry(
default_statistic::Gadfly.StatisticElement=Gadfly.Stat.rectbin();
tag=empty_tag)
RectangularGeometry(default_statistic, tag)
end
# function RectangularBinGeometry(
# default_statistic::Gadfly.StatisticElement=Gadfly.Stat.rectbin();
# tag=empty_tag)
# RectangularGeometry(default_statistic, tag)
# end

"""
Geom.rectbin
Draw equal sizes rectangles centered at `x` and `y` positions. Optionally
specify their `color`.
"""
const rectbin = RectangularBinGeometry
# const rectbin = RectangularBinGeometry
function rectbin()
RectangularGeometry(Gadfly.Stat.rectbin())
end

"""
Geom.histogram2d[(; xbincount=nothing, xminbincount=3, xmaxbincount=150,
Expand Down

0 comments on commit db70c10

Please sign in to comment.