Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Literate.notebook & Plots: "_show is not defined for this backend. m=text/plain" #8

Closed
mcabbott opened this issue May 9, 2018 · 6 comments

Comments

@mcabbott
Copy link

mcabbott commented May 9, 2018

When generating a notebook which contains Plots.jl plot() commands, I get a warning _show is not defined for this backend. m=text/plain.

MWE: this file produces the error, attached as .txt to please github: test.jl.txt. Contents is:

# Save this as `test.jl` on the desktop, and then run
# ```
# using Literate
# Literate.notebook("/Users/me/Desktop/test.jl","/Users/me/Desktop/")
# ```
using Plots
gr()
plot(rand(20))

# That gives a warning, uncommenting these lines gives an error:

# unicodeplots()
# plot(rand(20))

Here is the warning produced:

julia> using Literate
julia> Literate.notebook("/Users/me/Desktop/test.jl","/Users/me/Desktop/")
Info: generating notebook from /Users/me/Desktop/test.jl
Info: not running on Travis, skipping links will not be correct.
Info: executing notebook test.ipynb
WARNING: _show is not defined for this backend. m=text/plain

If I uncomment the last two lines of the file, and run that again, then in addition I get the following errors:


┌────────────────────────────────────────────────────────────┐
0.9 │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│ y1
│⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
│⠀⠀⠀⠀⠀⠀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
│⠀⠀⠀⠀⠀⢸⢣⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⢱⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
│⠀⠀⠀⠀⠀⢸⠀⢣⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡸⢇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
│⠀⠀⠀⠀⠀⡜⠀⠀⢣⢀⡠⠔⡆⠀⠀⠀⢰⠁⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⡇⠀⠀⠀⠀⡇⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
│⠀⠀⠀⠀⠀⡇⠀⠀⠀⠁⠀⠀⡇⠀⠀⠀⢸⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡜⢣⠀⠀⠀⢰⠁⠘⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢰⢆⠀⠀⠀⠀⠀│
│⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⢸⠀⠀⠀⡸⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⠇⠸⡀⠀⠀⡸⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡸⠀⠑⢄⡀⠀⠀│
│⠀⠀⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠘⡄⠀⠀⡇⠀⠀⢇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⠀⠀⡇⠀⠀⡇⠀⠀⢱⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⢇⠀⠀│
│⠀⠀⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⡇⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡎⠀⠀⢸⠀⢠⠃⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢰⠁⠀⠀⠀⠘⡄⠀│
│⠀⠀⠀⠀⡜⠀⠀⠀⠀⠀⠀⠀⠀⢸⠀⢸⠀⠀⠀⢸⠀⠀⠀⠀⠀⠀⢸⢇⠀⠀⢠⠃⠀⠀⠈⡆⢸⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⠀⠀⠀⠀⠀⢱⠀│
│⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠘⡄⢸⠀⠀⠀⠘⡄⠀⠀⠀⠀⠀⡜⠈⢆⠀⢸⠀⠀⠀⠀⢣⡇⠀⠀⠀⠀⢣⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⢇│
│⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⡎⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⡇⠀⠈⡆⡇⠀⠀⠀⠀⠸⠇⠀⠀⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⠃⠀⠀⠀⠀⠀⠀⠘│
│⠀⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⡇⠀⠀⠀⠀⡇⠀⠀⠀⠀⢰⠁⠀⠀⠘⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢇⠀⠀⠀⠀⠀⠀⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀│
│⠀⠀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⠇⠀⠀⠀⠀⢱⠀⠀⠀⠀⡸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢆⠀⠀⠀⡰⠢⣀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀│
│⠀⠀⠀⡜⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢆⢀⠎⠀⠀⠀⠑⠇⠀⠀⠀⠀⠀⠀⠀⠀│
│⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⡀⠀⠀⢠⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
│⠀⠀⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠱⡀⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
│⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠱⡀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
0 │⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠱⠇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
└────────────────────────────────────────────────────────────┘
0                                                           20
WARNING: _show is not defined for this backend. m=image/svg+xml
WARNING: _show is not defined for this backend. m=application/pdf
Error: error when executing notebook based on input file: /Users/me/Desktop/test.jl
ERROR: FileIO.File{FileIO.DataFormat{:UNKNOWN}}("/var/folders/1b/6flsxnb12rx3r3ktpr_zllyc0000gn/T/juliaiokN4H.pdf") couldn't be recognized by FileIO.

Stacktrace:
[1] #load#20(::Array{Any,1}, ::Function, ::FileIO.File{FileIO.DataFormat{:UNKNOWN}}) at /Users/me/.julia/v0.6/FileIO/src/loadsave.jl:88
[2] load(::FileIO.File{FileIO.DataFormat{:UNKNOWN}}) at /Users/me/.julia/v0.6/FileIO/src/loadsave.jl:86
[3] #load#13(::Array{Any,1}, ::Function, ::String) at /Users/me/.julia/v0.6/FileIO/src/loadsave.jl:52
[4] _show(::IOContext{Base64EncodePipe}, ::MIME{Symbol("image/png")}, ::Plots.Plot{Plots.UnicodePlotsBackend}) at /Users/me/.julia/v0.6/Plots/src/output.jl:230
[5] show(::IOContext{Base64EncodePipe}, ::MIME{Symbol("image/png")}, ::Plots.Plot{Plots.UnicodePlotsBackend}) at /Users/me/.julia/v0.6/Plots/src/output.jl:210
[6] limitstringmime(::MIME{Symbol("image/png")}, ::Plots.Plot{Plots.UnicodePlotsBackend}) at /Users/me/.julia/v0.6/Literate/src/IJulia.jl:68
[7] display_dict(::Plots.Plot{Plots.UnicodePlotsBackend}) at /Users/me/.julia/v0.6/Literate/src/IJulia.jl:28
[8] execute_notebook(::Dict{Any,Any}) at /Users/me/.julia/v0.6/Literate/src/Literate.jl:532
[9] #15 at /Users/me/.julia/v0.6/Literate/src/Literate.jl:466 [inlined]
[10] cd(::Literate.##15#19, ::String) at ./file.jl:70
[11] #notebook#11(::Base.#identity, ::Base.#identity, ::Bool, ::Bool, ::Bool, ::String, ::Array{Any,1}, ::Function, ::String, ::String) at /Users/me/.julia/v0.6/Literate/src/Literate.jl:465
[12] notebook(::String, ::String) at /Users/me/.julia/v0.6/Literate/src/Literate.jl:396
@fredrikekre
Copy link
Owner

fredrikekre commented May 9, 2018

Thanks for the report. All errors here are actually thrown from within Plots.jl, so its not all Literates fault. There are a couple of problems:

  1. There is not fallback _show method for the different backends (All backends should have a fallback for "text/plain" JuliaPlots/Plots.jl#1515)
  2. UnicodePlots is simply broken in the notebook (UnicodePlots broken in IJulia JuliaPlots/Plots.jl#1514)
  3. The last thing, which seems to be a bug in Literate is the serialization of image/svg+xml data, which I am trying to understand... (Edit: Its Plots shouldn't lie about output data JuliaPlots/Plots.jl#1529)

@mcabbott
Copy link
Author

Thanks for taking a look, and opening issues on Plots. Sounds like 1 & 2 at least should be simple.

@fredrikekre
Copy link
Owner

Ok, the last thing seem to be because Plots.jl lies about what data it sends back, see JuliaPlots/Plots.jl#1529

fredrikekre added a commit that referenced this issue May 17, 2018
this is needed for image/svg+xml and text/html, fix #8
@RoyiAvital
Copy link

Is there a way to get color in the MarkDown output of Literarte.jl for plots of UnicodePlots.jl?

@fredrikekre
Copy link
Owner

Does it work in Documenter?

@RoyiAvital
Copy link

Haven't tried. Just looking on a way creating a MarkDown file which is version control friendly.
So I thought on 2 options:

  1. Using UnicodePlots.jl.
  2. Pushing images to ImgUr then embedding by link.

Unfortunately ImgUr requires registration of the application etc...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants