added Showoff dependency; fix PLOTS_DEFAULTS; fix auto fill to 0; fix scale warning; tick labels with Showoff; fontsize in GR; travis deps

This commit is contained in:
Thomas Breloff 2016-07-18 15:00:02 -04:00
parent 624d33b96f
commit 3ccd1bc368
10 changed files with 67 additions and 40 deletions

View File

@ -6,3 +6,4 @@ Reexport
Compat
FixedSizeArrays
Measures
Showoff

View File

@ -11,6 +11,7 @@ using FixedSizeArrays
@reexport using RecipesBase
using Base.Meta
@reexport using PlotUtils
import Showoff
export
AbstractPlot,
@ -236,8 +237,8 @@ function __init__()
setup_ijulia()
setup_atom()
if haskey(ENV, "PLOTS_DEFAULTS")
for (k,v) in eval(parse(ENV["PLOTS_DEFAULTS"]))
if isdefined(Main, :PLOTS_DEFAULTS)
for (k,v) in Main.PLOTS_DEFAULTS
default(k, v)
end
end

View File

@ -585,15 +585,15 @@ end
function processFillArg(d::KW, arg)
fr = get(d, :fillrange, 0)
# fr = get(d, :fillrange, 0)
if typeof(arg) <: Brush
arg.size == nothing || (fr = arg.size)
arg.size == nothing || (d[:fillrange] = arg.size)
arg.color == nothing || (d[:fillcolor] = arg.color == :auto ? :auto : plot_color(arg.color))
arg.alpha == nothing || (d[:fillalpha] = arg.alpha)
# fillrange function
elseif allFunctions(arg)
fr = arg
d[:fillrange] = arg
# fillalpha
elseif allAlphas(arg)
@ -601,9 +601,9 @@ function processFillArg(d::KW, arg)
elseif !handleColors!(d, arg, :fillcolor)
fr = arg
d[:fillrange] = arg
end
d[:fillrange] = fr
# d[:fillrange] = fr
return
end
@ -778,7 +778,7 @@ function warnOnUnsupported(pkg::AbstractBackend, d::KW)
end
function warnOnUnsupported_scales(pkg::AbstractBackend, d::KW)
for k in (:xscale, :yscale, :zscale)
for k in (:xscale, :yscale, :zscale, :scale)
if haskey(d, k)
v = d[k]
v = get(_scaleAliases, v, v)

View File

@ -129,9 +129,18 @@ const _inv_scale_funcs = Dict{Symbol,Function}(
:ln => exp,
)
const _label_func = Dict{Symbol,Function}(
:log10 => x -> "10^$x",
:log2 => x -> "2^$x",
:ln => x -> "e^$x",
# :log2 => exp2,
# :ln => exp,
)
scalefunc(scale::Symbol) = x -> get(_scale_funcs, scale, identity)(Float64(x))
invscalefunc(scale::Symbol) = x -> get(_inv_scale_funcs, scale, identity)(Float64(x))
labelfunc(scale::Symbol) = get(_label_func, scale, string)
function optimal_ticks_and_labels(axis::Axis, ticks = nothing)
lims = axis_limits(axis)
@ -139,18 +148,32 @@ function optimal_ticks_and_labels(axis::Axis, ticks = nothing)
# scale the limits
scale = axis[:scale]
scaled_lims = map(scalefunc(scale), lims)
# @show lims scaled_lims
# get a list of well-laid-out ticks
cv = if ticks == nothing
optimize_ticks(scaled_lims...)[1]
optimize_ticks(scaled_lims...,
k_min = 5, # minimum number of ticks
k_max = 8, # maximum number of ticks
span_buffer = 0.0 # padding buffer in case nice ticks are closeby
)[1]
else
ticks
end
# # expand to ensure we see all the ticks
# expand_extrema!(axis, cv)
# rescale and return values and labels
# @show cv
ticklabels = map(labelfunc(scale), Showoff.showoff(cv, :plain))
tickvals = map(invscalefunc(scale), cv)
basestr = scale == :log10 ? "10^" : scale == :log2 ? "2^" : scale == :ln ? "e^" : ""
tickvals, ["$basestr$cvi" for cvi in cv]
# @show tickvals ticklabels
# ticklabels = Showoff.showoff(tickvals, scale == :log10 ? :scientific : :auto)
tickvals, ticklabels
# basestr = scale == :log10 ? "10^" : scale == :log2 ? "2^" : scale == :ln ? "e^" : ""
# tickvals, ["$basestr$cvi" for cvi in cv]
end
# return (continuous_values, discrete_values) for the ticks on this axis

View File

@ -448,7 +448,7 @@ function gr_display(plt::Plot)
# update point mult
px_per_pt = px / pt
_gr_point_mult[1] = px_per_pt / max(h,w)
_gr_point_mult[1] = 1.5 * px_per_pt / max(h,w)
# subplots:
for sp in plt.subplots
@ -566,7 +566,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
end
xticks, yticks, spine_segs, grid_segs = axis_drawing_info(sp)
# @show xticks yticks spine_segs grid_segs
# @show xticks yticks #spine_segs grid_segs
# draw the grid lines
if sp[:grid]

View File

@ -147,14 +147,15 @@ function Base.writemime(io::IO, ::MIME"text/html", plt::Plot)
end
end
function _writemime(io::IO, m, plt::Plot)
warn("_writemime is not defined for this backend. m=", string(m))
end
function _display(plt::Plot)
warn("_display is not defined for this backend.")
end
# for writing to io streams... first prepare, then callback
for mime in keys(_mimeformats)
@eval function _writemime(io::IO, m, plt::Plot)
warn("_writemime is not defined for this backend. m=", string(m))
end
@eval function _display(plt::Plot)
warn("_display is not defined for this backend.")
end
@eval function Base.writemime(io::IO, m::MIME{Symbol($mime)}, plt::Plot)
prepare_output(plt)
_writemime(io, m, plt)
@ -166,24 +167,22 @@ end
# A backup, if no PNG generation is defined, is to try to make a PDF and use FileIO to convert
if is_installed("FileIO")
@eval begin
import FileIO
function _writemime(io::IO, ::MIME"image/png", plt::Plot)
fn = tempname()
@eval import FileIO
function _writemime(io::IO, ::MIME"image/png", plt::Plot)
fn = tempname()
# first save a pdf file
pdf(plt, fn)
# first save a pdf file
pdf(plt, fn)
# load that pdf into a FileIO Stream
s = FileIO.load(fn * ".pdf")
# load that pdf into a FileIO Stream
s = FileIO.load(fn * ".pdf")
# save a png
pngfn = fn * ".png"
FileIO.save(pngfn, s)
# save a png
pngfn = fn * ".png"
FileIO.save(pngfn, s)
# now write from the file
write(io, readall(open(pngfn)))
end
# now write from the file
write(io, readall(open(pngfn)))
end
end

View File

@ -77,7 +77,7 @@ function seriestype_supported(pkg::AbstractBackend, st::Symbol)
end
macro deps(st, args...)
:(series_recipe_dependencies($(quot(st)), $(map(quot, args)...)))
:(Plots.series_recipe_dependencies($(quot(st)), $(map(quot, args)...)))
end
# get a list of all seriestypes

View File

@ -5,8 +5,10 @@ PlotUtils
StatPlots
Reexport
Measures
Showoff
FactCheck
Images
ImageMagick
@osx QuartzImageIO
GR
DataFrames

View File

@ -30,7 +30,7 @@ facts("GR") do
@fact gr() --> Plots.GRBackend()
@fact backend() --> Plots.GRBackend()
# @linux_only image_comparison_facts(:gr, skip=[], eps=img_eps)
@linux_only image_comparison_facts(:gr, skip=[], eps=img_eps)
end
facts("Plotly") do

View File

@ -1,8 +1,8 @@
Pkg.clone("ImageMagick")
Pkg.build("ImageMagick")
# Pkg.clone("ImageMagick")
# Pkg.build("ImageMagick")
Pkg.clone("GR")
Pkg.build("GR")
# Pkg.clone("GR")
# Pkg.build("GR")
Pkg.clone("https://github.com/JuliaPlots/PlotReferenceImages.jl.git")
@ -17,8 +17,9 @@ Pkg.clone("StatPlots")
# Pkg.clone("https://github.com/spencerlyon2/PlotlyJS.jl.git")
# Pkg.checkout("RecipesBase")
Pkg.clone("VisualRegressionTests")
# Pkg.clone("VisualRegressionTests")
# need this to use Conda
ENV["PYTHON"] = ""
Pkg.add("PyPlot")
Pkg.build("PyPlot")