Skip to content

Commit

Permalink
color aesthetic with date (#1491)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mattriks authored Nov 5, 2020
1 parent 90185dc commit e992927
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/scale.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ using Showoff
using IndirectArrays
using CategoricalArrays
using Printf
using Base.Iterators
using Base.Iterators, Dates

import Gadfly: element_aesthetics, isconcrete, concrete_length, discretize_make_ia,
aes2str, valid_aesthetics, Maybe
Expand Down Expand Up @@ -661,7 +661,7 @@ function apply_scale(scale::ContinuousColorScale,
cdata = skipmissing(
Iterators.flatten(i.color for i in datas if !(i.color == nothing || eltype(i.color)<:Colorant)))
if !isempty(cdata)
isa(first(cdata), Number) || error(colorclash)
typeof(first(cdata))<:Union{Number, Date} || error(colorclash)
cmin, cmax = extrema(cdata)
else
return
Expand Down
12 changes: 9 additions & 3 deletions test/testscripts/continuous_color_scale_range.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
using Gadfly
using Dates, Gadfly

set_default_plot_size(6inch, 3inch)
set_default_plot_size(6.6inch, 3inch)

plot(x=[0.236033, 0.346517, 0.312707, 0.00790928, 0.488613, 0.210968, 0.951916, 0.999905, 0.251662, 0.986666],
p1 = plot(x=[0.236033, 0.346517, 0.312707, 0.00790928, 0.488613, 0.210968, 0.951916, 0.999905, 0.251662, 0.986666],
y=[0.555751, 0.437108, 0.424718, 0.773223, 0.28119, 0.209472, 0.251379, 0.0203749, 0.287702, 0.859512],
color=[0.0769509, 0.640396, 0.873544, 0.278582, 0.751313, 0.644883, 0.0778264, 0.848185, 0.0856352, 0.553206],
Scale.color_continuous(minvalue=-10, maxvalue=10))

p2 = plot(x=1:4, y=1:4, color=Date("2017-10-01"):Day(1):Date("2017-10-04"),
Scale.color_continuous(minvalue=Date("2017-10-01"),maxvalue=Date("2017-10-08"))
)

hstack(p1, p2)

0 comments on commit e992927

Please sign in to comment.