format code to tab length of 4
This commit is contained in:
parent
df6fa6fd68
commit
fafb0d9510
@ -1,5 +1,4 @@
|
||||
|
||||
|
||||
defaultOutputFormat(plt::Plot) = "png"
|
||||
|
||||
function png(plt::Plot, fn::AbstractString)
|
||||
@ -18,7 +17,6 @@ function svg(plt::Plot, fn::AbstractString)
|
||||
end
|
||||
svg(fn::AbstractString) = svg(current(), fn)
|
||||
|
||||
|
||||
function pdf(plt::Plot, fn::AbstractString)
|
||||
fn = addExtension(fn, "pdf")
|
||||
io = open(fn, "w")
|
||||
@ -27,7 +25,6 @@ function pdf(plt::Plot, fn::AbstractString)
|
||||
end
|
||||
pdf(fn::AbstractString) = pdf(current(), fn)
|
||||
|
||||
|
||||
function ps(plt::Plot, fn::AbstractString)
|
||||
fn = addExtension(fn, "ps")
|
||||
io = open(fn, "w")
|
||||
@ -76,8 +73,8 @@ function txt(plt::Plot, fn::AbstractString)
|
||||
end
|
||||
txt(fn::AbstractString) = txt(current(), fn)
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
const _savemap = Dict(
|
||||
"png" => png,
|
||||
@ -94,14 +91,6 @@ const _savemap = Dict(
|
||||
|
||||
const _extension_map = Dict("tikz" => "tex")
|
||||
|
||||
function getExtension(fn::AbstractString)
|
||||
pieces = split(fn, ".")
|
||||
length(pieces) > 1 || error("Can't extract file extension: ", fn)
|
||||
ext = pieces[end]
|
||||
haskey(_savemap, ext) || error("Invalid file extension: ", fn)
|
||||
ext
|
||||
end
|
||||
|
||||
function addExtension(fn::AbstractString, ext::AbstractString)
|
||||
oldfn, oldext = splitext(fn)
|
||||
oldext = chop(oldext, head = 1, tail = 0)
|
||||
@ -141,6 +130,7 @@ savefig(fn::AbstractString) = savefig(current(), fn)
|
||||
|
||||
|
||||
# ---------------------------------------------------------
|
||||
|
||||
"""
|
||||
gui([plot])
|
||||
|
||||
@ -168,12 +158,8 @@ end
|
||||
|
||||
# ---------------------------------------------------------
|
||||
|
||||
const _best_html_output_type = KW(
|
||||
:pyplot => :png,
|
||||
:unicodeplots => :txt,
|
||||
:plotlyjs => :html,
|
||||
:plotly => :html
|
||||
)
|
||||
const _best_html_output_type =
|
||||
KW(:pyplot => :png, :unicodeplots => :txt, :plotlyjs => :html, :plotly => :html)
|
||||
|
||||
# a backup for html... passes to svg or png depending on the html_output_format arg
|
||||
function _show(io::IO, ::MIME"text/html", plt::Plot)
|
||||
@ -183,7 +169,12 @@ function _show(io::IO, ::MIME"text/html", plt::Plot)
|
||||
end
|
||||
if output_type == :png
|
||||
# @info("writing png to html output")
|
||||
print(io, "<img src=\"data:image/png;base64,", base64encode(show, MIME("image/png"), plt), "\" />")
|
||||
print(
|
||||
io,
|
||||
"<img src=\"data:image/png;base64,",
|
||||
base64encode(show, MIME("image/png"), plt),
|
||||
"\" />",
|
||||
)
|
||||
elseif output_type == :svg
|
||||
# @info("writing svg to html output")
|
||||
show(io, MIME("image/svg+xml"), plt)
|
||||
@ -204,9 +195,18 @@ function _display(plt::Plot)
|
||||
end
|
||||
|
||||
# for writing to io streams... first prepare, then callback
|
||||
for mime in ("text/plain", "text/html", "image/png", "image/eps", "image/svg+xml",
|
||||
"application/eps", "application/pdf", "application/postscript",
|
||||
"application/x-tex", "application/vnd.plotly.v1+json")
|
||||
for mime in (
|
||||
"text/plain",
|
||||
"text/html",
|
||||
"image/png",
|
||||
"image/eps",
|
||||
"image/svg+xml",
|
||||
"application/eps",
|
||||
"application/pdf",
|
||||
"application/postscript",
|
||||
"application/x-tex",
|
||||
"application/vnd.plotly.v1+json",
|
||||
)
|
||||
@eval function Base.show(io::IO, m::MIME{Symbol($mime)}, plt::Plot)
|
||||
if haskey(io, :juno_plotsize)
|
||||
showjuno(io, m, plt)
|
||||
@ -218,7 +218,8 @@ for mime in ("text/plain", "text/html", "image/png", "image/eps", "image/svg+xml
|
||||
end
|
||||
end
|
||||
|
||||
Base.show(io::IO, m::MIME"application/prs.juno.plotpane+html", plt::Plot) = showjuno(io, MIME("text/html"), plt)
|
||||
Base.show(io::IO, m::MIME"application/prs.juno.plotpane+html", plt::Plot) =
|
||||
showjuno(io, MIME("text/html"), plt)
|
||||
|
||||
# default text/plain for all backends
|
||||
_show(io::IO, ::MIME{Symbol("text/plain")}, plt::Plot) = show(io, plt)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user