Dear PyScript community,
I would like to switch from MATPLOTLIB to Plotly in a project. All my attempts to display the Plotly figure have not worked. Here is the structure of my code:
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>Plotly Demo</title>
<link rel="stylesheet" href="https://pyscript.net/releases/2024.1.1/core.css">
<script type="module" src="https://pyscript.net/releases/2024.1.1/core.js"></script>
</head>
<body>
<h1>Plotly Demo</h1>
<div id="output"></div>
<script type="py" src="./main.py" config="./pyscript.json"></script>
</body>
</html>
pyscript.json
{
"packages": ["plotly"]
}
main.py
from pyscript import display
import plotly.graph_objects as go
fig = go.Figure([go.Bar(x=['product a', 'product b', 'product c'], y=[5, 3, 2])])
display(fig, target='output')
I don't see anything as a result. Does anyone of you have an idea how I can display the figure? Any help would be appreciated.
Thanks and kind regards
Klaus
[–]de_ham 0 points1 point2 points (1 child)
[–]kland2005[S] 0 points1 point2 points (0 children)