|
14 | 14 |
|
15 | 15 | import plotly
|
16 | 16 | from plotly import tools, utils
|
17 |
| -from plotly.exceptions import PlotlyError |
18 | 17 |
|
| 18 | +import IPython |
| 19 | +from IPython.display import HTML, display |
19 | 20 |
|
20 |
| -try: |
21 |
| - import IPython |
22 |
| - _ipython_imported = True |
23 |
| -except ImportError: |
24 |
| - _ipython_imported = False |
25 |
| - |
26 |
| -try: |
27 |
| - import matplotlib |
28 |
| - _matplotlib_imported = True |
29 |
| -except ImportError: |
30 |
| - _matplotlib_imported = False |
31 |
| - |
32 |
| - |
33 |
| -__PLOTLY_OFFLINE_INITIALIZED = False |
| 21 | +import matplotlib |
34 | 22 |
|
35 | 23 |
|
36 | 24 | def download_plotlyjs(download_url):
|
@@ -79,21 +67,13 @@ def init_notebook_mode():
|
79 | 67 | to load the necessary javascript files for creating
|
80 | 68 | Plotly graphs with plotly.offline.iplot.
|
81 | 69 | """
|
82 |
| - if not tools._ipython_imported: |
83 |
| - raise ImportError('`iplot` can only run inside an IPython Notebook.') |
84 |
| - from IPython.display import HTML, display |
85 |
| - |
86 |
| - global __PLOTLY_OFFLINE_INITIALIZED |
87 |
| - if not __PLOTLY_OFFLINE_INITIALIZED: |
88 |
| - display(HTML("<script type='text/javascript'>" + |
89 |
| - "define('plotly', function(require, exports, module) {" + |
90 |
| - get_plotlyjs() + |
91 |
| - "});" + |
92 |
| - "require(['plotly'], function(Plotly) {" + |
93 |
| - "window.Plotly = Plotly;" + |
94 |
| - "});" + |
95 |
| - "</script>")) |
96 |
| - __PLOTLY_OFFLINE_INITIALIZED = True |
| 70 | + warnings.warn(''' |
| 71 | + `init_notebook_mode` is deprecated and will be removed in the |
| 72 | + next release. Notebook mode is now automatically initialized when |
| 73 | + notebook methods are invoked, so it is no |
| 74 | + longer necessary to manually initialize. |
| 75 | + ''', DeprecationWarning) |
| 76 | + pass |
97 | 77 |
|
98 | 78 |
|
99 | 79 | def _plot_html(figure_or_data, show_link, link_text,
|
@@ -433,11 +413,9 @@ def iplot_mpl(mpl_fig, resize=False, strip_style=False,
|
433 | 413 |
|
434 | 414 | Example:
|
435 | 415 | ```
|
436 |
| - from plotly.offline import init_notebook_mode, iplot_mpl |
| 416 | + from plotly.offline import iplot_mpl |
437 | 417 | import matplotlib.pyplot as plt
|
438 | 418 |
|
439 |
| - init_notebook_mode() |
440 |
| -
|
441 | 419 | fig = plt.figure()
|
442 | 420 | x = [10, 15, 20, 25, 30]
|
443 | 421 | y = [100, 250, 200, 150, 300]
|
@@ -468,10 +446,9 @@ def enable_mpl_offline(resize=False, strip_style=False,
|
468 | 446 |
|
469 | 447 | Example:
|
470 | 448 | ```
|
471 |
| - from plotly.offline import init_notebook_mode, enable_mpl_offline |
| 449 | + from plotly.offline import enable_mpl_offline |
472 | 450 | import matplotlib.pyplot as plt
|
473 | 451 |
|
474 |
| - init_notebook_mode() |
475 | 452 | enable_mpl_offline()
|
476 | 453 |
|
477 | 454 | fig = plt.figure()
|
|
0 commit comments