jordo45
jordo45β€’10mo ago

3d matplotlib

has anyone tried a 3d matplotlib plot with mo.mpl.interactive(plt.gcf()) ? I get an infinitely growing PNG πŸ€”
3 Replies
Myles Scolnick
Myles Scolnickβ€’10mo ago
Can you paste a minimal example of it failing?
jordo45
jordo45OPβ€’10mo ago
import marimo

__generated_with = "0.2.4"
app = marimo.App(width="full")


@app.cell
def __():
import marimo as mo
import matplotlib.pyplot as plt
return mo, plt


@app.cell
def __(plt):
fig = plt.figure()
ax = fig.add_subplot(projection='3d')

ax.scatter([0, 1], [1, 2], [3, 4])
return ax, fig


@app.cell
def __():
mo.mpl.interactive(ax)
return


if __name__ == "__main__":
app.run()
import marimo

__generated_with = "0.2.4"
app = marimo.App(width="full")


@app.cell
def __():
import marimo as mo
import matplotlib.pyplot as plt
return mo, plt


@app.cell
def __(plt):
fig = plt.figure()
ax = fig.add_subplot(projection='3d')

ax.scatter([0, 1], [1, 2], [3, 4])
return ax, fig


@app.cell
def __():
mo.mpl.interactive(ax)
return


if __name__ == "__main__":
app.run()
I'm seeing this is probably environment related, since it works on my personal machine
{
"marimo": "0.2.4",
"OS": "Linux",
"OS Version": "5.4.0-169-generic",
"Processor": "x86_64",
"Python Version": "3.8.10",
"Binaries": {
"Chrome": "117.0.5938.149",
"Node": "--"
},
"Requirements": {
"black": "23.3.0",
"click": "8.1.3",
"jedi": "0.18.2",
"pymdown-extensions": "10.7",
"starlette": "0.27.0",
"tomlkit": "0.12.3",
"typing_extensions": "4.7.1",
"uvicorn": "0.23.2"
}
}
{
"marimo": "0.2.4",
"OS": "Linux",
"OS Version": "5.4.0-169-generic",
"Processor": "x86_64",
"Python Version": "3.8.10",
"Binaries": {
"Chrome": "117.0.5938.149",
"Node": "--"
},
"Requirements": {
"black": "23.3.0",
"click": "8.1.3",
"jedi": "0.18.2",
"pymdown-extensions": "10.7",
"starlette": "0.27.0",
"tomlkit": "0.12.3",
"typing_extensions": "4.7.1",
"uvicorn": "0.23.2"
}
}
it works with plotly instead of matplotlib.
Myles Scolnick
Myles Scolnickβ€’10mo ago
What is the main differences between your two environments? Plotly is better in my opinion since it’s easier to share as a static page (matplotlib interactive requires a server)