Python Dev

Avoid to open graph in web browser in case of plot in plotly

Share this for your friends.

Avoid to open graph in web browser in case of plot in plotly

Avoid to open graph in web browser in case of plot in plotly.

When you make some graph with using plotly, you may think above.
In this article, I will show you how to make graph without opening it.


What is plotly

Plotly is one of python graphing library.
If you search how to visualize data, you will find Matplotlib.
Plotly may be the second most famous library.

Matplotlib makes light image file for visualizing.
Plotly generates rich HTML graph.


Why avoiding to open graph

If you execute plot with using plotly, it makes HTML graph and open it in web browser.
If there is one graph, it is OK.
But if you have a lot of data to be visualized, plotly will open a lot of graph.
It will use huge memory.


Make graph without open

Answer is written in the document.

plotly.offline.plot({
    "data": [go.Scatter(x=[1, 2, 3, 4], y=[4, 3, 2, 1])],
    "layout": go.Layout(title="hello world")
}, auto_open=True)

So instead of auto_open=True, put auto_open=False.


Finally

In order to make graph without opening it, you must set auto_open=False.



Share this for your friends.

If you felt this article is useful, please share.

にほんブログ村 IT技術ブログへ

-Python, Dev
-,

© 2024 ITips