Display IFrame in IJulia Jupyter Notebook - julia

Is there a way to display an IFrame in an IJulia Jupyter notebook?
I am trying to use Plotly.jl with Jupyter. When plot is called it returns a URL linking to the generated graph.
Using an IFrame should allow this to work out.
Plotly.plot(["z"=>rand(6,6)],["style"=>["type"=>"heatmap"]])
https://plot.ly/~astrieanna/0 # Returned URL

This is not an answer the the posted question, but it does solve the issue with plotly.
Plotly.jl is about to undergo massive changes. One of these will be relying on the PlotlyJS.jl package for all plot generation and display.
If you want to use plotly from julia in a jupyter notebook you should use PlotlyJS.jl: https://github.com/spencerlyon2/PlotlyJS.jl
Docs here: http://spencerlyon.com/PlotlyJS.jl/

IJuliaPortrayals has an IFrame constructor.
IFrame(600, 200, "http://julialang.org")
At In [15]:
Bring back 2003-era pages with IFrame!

Related

How to refresh plots without needing to close the previous plot?

How do I get VSCode to refresh the plot when making a new plot without needing to close the previous plot tab?
Ideally, it should open up a new tab with the new plot next to the old one.
Moreover, when using Httpgd, even tho the plot refreshes without me having to close the previous plot, it opens up in a separate window outside VSCode. How do I get it to open up as a new tab like in the gif above?
I had the exact same problem and what fixed it for me was simply, in vscode, going into:
Files > Preferences > Settings > section Extensions > scroll down and find R:
find the section "Plot: Use Httpgd" and check it, and restart Vscode.
I can't confirm but I believe it might have started after installing the httpgd package, because I had the behavior you desire before installation, and the exact same behavior you experience after httpgd installation. Of course if my solution works for you (I hope), it will work under httpgd after and not the base default VsCode/R-plot viewer as in your gif.
#coip pointed out that the steps given on this stackoverflow post to me. Downloading the httpgd package from CRAN fixed the problem for me.

Octave in Jupyter Notebook - Opening 3D plot in an external window for interactive use

Is it possible using Octave in Jupyter Notebook to open plots in an external window so that they can be manipulated (zooming in/out, rotating)?
I hoped there would be some switch so that I could use them inline (as it is by default) but if need be, I could open them in an external window to manipulate it the way like in GNU Octave GUI. After checking what I need, I would switch back to inline.
I looked for some hints. I found this %%octave -g in octavemagic: Octave inside IPython. Unforutunately, it doesn't work for me when using Octave kernel.
I found something about inline plotting in An Octave kernel for Jupyter (Configuration section) but it doesn't look like it could help anything in regard to switching on/off it from the notebook.
For example, I would like the following code to invoke an external window.
y=-10:0.4:10+eps;
[xx,yy]=meshgrid(x,y);
zz= sin(sqrt(xx.^2+yy.^2))./(sqrt(xx.^2+yy.^2));
surf(xx,yy,zz)
view(-35,45)
It looks like that I have finally found the answer here:
https://github.com/Calysto/octave_kernel/issues/98
https://github.com/Calysto/octave_kernel/issues/6
https://am111.readthedocs.io/en/latest/jmatlab_use.html
%plot gnuplot - switch to using external window
%plot inline - switch to using inline plotting

Jupyter Notebook save to PDF without Code

This has been an ongoing issue for me, as I would love to use Jupyter Notebook to write my research reports, but have found it very difficult to export my Jupyter Notebooks to PDF without code and without large formatting errors.
I am able to download the notebooks as PDF, but have not found a way to hide the code, or have the PDF resemble the formatting of the notebook.
No solution I've found on SO has been sufficient for my issue, so it may be possible that this is not the intended functionality of Jupyter Notebook.
Have you tried this:
jupyter nbconvert path/to/your/ipynb --to=pdf --TemplateExporter.exclude_input=True
For more on the flags, you can refer to nbconvert config options
I have successfully converted .ipynb to .html exclude the code blocks
I followed the suggestion by 0xffff above but the PDF output did not behave as intended (code blocks were still included).
However, their suggestion inspired me to try converting to html first using the following call:
jupyter nbconvert path/to/your/ipynb --to=html --TemplateExporter.exclude_input=True
This behaved as intended, and from there, it was straightforward to print the output to PDF in a browser.
Regarding the issue with the --to=pdf flag, I've opened up an issue on the Jupyter Notebook git repo: https://github.com/jupyter/notebook/issues/3804. Will report back once I get a response.
nbconvert
nbconvert is an official package, and other answers have mentioned it. However, they did not mention there are two ways to convert to PDF.
The default option uses LaTeX, and it's often a pain to install:
jupyter nbconvert notebook.ipynb --to=pdf
A newer option is to use the webpdf converter, this does not require LaTeX
jupyter nbconvert notebook.ipynb --to=webpdf
Quarto
Quarto is the newest option. The defaults are prettier than nbconvert, and it has advanced features to customize the output PDF. However, it uses pandoc (and pandoc uses LaTeX), so you must install both first.
quarto render notebook.ipynb --to pdf
Quarto is a new project, and I often run into problems (I couldn't convert the sample notebook); however, the project is in active development and I'm sure it will get better.
Online converters
The last option is to use one of the many online services. The two main caveats are 1) You might not want to upload your notebooks to some random website, and 2) It's often unclear what engine they use to convert the notebooks. I've tried many of them with mostly negative results.
I created one online converter that uses nbconvert and deletes your notebook as soon as it's converted.
If you manually create the PDF, there is a simpler solution: add the following code block & execute it
from IPython.core.display import HTML
HTML('<style>.input, .jp-InputArea {display: none !important}</style>')
Code will disappear both in the "normal" UI and in print preview / export to HTML. Open print preview, generate the PDF - it looks great now, clear the output of this one cell to bring the code back, done

How to display images when using for loop in IJulia?

i want to display images in Jupyter using Image.jl.
the doc says:
If you're using the IJulia notebook, images will be displayed automatically.
Julia code for the display of images can be found in ImageView. Installation of this package is recommended but not required.
but i failed to find any way to automatically display images in a for loop. the code below is an example:
using Images
for i=1:10
convert(Image,rand(100,100))
end
i guess there exits an undocumented function to draw images in IJulia which can be called explicitly to show out those hidden results. thanks in advance! #tholy
You need to use the display function, which is what IJulia uses, you can find it's documentation in the Multimedia I/O section of the Julia manual.

R leaflet package inline in IPython Notebook

I'm using R in Ipython Notebook with R line and cell magics. All of my R plots print automatically inline except for the R package leaflet which opens in a new browser tab.
I've tried using %capture to capture the output. I've also tried doing different versions of --inline.
In knitr, the map is included inside the file following the code chunk. Any idea on how to get this functionality in ipython notebook using R?
Thanks in advance for any and all help.
Edit:
%%capture only works with strings.
You can display interactive maps inline using rMaps.
There is a demonstration notebook here:
http://nbviewer.ipython.org/github/ipython/front-to-back/blob/master/R_demo.ipynb

Resources