Open DancingQuanta opened 5 years ago
This issue was caused by my revtex.tplx
in the ways I did not understand. Originally I have modifed someone's else template for revtex document class to have some cell tags code to manipulate contents passed to nbconvert
. Since nbconvert
have added more control over the cell tags I no longer needed my modifications any more and forgot about them. Since them this tags code have been mashed things up for holoviews objects!
So this issue is reduced to lack of documenataion on hotebook_extension
and use of nbconvert
.
I am writing my observations here for using nbconvert
to generate markdown
export from a jupyter notebook (especially from Download as
interface).
I am using the following imports and hv setup
import numpy as np
import holoviews as hv
import hvplot.xarray
import xarray as xr
hv.extension('matplotlib')
hv.notebook_extension(display_formats=['html', 'svg'])
hv.output(fig='svg')
hv.notebook_extension(display_formats=['html', 'svg'])
This sets all the rendered plots to be a SVG images which you can easily right click to get context menu and save as
.
However, when exporting a markdown version of a notebook the images was extracted as normal and the new markdown file contain reference to SVG images as an HTML img src
tag not markdown image link as I expected.
hv.notebook_extension(display_formats=['svg'])
This case is missing the html
item from the display format and the rendered images are not SVG images as far I can tell because I cannot save as
them.
Interestlngly enough, when converting to markdown the new markdown file contain references to images as proper markdown image link which is what I wanted all along.
I am using Chrome with a useful extension called Dark Reader
which transform websites to white texxt on black. Using this extension I have observed visual differences between above cases. For the case 1, the figures are unaffected by my extension modifying the notebook to black so they show up white. In case 2, the figures are affected and is showing up black background and plot elements are inverted colours. This made me suspect that addition of html
to the display formats wraps the SVG in HTML tags which allows it to be saved through context menu.
As far as I can tell, it is nice to see flexibility in exposing SVG images through an HTML tags though unfortunately do not convert to markdown image links upon export to markdown format.
Summary: hv.notebook_extension(display_formats=['svg'])
is great for clean markdown export from a notebook with SVG images.
Edit; the notebook I am using is here
I have a jupyter notebook I wanted to convert to latex with
nbconvert
. I have set up my notebook with following settingsI am using holoviews master
91259b96
.I used the following
nbconvert
command.A tex document was created with text repr of the holoviews object. The
nbconvert
also appears to create a pdf of each plot. I am expecting a latex enviroment with graphic rendering tex code in place.I may have been missing this in the docs or this latex rendering is not yet fully supported.