Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mo.mpl.interactive doesn't work #252

Closed
proItheus opened this issue Oct 25, 2023 · 5 comments
Closed

mo.mpl.interactive doesn't work #252

proItheus opened this issue Oct 25, 2023 · 5 comments
Labels
bug Something isn't working

Comments

@proItheus
Copy link

Describe the bug

It's just blank.
Screenshot_20231026_000211

Version

0.1.36

Code to reproduce

import marimo

__generated_with = "0.1.36"
app = marimo.App()


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


@app.cell
def __(np):
    x=np.linspace(0,1,20)
    return x,


@app.cell
def __(plt, x):
    plt.plot(x,x)
    return


@app.cell
def __(mo, plt):
    mo.mpl.interactive(plt.gcf())
    return


if __name__ == "__main__":
    app.run()
@proItheus proItheus added the bug Something isn't working label Oct 25, 2023
@akshayka
Copy link
Contributor

Hey, thanks for opening.

Each cell gets its own figure for the imperative API. So in your last cell, plt.gcf() returns an empty figure. We can add this to the documentation.

  • You could combine the plotting cell and the cell that uses mpl.interactive.
  • Or you could use the object oriented API and grab the axis object.

Let me know if they look ok to you.

Two options below.

import marimo

__generated_with = "0.1.36"
app = marimo.App()


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


@app.cell
def __(np):
    x=np.linspace(0,1,20)
    return x,


@app.cell
def __(mo, plt, x):
    plt.plot(x,x)
    mo.mpl.interactive(plt.gcf())
    return


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

This should also work:

import marimo

__generated_with = "0.1.36"
app = marimo.App()


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


@app.cell
def __(np):
    x=np.linspace(0,1,20)
    return x,


@app.cell
def __(plt, x):
    plt.plot(x, x)
    ax = plt.gca()
    return ax,


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


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

@proItheus
Copy link
Author

Well, not exactly. It is no longer blank, but still have some weird behavior.
plot.webm

@akshayka
Copy link
Contributor

Oh weird. @mscolnick could this have to do with iframe resizing?

@mscolnick
Copy link
Contributor

@proItheus, i am unable to reproduce it. on my computer the interactive plot takes up the full size it is given.

couple questions that could help us:

  • what browser are you using
  • what version of matplotlib

thanks

@proItheus
Copy link
Author

Well, I realized I have enabled privacy.resistFingerprinting in firefox. When this switch is turned off, it works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants