From 85040d6104c9e2c821faa844542c0afe0337bbc6 Mon Sep 17 00:00:00 2001 From: Thomas Breloff Date: Mon, 21 Sep 2015 12:05:17 -0400 Subject: [PATCH] fix creating empty plot with plot() --- src/backends/immerse.jl | 2 +- src/colors.jl | 9 +++------ src/plot.jl | 5 ++++- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/backends/immerse.jl b/src/backends/immerse.jl index 44c2fd81..f9cfb32a 100644 --- a/src/backends/immerse.jl +++ b/src/backends/immerse.jl @@ -114,7 +114,7 @@ function buildSubplotObject!(::ImmersePackage, subplt::Subplot) end # destructor... clean up plots - Gtk.on_signal_destroy((x...) -> [Immerse.dropfig(_display,i) for i in figindices], win) + Gtk.on_signal_destroy((x...) -> [Immerse.dropfig(Immerse._display,i) for i in figindices], win) subplt.o = win end diff --git a/src/colors.jl b/src/colors.jl index 15e22d7c..da607924 100644 --- a/src/colors.jl +++ b/src/colors.jl @@ -88,7 +88,9 @@ function adjustAway(val, bgval, vmin=0., vmax=100.) end end +# borrowed from http://stackoverflow.com/a/1855903: lightnessLevel(c::Colorant) = 0.299 * red(c) + 0.587 * green(c) + 0.114 * blue(c) + isdark(c::Colorant) = lightnessLevel(c) < 0.5 islight(c::Colorant) = !isdark(c) @@ -128,8 +130,6 @@ end function getPaletteUsingColorDiffFromBackground(bgcolor::Colorant, numcolors::Int = _defaultNumColors) colordiffs = [colordiff(c, bgcolor) for c in _allColors] mindiff = colordiffs[reverse(sortperm(colordiffs))[numcolors]] - @show bgcolor numcolors mindiff colordiffs - # filter(c -> colordiff(c, bgcolor) > 0.5, _allColors) filter(c -> colordiff(c, bgcolor) >= mindiff, _allColors) end @@ -143,11 +143,9 @@ function getBackgroundRGBColor(c, d::Dict) # d[:color_palette] = getPaletteUsingDistinguishableColors(bgcolor) # d[:color_palette] = getPaletteUsingFixedColorList(bgcolor) d[:color_palette] = getPaletteUsingColorDiffFromBackground(bgcolor) - @show d[:color_palette] # set the foreground color (text, ticks, gridlines) to be white or black depending - # on how dark the background is. borrowed from http://stackoverflow.com/a/1855903 - # a = 0.299 * red(bgcolor) + 0.587 * green(bgcolor) + 0.114 * blue(bgcolor) + # on how dark the background is. if !haskey(d, :foreground_color) || d[:foreground_color] == :auto d[:foreground_color] = isdark(bgcolor) ? colorant"white" : colorant"black" end @@ -165,7 +163,6 @@ function getSeriesRGBColor(c, d::Dict, n::Int) end # should be a RGB now... either it was passed in, generated automatically, or created from a string - # @assert isa(c, RGB) @assert isa(c, Colorant) # return the RGB diff --git a/src/plot.jl b/src/plot.jl index 99b109ec..afbfd398 100644 --- a/src/plot.jl +++ b/src/plot.jl @@ -264,8 +264,11 @@ end function createKWargsList(plt::PlottingObject; kw...) d = Dict(kw) if !haskey(d, :y) - error("Called plot/subplot without args... must set y in the keyword args. Example: plot(; y=rand(10))") + # assume we just want to create an empty plot object which can be added to later + return [] + # error("Called plot/subplot without args... must set y in the keyword args. Example: plot(; y=rand(10))") end + if haskey(d, :x) return createKWargsList(plt, d[:x], d[:y]; kw...) else