Skip to content

Commit ed1cce8

Browse files
committed
ijulia, plotly, and gr display fixes
1 parent 9a544b0 commit ed1cce8

File tree

3 files changed

+13
-33
lines changed

3 files changed

+13
-33
lines changed

src/Plots.jl

+7-29
Original file line numberDiff line numberDiff line change
@@ -223,38 +223,16 @@ yaxis!(plt::Plot, args...; kw...) = plot!(pl
223223

224224
# ---------------------------------------------------------
225225

226-
227-
# try
228-
# import DataFrames
229-
# dataframes()
230-
# end
231-
232-
# const CURRENT_BACKEND = pickDefaultBackend()
233-
234-
# for be in backends()
235-
# try
236-
# backend(be)
237-
# backend()
238-
# catch err
239-
# @show err
240-
# end
241-
# end
242-
243226
const CURRENT_BACKEND = CurrentBackend(:none)
244227

245-
# function __init__()
246-
# # global const CURRENT_BACKEND = pickDefaultBackend()
247-
# # global const CURRENT_BACKEND = CurrentBackend(:none)
248-
249-
# # global CURRENT_BACKEND
250-
# # println("[Plots.jl] Default backend: ", CURRENT_BACKEND.sym)
228+
function __init__()
251229

252-
# # # auto init dataframes if the import statement doesn't error out
253-
# # try
254-
# # @eval import DataFrames
255-
# # dataframes()
256-
# # end
257-
# end
230+
# override IJulia inline display
231+
if isijulia()
232+
@eval import IJulia
233+
IJulia.display_dict(plt::PlottingObject) = Dict{ASCIIString, ByteString}("text/html" => sprint(writemime, "text/html", plt))
234+
end
235+
end
258236

259237
# ---------------------------------------------------------
260238

src/backends/gr.jl

+5
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,10 @@ function Base.writemime(io::IO, m::MIME"image/svg+xml", plt::PlottingObject{GRPa
701701
write(io, readall("gks.svg"))
702702
end
703703

704+
function Base.writemime(io::IO, m::MIME"text/html", plt::PlottingObject{GRPackage})
705+
writemime(io, MIME("image/svg+xml"), plt)
706+
end
707+
704708
function Base.writemime(io::IO, m::MIME"application/pdf", plt::PlottingObject{GRPackage})
705709
GR.emergencyclosegks()
706710
ENV["GKS_WSTYPE"] = "pdf"
@@ -722,5 +726,6 @@ function Base.display(::PlotsDisplay, plt::Plot{GRPackage})
722726
end
723727

724728
function Base.display(::PlotsDisplay, plt::Subplot{GRPackage})
729+
gr_display(plt)
725730
true
726731
end

src/backends/plotly.jl

+1-4
Original file line numberDiff line numberDiff line change
@@ -457,11 +457,8 @@ end
457457

458458
# ----------------------------------------------------------------
459459

460-
461460
function Base.writemime(io::IO, ::MIME"image/png", plt::PlottingObject{PlotlyPackage})
462-
isijulia() && return
463-
# TODO: write a png to io
464-
println("todo: png")
461+
warn("todo: png")
465462
end
466463

467464
function Base.writemime(io::IO, ::MIME"text/html", plt::PlottingObject{PlotlyPackage})

0 commit comments

Comments
 (0)