holtzy / The-Python-Graph-Gallery

A website displaying hundreds of charts made with Python
https://www.python-graph-gallery.com
BSD Zero Clause License
1.89k stars 372 forks source link

matplotlib to plotly converter !!!! ggplotly in python #474

Closed JosephBARBIERDARNAL closed 2 weeks ago

JosephBARBIERDARNAL commented 1 month ago
import matplotlib.pyplot as plt
import numpy as np

fig, ax = plt.subplots()
x = np.linspace(0, 10)
ax.plot(x, np.sin(x), '--', linewidth=2)
ax.plot(x, np.cos(x), '--', linewidth=2)
ax.text(x=0.5, y=0.8, s='hello world')

import plotly.graph_objs as go
import plotly.tools as tls
plotly_fig = tls.mpl_to_plotly(fig)
plotly_fig['layout']['showlegend'] = True
fig = go.Figure(plotly_fig)
fig.show()
JosephBARBIERDARNAL commented 2 weeks ago

not that good actually