Vous avez besoin de pandas>=0.25 pour modifier le backend de traçage de pandas.
Les backends de traçage disponibles sont :
- matplotlib
- hvplot>=0.5.1
- holoviews
- pandas_bokeh
- intrigue>=4.8
- altaïr
Ainsi, le paramètre par défaut est :
pd.options.plotting.backend = 'matplotlib'
Vous pouvez modifier la bibliothèque de traçage utilisée par pandas comme suit. Dans ce cas, il définit hvplot / holoviews comme moteur de traçage :
pd.options.plotting.backend = 'hvplot'
Ou vous pouvez également utiliser (ce qui revient essentiellement au même) :
pd.set_option('plotting.backend', 'hvplot')
Maintenant, vous avez hvplot / holoviews comme moteur de traçage pour pandas et cela vous donnera des tracés holoviews interactifs au lieu de tracés matplotlib statiques.
Bien sûr, vous devez avoir installé la bibliothèque hvplot / holoviews + dépendances pour que cela fonctionne.
Voici un exemple de code résultant en un tracé interactif. Il utilise la syntaxe pandas standard .plot() :
import numpy as np
import pandas as pd
import hvplot
import hvplot.pandas
pd.options.plotting.backend = 'hvplot'
data = np.random.normal(size=[50, 2])
df = pd.DataFrame(data, columns=['x', 'y'])
df.plot(kind='scatter', x='x', y='y')
À partir de plotly 4.8.0, vous pouvez utiliser plotly pour le traçage interactif avec pandas 1.0+.
Mettre à jour avec pip install -U plotly
Définissez le backend de traçage sur plotly :
pd.options.plotting.backend = "plotly"
df = pd.DataFrame(dict(a=[1, 2, 3], b=[2, 4, 6]))
df.plot()
Voici l'annonce