Skip to content

Commit

Permalink
ijulia, plotly, and gr display fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tbreloff committed Mar 8, 2016
1 parent 9a544b0 commit ed1cce8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 33 deletions.
36 changes: 7 additions & 29 deletions src/Plots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

# ---------------------------------------------------------

Expand Down
5 changes: 5 additions & 0 deletions src/backends/gr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -722,5 +726,6 @@ function Base.display(::PlotsDisplay, plt::Plot{GRPackage})
end

function Base.display(::PlotsDisplay, plt::Subplot{GRPackage})
gr_display(plt)
true
end
5 changes: 1 addition & 4 deletions src/backends/plotly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down

0 comments on commit ed1cce8

Please sign in to comment.