phockett / Quantum-Metrology-with-Photoelectrons-Vol3

Other
4 stars 0 forks source link

Figure rendering (Plotly) #2

Open phockett opened 1 year ago

phockett commented 1 year ago

May also expect to see Plotly doesn't render after maths bug, although haven't had an issue with this as yet in HTML or PDF outputs.

phockett commented 1 year ago

Fixed Plotly display in HTML output in 0e7e7fb4bba9d751fb3c75157b98b59866c501bf, needs Plotly js in config file, as per https://jupyterbook.org/en/stable/interactive/interactive.html#plotly.

For rendering tests, see https://phockett.github.io/Quantum-Metrology-with-Photoelectrons-Vol3/tests/plotly_surface_render_test.html

phockett commented 1 year ago

Plotly status

phockett commented 1 year ago

Possible solutions for build-type dependence:

phockett commented 1 year ago

Basic solution using setup_notebook.py bodge now in place, see 33e23be7c6d797a6d0406a86ad568cbf98067d3d.

Tested OK for PDF build for non-glue wrapped Plotly figs, provided force notebook execution.

Needs work, also need to fix for gluePlotly() case

phockett commented 1 year ago

Plotly rendering in PDF now fixed in fcd8653ca2f5ae2676d9ff0ba3c396e046457d16, using static figure additions to gluePlotly()

For details see https://github.com/executablebooks/jupyter-book/issues/1815#issuecomment-1322435036

Note this needs env settings for control over builds, defaults to HTML case. Will also only work generally for clean builds (needs to run per-notebook to set fig options).

For dev stuff, see tests/plotly_pdf_export_test_181122.ipynb. Note that there may be better solutions here (e.g. with Panel wrapper options...?), but this is now working.

phockett commented 1 year ago

Added Holoviews/Bokeh interactive 2D plot in 77f5cf1734bd9e53f3d804539ea151435ede8d9d (theory/density matrix demo, raw cell output, didn't try glue) - this seems to break all other figures in chpt (both HTML and PDF)? Bug with maths, or issues with build chain/dependencies/fig options? May need to specify static output options for PDF?

Test notes in QM3/doc-source/tests/holoviews_render_tests_310123.ipynb - this is working OK for raw and glued Holoviews outputs in HTML format, but nothing in PDF - need to set some static options there it seems.

UPDATE 2: Now rendering also broken in tensor intro section? Issues with cached pages?

UPDATE 3: Rendering fixed after build with forced execution, PDF output now gives text describing HV object. Probably need to implement image write solution as per Plotly case here? Or pass subset of HV object to glue() (possibly display(HVobj))? For options see https://holoviews.org/user_guide/Plots_and_Renderers.html (see also MF recon notes and hvSave functionality, now in PEMtk.fit._plotters).

phockett commented 1 year ago

Now have glueDecorator() in place (see 8d9da059bdcc8bf7a3d3bf90be7b678c8b4c3bd0) for general patches. This is working for Plotly and Holoviews, PDF and HTML, per builds 09/02/23 14-03-21 version.

May still be some issues/weirdness with Plotly surfaces in some cases - TBC, but seems OK with Panel IF run early in build chain only.

TODO: further testing and tidy code.

phockett commented 1 year ago

Plotly PAD plots and formatting

Plot styles now updated in ePSproc (https://github.com/phockett/ePSproc/issues/27#issuecomment-1468435262). Need to fix HTML and static output for book. Currently appearing squashed or chopped in final outputs, so seems to be aspect and/or layout issue?

Fixes:

UPDATE: As of 017025c5c83572dde75504fde177b3a34c432ed4, allow for passing of IMGHEIGHT and IMGWIDTH to setup_notebook.py, defaults to 800x1200 landscape format. Currently set for plotly exporters in glueDecorator(), and also passed to ep.plot.hvPlotters.setPlotters(width=imgWidth, height=imgHeight).

For Plotly HTML figs are a little wider than default JBook template, but OK. For PDF figs are OK, if a little small, so may still want some tweaking of the defaults.

NOTE that defaults are set per notebook, and can't currently override for glued figures - may want to add this as an option if more control is required.

TODO: way to dynamically change height? At the moment not working well for single row PADs... but OK for double row. Should scale appropriately at build if possible. Should all be in fig['layout']? See current padPlot code, also Panel docs e.g. https://panel.holoviz.org/reference/panes/Plotly.html