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

interactive plot doesn't seem to work #197

Closed
researcherofreality opened this issue Nov 11, 2024 · 4 comments
Closed

interactive plot doesn't seem to work #197

researcherofreality opened this issue Nov 11, 2024 · 4 comments

Comments

@researcherofreality
Copy link

researcherofreality commented Nov 11, 2024

I tried making an interactive plot but didn't work.

Running the following, given in the example:

`import cebra

import numpy as np

X = np.random.uniform(0, 1, (100, 50))

y = np.random.uniform(0, 10, (100, 5))

cebra_model = cebra.CEBRA(max_iterations=10)

cebra_model.fit(X, y)

embedding = cebra_model.transform(X)

cebra_time = np.arange(X.shape[0])

plt.figure(figsize=((10,8)))

fig = cebra.plot_embedding_interactive(embedding, embedding_labels=cebra_time)`

returns <Figure size 500x500 with 0 Axes>. I have plotly installed, so not sure what the issue might be.

@researcherofreality
Copy link
Author

researcherofreality commented Nov 11, 2024

Woops, sorry for this.

It worked for one plot - why I closed the issue - but now it seems to have stopped plotting. It just returns the same output as before.

I was running it from a jupyter notebook and there it plotted just once. running it from the command line in python it does return the figure details but doesn't actually plot.

Any help :)?

@CeliaBenquet
Copy link
Member

Hi @researcherofreality,
You're right that the code in the example doesn't plot the interactive plot as it only creates the plot and "store" it in the fig variable.

To be able to visualize the plot, you can either:

  • add the line fig.show() after your code and you can remove plt.figure(figsize=((10,8))).
  • remove the fig= part and just have cebra.plot_embedding_interactive(embedding, embedding_labels=cebra_time) as the last line of your cell and you can remove plt.figure(figsize=((10,8))).
  • if you want to add axes, etc and keep plt.figure(figsize=((10,8))), you need to pass the figure to the function, that would be something like:
fig, ax = plt.subplots(1, 1, figsize=(10, 8))
ax = cebra.plot_embedding_interactive(embedding, embedding_labels=cebra_time, axis=ax)
# [...]
fig.show()

Let me know if that works for you, from the code you provided, I get that -- really sparse but interactive 😉 -- embedding.
Screenshot 2024-12-16 at 16 42 25

@researcherofreality
Copy link
Author

Great, thank you for the help!

@CeliaBenquet
Copy link
Member

I will close the issue if that solved it for you 😉 Thanks for using CEBRA! 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants