matplotlib / matplotlib/ipympl
Using ipympl logic inside python shell or ipython?
Personne n'a encore pris cette issue.
- Langage dominant
- Jupyter Notebook
- Étoiles
- 1.7k
- Forks
- 234
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
I have a class that inherits from the ipywidgets.widgets.VBox and adds a figure.canvas instance of a matplotlib figure to its children like so:
import matplotlib.pyplot as plt
from ipywidgets import widgets
plt.ioff()
class MyVis(widgets.VBox):
def __init__(self):
super().__init__()
self.fig = plt.figure()
self.children = [self.fig.canvas]
m = MyVis()
This works fine when I use this class within jupyter notebooks using the %matplotlib widget magic before executing the above code.
When executed within ipython I get
TraitError: Element of the 'children' trait of a MyVis instance must be a Widget, but a value of <matplotlib.backends.backend_tkagg.FigureCanvasTkAgg object at 0x7f0c48d731d0> <class 'matplotlib.backends.backend_tkagg.FigureCanvasTkAgg'> was specified.
since of course ipympl and its magic are not active.
Since I also want to have unit-tests for this class (and others that make use of this class) using pytest, it would be nice to get around this problem.
Can I enable the ipympl way of handling figures somehow in the python shell (similar to using the %matplotlib widget magic in the notebook) that would allow my tests to run?
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par l’exemple MyVis et reproduisez le TraitError dans IPython, puis comparez-le avec la configuration du notebook utilisant le magic %matplotlib widget. Vérifiez comment le canvas matplotlib est sélectionné et déterminez quelle configuration de test permettrait aux cas pytest d’utiliser un canvas widget compatible en dehors de Jupyter ; le travail est considéré comme terminé lorsque la classe peut être instanciée et testée sans l’erreur du canvas Tk.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- jupyter, python
- Domaine
- backend, testing
- Type d'issue
- Fonctionnalité
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 28/100