From ed1cce86ef3bbefb7f0d7771f549c285d6dace3f Mon Sep 17 00:00:00 2001 From: Thomas Breloff Date: Tue, 8 Mar 2016 15:07:51 -0500 Subject: [PATCH] ijulia, plotly, and gr display fixes --- src/Plots.jl | 36 +++++++----------------------------- src/backends/gr.jl | 5 +++++ src/backends/plotly.jl | 5 +---- 3 files changed, 13 insertions(+), 33 deletions(-) diff --git a/src/Plots.jl b/src/Plots.jl index a24a2437b..b5ff1bdc4 100644 --- a/src/Plots.jl +++ b/src/Plots.jl @@ -223,38 +223,16 @@ yaxis!(plt::Plot, args...; kw...) = plot!(pl # --------------------------------------------------------- - -# try -# import DataFrames -# dataframes() -# end - -# const CURRENT_BACKEND = pickDefaultBackend() - -# for be in backends() -# try -# backend(be) -# backend() -# catch err -# @show err -# end -# end - const CURRENT_BACKEND = CurrentBackend(:none) -# function __init__() -# # global const CURRENT_BACKEND = pickDefaultBackend() -# # global const CURRENT_BACKEND = CurrentBackend(:none) - -# # global CURRENT_BACKEND -# # println("[Plots.jl] Default backend: ", CURRENT_BACKEND.sym) +function __init__() -# # # auto init dataframes if the import statement doesn't error out -# # try -# # @eval import DataFrames -# # dataframes() -# # end -# end + # override IJulia inline display + if isijulia() + @eval import IJulia + IJulia.display_dict(plt::PlottingObject) = Dict{ASCIIString, ByteString}("text/html" => sprint(writemime, "text/html", plt)) + end +end # --------------------------------------------------------- diff --git a/src/backends/gr.jl b/src/backends/gr.jl index 43f101cff..31442a15f 100644 --- a/src/backends/gr.jl +++ b/src/backends/gr.jl @@ -701,6 +701,10 @@ function Base.writemime(io::IO, m::MIME"image/svg+xml", plt::PlottingObject{GRPa write(io, readall("gks.svg")) end +function Base.writemime(io::IO, m::MIME"text/html", plt::PlottingObject{GRPackage}) + writemime(io, MIME("image/svg+xml"), plt) +end + function Base.writemime(io::IO, m::MIME"application/pdf", plt::PlottingObject{GRPackage}) GR.emergencyclosegks() ENV["GKS_WSTYPE"] = "pdf" @@ -722,5 +726,6 @@ function Base.display(::PlotsDisplay, plt::Plot{GRPackage}) end function Base.display(::PlotsDisplay, plt::Subplot{GRPackage}) + gr_display(plt) true end diff --git a/src/backends/plotly.jl b/src/backends/plotly.jl index 2c2b86bc2..960a7f95b 100644 --- a/src/backends/plotly.jl +++ b/src/backends/plotly.jl @@ -457,11 +457,8 @@ end # ---------------------------------------------------------------- - function Base.writemime(io::IO, ::MIME"image/png", plt::PlottingObject{PlotlyPackage}) - isijulia() && return - # TODO: write a png to io - println("todo: png") + warn("todo: png") end function Base.writemime(io::IO, ::MIME"text/html", plt::PlottingObject{PlotlyPackage})