fixed dataframes loading; added dataframes to tests; started atom integration
This commit is contained in:
parent
b08212e2f9
commit
8b2a838388
@ -239,6 +239,9 @@ function __init__()
|
|||||||
@eval import IJulia
|
@eval import IJulia
|
||||||
IJulia.display_dict(plt::AbstractPlot) = Dict{ASCIIString, ByteString}("text/html" => sprint(writemime, "text/html", plt))
|
IJulia.display_dict(plt::AbstractPlot) = Dict{ASCIIString, ByteString}("text/html" => sprint(writemime, "text/html", plt))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
setup_dataframes()
|
||||||
|
setup_atom()
|
||||||
end
|
end
|
||||||
|
|
||||||
# ---------------------------------------------------------
|
# ---------------------------------------------------------
|
||||||
|
|||||||
@ -79,7 +79,7 @@ function addExtension(fn::@compat(AbstractString), ext::@compat(AbstractString))
|
|||||||
end
|
end
|
||||||
|
|
||||||
function savefig(plt::AbstractPlot, fn::@compat(AbstractString))
|
function savefig(plt::AbstractPlot, fn::@compat(AbstractString))
|
||||||
|
|
||||||
# get the extension
|
# get the extension
|
||||||
local ext
|
local ext
|
||||||
try
|
try
|
||||||
@ -117,3 +117,25 @@ Base.display(::Base.REPL.REPLDisplay, ::MIME"text/plain", plt::AbstractPlot) = g
|
|||||||
function Base.writemime(io::IO, ::MIME"text/html", plt::AbstractPlot)
|
function Base.writemime(io::IO, ::MIME"text/html", plt::AbstractPlot)
|
||||||
writemime(io, MIME("image/svg+xml"), plt)
|
writemime(io, MIME("image/svg+xml"), plt)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------
|
||||||
|
# Atom PlotPane
|
||||||
|
# ---------------------------------------------------------
|
||||||
|
|
||||||
|
function setup_atom()
|
||||||
|
# @require Atom begin
|
||||||
|
# @eval begin
|
||||||
|
# import Atom
|
||||||
|
#
|
||||||
|
# Atom.displaysize(::AbstractPlot) = (535, 379)
|
||||||
|
# Atom.displaytitle(::AbstractPlot) = "Plots.jl"
|
||||||
|
#
|
||||||
|
# Atom.@render Atom.PlotPane p::Plot begin
|
||||||
|
# x, y = Atom.@rpc Atom.plotsize()
|
||||||
|
# plot!(p, size=(x,y)) # changes the size of the Plots.Plot
|
||||||
|
# Atom.div(Dict(:style=>"background: white"), Atom.HTML(stringmime("text/html", p)))
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
end
|
||||||
|
|||||||
54
src/plot.jl
54
src/plot.jl
@ -531,39 +531,33 @@ end
|
|||||||
|
|
||||||
# For DataFrame support. Imports DataFrames and defines the necessary methods which support them.
|
# For DataFrame support. Imports DataFrames and defines the necessary methods which support them.
|
||||||
|
|
||||||
@require DataFrames begin
|
function setup_dataframes()
|
||||||
|
@require DataFrames begin
|
||||||
|
|
||||||
function createKWargsList(plt::AbstractPlot, df::DataFrames.AbstractDataFrame, args...; kw...)
|
function createKWargsList(plt::AbstractPlot, df::DataFrames.AbstractDataFrame, args...; kw...)
|
||||||
createKWargsList(plt, args...; kw..., dataframe = df)
|
createKWargsList(plt, args...; kw..., dataframe = df)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# expecting the column name of a dataframe that was passed in... anything else should error
|
||||||
|
function extractGroupArgs(s::Symbol, df::DataFrames.AbstractDataFrame, args...)
|
||||||
|
if haskey(df, s)
|
||||||
|
return extractGroupArgs(df[s])
|
||||||
|
else
|
||||||
|
error("Got a symbol, and expected that to be a key in d[:dataframe]. s=$s d=$d")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function getDataFrameFromKW(d::Dict)
|
||||||
|
get(d, :dataframe) do
|
||||||
|
error("Missing dataframe argument!")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# the conversion functions for when we pass symbols or vectors of symbols to reference dataframes
|
||||||
|
convertToAnyVector(s::Symbol, d::Dict) = Any[getDataFrameFromKW(d)[s]], s
|
||||||
|
convertToAnyVector(v::AVec{Symbol}, d::Dict) = (df = getDataFrameFromKW(d); Any[df[s] for s in v]), v
|
||||||
|
|
||||||
# expecting the column name of a dataframe that was passed in... anything else should error
|
|
||||||
function extractGroupArgs(s::Symbol, df::DataFrames.AbstractDataFrame, args...)
|
|
||||||
if haskey(df, s)
|
|
||||||
return extractGroupArgs(df[s])
|
|
||||||
else
|
|
||||||
error("Got a symbol, and expected that to be a key in d[:dataframe]. s=$s d=$d")
|
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
function getDataFrameFromKW(d::Dict)
|
|
||||||
# for (k,v) in kw
|
|
||||||
# if k == :dataframe
|
|
||||||
# return v
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
get(d, :dataframe) do
|
|
||||||
error("Missing dataframe argument!")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# the conversion functions for when we pass symbols or vectors of symbols to reference dataframes
|
|
||||||
# convertToAnyVector(s::Symbol; kw...) = Any[getDataFrameFromKW(;kw...)[s]], s
|
|
||||||
# convertToAnyVector(v::AVec{Symbol}; kw...) = (df = getDataFrameFromKW(;kw...); Any[df[s] for s in v]), v
|
|
||||||
convertToAnyVector(s::Symbol, d::Dict) = Any[getDataFrameFromKW(d)[s]], s
|
|
||||||
convertToAnyVector(v::AVec{Symbol}, d::Dict) = (df = getDataFrameFromKW(d); Any[df[s] for s in v]), v
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
|
|||||||
@ -10,3 +10,5 @@ ImageMagick
|
|||||||
PyPlot
|
PyPlot
|
||||||
@osx QuartzImageIO
|
@osx QuartzImageIO
|
||||||
GR
|
GR
|
||||||
|
DataFrames
|
||||||
|
RDatasets
|
||||||
|
|||||||
@ -2,6 +2,8 @@
|
|||||||
using VisualRegressionTests
|
using VisualRegressionTests
|
||||||
using ExamplePlots
|
using ExamplePlots
|
||||||
|
|
||||||
|
import DataFrames, RDatasets
|
||||||
|
|
||||||
# don't let pyplot use a gui... it'll crash
|
# don't let pyplot use a gui... it'll crash
|
||||||
# note: Agg will set gui -> :none in PyPlot
|
# note: Agg will set gui -> :none in PyPlot
|
||||||
ENV["MPLBACKEND"] = "Agg"
|
ENV["MPLBACKEND"] = "Agg"
|
||||||
@ -16,12 +18,12 @@ using Plots, FactCheck
|
|||||||
default(size=(500,300))
|
default(size=(500,300))
|
||||||
|
|
||||||
|
|
||||||
# TODO: use julia's Condition type and the wait() and notify() functions to initialize a Window, then wait() on a condition that
|
# TODO: use julia's Condition type and the wait() and notify() functions to initialize a Window, then wait() on a condition that
|
||||||
# is referenced in a button press callback (the button clicked callback will call notify() on that condition)
|
# is referenced in a button press callback (the button clicked callback will call notify() on that condition)
|
||||||
|
|
||||||
function image_comparison_tests(pkg::Symbol, idx::Int; debug = false, popup = isinteractive(), sigma = [1,1], eps = 1e-2)
|
function image_comparison_tests(pkg::Symbol, idx::Int; debug = false, popup = isinteractive(), sigma = [1,1], eps = 1e-2)
|
||||||
|
|
||||||
# first
|
# first
|
||||||
Plots._debugMode.on = debug
|
Plots._debugMode.on = debug
|
||||||
example = ExamplePlots._examples[idx]
|
example = ExamplePlots._examples[idx]
|
||||||
info("Testing plot: $pkg:$idx:$(example.header)")
|
info("Testing plot: $pkg:$idx:$(example.header)")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user