Comments (6)
Plotly can be used in Jinja Markdown (Markdown with Python variables) this way:
Cell 1:
import plotly.express as px
fig = px.bar(x=["a", "b", "c"], y=[1, 3, 2])
Cell 2:
%%jmd
Texts
{{ fig.to_html(include_plotlyjs=False) }}
With plot between them
Alternatively we can use “cdn” instead of False to load from online.
This way ensures interactivity after export using Pretty Jupyter. Also the outputted plot is shown in the JupyterLab as well.
Other environments, such as Jupyter Notebook or Visual Studio Code, have a problem with displaying plotly graphs this way. They just aren't rendering the outputted HTML. Hence on those platforms (vscode, jupyter notebook, NOT jupyterlab) if you combine markdown and Python variables, you won't see the outputted plot in the IDE, just in the exported notebook. To display the plot, this works in all environments: fig.show(renderer="browser")
(fig.show(renderer="iframe")
can also be considered).
So for Pretty Jupyter the best way is to create html and render that. This works works best in JupyterLab. In other environments, you can still use it. It won't be visible in the IDE, but you can view the plot e.g. with fig.show(renderer="browser")
.
from pretty-jupyter.
Hello,
Thank you, I'm glad you like it. I believe that plotly is already supported.
I'm one hundred percent sure that plotly.offline.plot
works. You can create html using this function and then just print it, for example using Jinja Markdown like this: {{ plotly.offline.plot(fig, include_plotlyjs=False, output_type='div') }}
.
I'll check out other methods too and add it to the examples. However, generally, it is possible.
from pretty-jupyter.
It seems to be a bit deeper issue than I previously suspected. I will add support it for the following:
- Plotly graph needs to be viewable in Jupyter. Ideally for both Jinja Markdown and normal code cells.
- Plotly graph needs to be working after export to HTML. It must be available without internet load.
from pretty-jupyter.
Cool! I will try. Thank you!
from pretty-jupyter.
@fyenne I improve the support in a new version 1.2.4. Now dynamic graphs are supported as well as they are in default nbconvert. I tested it for plotly and highchart both (python-highchart package). I added example with plotly to the example here: https://github.com/JanPalasek/pretty-jupyter-examples/tree/main/main-features-demo .
You can use also fig.show()
(without any parameter) and it will be shown in any IDE (jupyter, jupyterlab, vs code) and it will be also shown in the exported html by pretty-jupyter.
from pretty-jupyter.
thank you~
from pretty-jupyter.
Related Issues (20)
- Add options to TOC
- Export to pdf
- Add optional dependencies
- Metadata
- Section numbering HOT 1
- Create templates HOT 2
- 2.0.0 HOT 1
- Future work
- Not properly nesting TOC HOT 3
- Itables HOT 1
- Button to download jupyter/open in colab? HOT 3
- <Tabsets> and <nbconvert --embed-images> can't be used together when exporting notebooks to html reports HOT 6
- Investigate blank space at the end HOT 5
- Errorneous table of content HOT 4
- pretty-jupyter compatible with SoS notebooks? HOT 2
- CI Fix HOT 1
- Table of contents (toc) does not show HOT 7
- ImportError: No module named RemoveInputPreprocessor for 2.0.0 above HOT 2
- pinned nbconvert 6 dependency HOT 1
- Create "hidden" Markdowns
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pretty-jupyter.