foreground_color fixes and added support in pyplot
This commit is contained in:
parent
454630dace
commit
be43e64743
18
src/args.jl
18
src/args.jl
@ -115,6 +115,7 @@ _plotDefaults[:ylabel] = ""
|
|||||||
_plotDefaults[:yrightlabel] = ""
|
_plotDefaults[:yrightlabel] = ""
|
||||||
_plotDefaults[:legend] = true
|
_plotDefaults[:legend] = true
|
||||||
_plotDefaults[:background_color] = colorant"white"
|
_plotDefaults[:background_color] = colorant"white"
|
||||||
|
_plotDefaults[:foreground_color] = :auto
|
||||||
_plotDefaults[:xticks] = true
|
_plotDefaults[:xticks] = true
|
||||||
_plotDefaults[:yticks] = true
|
_plotDefaults[:yticks] = true
|
||||||
_plotDefaults[:size] = (800,600)
|
_plotDefaults[:size] = (800,600)
|
||||||
@ -125,7 +126,7 @@ _plotDefaults[:show] = false
|
|||||||
|
|
||||||
# TODO: x/y scales
|
# TODO: x/y scales
|
||||||
|
|
||||||
const _allArgs = sort(collect(intersect(keys(_seriesDefaults), keys(_plotDefaults))))
|
const _allArgs = sort(collect(union(keys(_seriesDefaults), keys(_plotDefaults))))
|
||||||
supportedArgs(::PlottingPackage) = _allArgs
|
supportedArgs(::PlottingPackage) = _allArgs
|
||||||
supportedArgs() = supportedArgs(plotter())
|
supportedArgs() = supportedArgs(plotter())
|
||||||
|
|
||||||
@ -246,6 +247,7 @@ function warnOnUnsupported(pkg::PlottingPackage, d::Dict)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
# build the argument dictionary for the plot
|
||||||
function getPlotArgs(pkg::PlottingPackage, kw, idx::Int)
|
function getPlotArgs(pkg::PlottingPackage, kw, idx::Int)
|
||||||
d = Dict(kw)
|
d = Dict(kw)
|
||||||
|
|
||||||
@ -274,8 +276,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# build the argument dictionary for a series
|
||||||
# note: idx is the index of this series within this call, n is the index of the series from all calls to plot/subplot
|
|
||||||
function getSeriesArgs(pkg::PlottingPackage, initargs::Dict, kw, commandIndex::Int, plotIndex::Int, globalIndex::Int) # TODO, pass in initargs, not plt
|
function getSeriesArgs(pkg::PlottingPackage, initargs::Dict, kw, commandIndex::Int, plotIndex::Int, globalIndex::Int) # TODO, pass in initargs, not plt
|
||||||
d = Dict(kw)
|
d = Dict(kw)
|
||||||
|
|
||||||
@ -300,17 +301,6 @@ function getSeriesArgs(pkg::PlottingPackage, initargs::Dict, kw, commandIndex::I
|
|||||||
aliasesAndAutopick(d, :linestyle, _styleAliases, supportedStyles(pkg), plotIndex)
|
aliasesAndAutopick(d, :linestyle, _styleAliases, supportedStyles(pkg), plotIndex)
|
||||||
aliasesAndAutopick(d, :marker, _markerAliases, supportedMarkers(pkg), plotIndex)
|
aliasesAndAutopick(d, :marker, _markerAliases, supportedMarkers(pkg), plotIndex)
|
||||||
|
|
||||||
# # auto-pick
|
|
||||||
# if d[:axis] == :auto
|
|
||||||
# d[:axis] = autopick_ignore_none_auto(supportedAxes(pkg), plotIndex)
|
|
||||||
# end
|
|
||||||
# if d[:linestyle] == :auto
|
|
||||||
# d[:linestyle] = autopick_ignore_none_auto(supportedStyles(pkg), plotIndex)
|
|
||||||
# end
|
|
||||||
# if d[:marker] == :auto
|
|
||||||
# d[:marker] = autopick_ignore_none_auto(supportedMarkers(pkg), plotIndex)
|
|
||||||
# end
|
|
||||||
|
|
||||||
# update color
|
# update color
|
||||||
d[:color] = getSeriesRGBColor(d[:color], initargs, plotIndex)
|
d[:color] = getSeriesRGBColor(d[:color], initargs, plotIndex)
|
||||||
|
|
||||||
|
|||||||
@ -94,6 +94,20 @@ function getPyPlotFunction(plt::Plot, axis::Symbol, linetype::Symbol)
|
|||||||
# return linetype == :hist ? PyPlot.plt[:hist] : (linetype in (:sticks,:bar) ? PyPlot.bar : (linetype in (:heatmap,:hexbin) ? PyPlot.hexbin : PyPlot.plot))
|
# return linetype == :hist ? PyPlot.plt[:hist] : (linetype in (:sticks,:bar) ? PyPlot.bar : (linetype in (:heatmap,:hexbin) ? PyPlot.hexbin : PyPlot.plot))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function updateAxisColors(o, fgcolor)
|
||||||
|
ax = o[:axes][1]
|
||||||
|
for loc in ("bottom", "top", "left", "right")
|
||||||
|
ax[:spines][loc][:set_color](fgcolor)
|
||||||
|
end
|
||||||
|
for axis in ("x", "y")
|
||||||
|
ax[:tick_params](axis=axis, colors=fgcolor, which="both")
|
||||||
|
end
|
||||||
|
for axis in (:yaxis, :xaxis)
|
||||||
|
ax[axis][:label][:set_color](fgcolor)
|
||||||
|
end
|
||||||
|
ax[:title][:set_color](fgcolor)
|
||||||
|
end
|
||||||
|
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
|
|
||||||
# TODO:
|
# TODO:
|
||||||
@ -217,6 +231,7 @@ end
|
|||||||
|
|
||||||
function Base.display(::PyPlotPackage, plt::Plot)
|
function Base.display(::PyPlotPackage, plt::Plot)
|
||||||
addPyPlotLegend(plt)
|
addPyPlotLegend(plt)
|
||||||
|
updateAxisColors(plt.o.o, getPyPlotColor(plt.initargs[:foreground_color]))
|
||||||
display(plt.o)
|
display(plt.o)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -137,7 +137,14 @@ end
|
|||||||
# TODO: allow the setting of the algorithm, either by passing a symbol (:colordiff, :fixed, etc) or a function?
|
# TODO: allow the setting of the algorithm, either by passing a symbol (:colordiff, :fixed, etc) or a function?
|
||||||
|
|
||||||
function getBackgroundRGBColor(c, d::Dict)
|
function getBackgroundRGBColor(c, d::Dict)
|
||||||
bgcolor = convertColor(d[:background_color])
|
if :background_color in supportedArgs()
|
||||||
|
bgcolor = convertColor(d[:background_color])
|
||||||
|
else
|
||||||
|
bgcolor = _plotDefaults[:background_color]
|
||||||
|
if d[:background_color] != _plotDefaults[:background_color]
|
||||||
|
warn("Cannot set background_color with backend $(plotter())")
|
||||||
|
end
|
||||||
|
end
|
||||||
d[:background_color] = bgcolor
|
d[:background_color] = bgcolor
|
||||||
|
|
||||||
# d[:color_palette] = getPaletteUsingDistinguishableColors(bgcolor)
|
# d[:color_palette] = getPaletteUsingDistinguishableColors(bgcolor)
|
||||||
@ -148,6 +155,8 @@ function getBackgroundRGBColor(c, d::Dict)
|
|||||||
# on how dark the background is.
|
# on how dark the background is.
|
||||||
if !haskey(d, :foreground_color) || d[:foreground_color] == :auto
|
if !haskey(d, :foreground_color) || d[:foreground_color] == :auto
|
||||||
d[:foreground_color] = isdark(bgcolor) ? colorant"white" : colorant"black"
|
d[:foreground_color] = isdark(bgcolor) ? colorant"white" : colorant"black"
|
||||||
|
else
|
||||||
|
d[:foreground_color] = convertColor(d[:foreground_color])
|
||||||
end
|
end
|
||||||
|
|
||||||
bgcolor
|
bgcolor
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user