Repository: plotly/plotly.py
Pull request #622 (2016-11-29 20:42:46)

Fix Plotting Error in other domains besides plot.ly
Fixing https://github.com/plotly/plotly.py/issues/621


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8a2df8177..614a26148 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,7 +2,9 @@
 All notable changes to this project will be documented in this file.
 This project adheres to [Semantic Versioning](http://semver.org/).
 
-## [Unreleased]
+## [1.12.11] - 2016-12-01
+### Fixed
+- The `link text` in the bottom right corner of the offline plots now properly displays `Export to [Domain Name]` for the given domain name set in the users' `.config` file.
 
 ## [1.12.10] - 2016-11-28
 ### Updated
diff --git a/plotly/offline/offline.py b/plotly/offline/offline.py
index 87de82dd5..103124071 100644
--- a/plotly/offline/offline.py
+++ b/plotly/offline/offline.py
@@ -211,7 +211,6 @@ def _plot_html(figure_or_data, config, validate, default_width,
     )
 
     config_clean = dict((k, config[k]) for k in configkeys if k in config)
-
     jconfig = json.dumps(config_clean)
 
     # TODO: The get_config 'source of truth' should
@@ -219,13 +218,14 @@ def _plot_html(figure_or_data, config, validate, default_width,
     plotly_platform_url = plotly.plotly.get_config().get('plotly_domain',
                                                          'https://plot.ly')
     if (plotly_platform_url != 'https://plot.ly' and
-            link_text == 'Export to plot.ly'):
+            config['linkText'] == 'Export to plot.ly'):
 
         link_domain = plotly_platform_url\
             .replace('https://', '')\
             .replace('http://', '')
-        link_text = link_text.replace('plot.ly', link_domain)
+        link_text = config['linkText'].replace('plot.ly', link_domain)
         config['linkText'] = link_text
+        jconfig = jconfig.replace('Export to plot.ly', link_text)
 
     if 'frames' in figure_or_data:
         script = '''
@@ -360,13 +360,10 @@ def iplot(figure_or_data, show_link=True, link_text='Export to plot.ly',
         display(HTML(script))
 
 
-def plot(figure_or_data,
-         show_link=True, link_text='Export to plot.ly',
-         validate=True, output_type='file',
-         include_plotlyjs=True,
-         filename='temp-plot.html', auto_open=True,
-         image=None, image_filename='plot_image',
-         image_width=800, image_height=600):
+def plot(figure_or_data, show_link=True, link_text='Export to plot.ly',
+         validate=True, output_type='file', include_plotlyjs=True,
+         filename='temp-plot.html', auto_open=True, image=None,
+         image_filename='plot_image', image_width=800, image_height=600):
     """ Create a plotly graph locally as an HTML document or string.
 
     Example:
diff --git a/plotly/version.py b/plotly/version.py
index dca340c2c..e55c47af9 100644
--- a/plotly/version.py
+++ b/plotly/version.py
@@ -1,1 +1,1 @@
-__version__ = '1.12.10'
+__version__ = '1.12.11'


Test patch:
diff --git a/plotly/tests/test_core/test_offline/test_offline.py b/plotly/tests/test_core/test_offline/test_offline.py
index 34684322e..f845709a2 100644
--- a/plotly/tests/test_core/test_offline/test_offline.py
+++ b/plotly/tests/test_core/test_offline/test_offline.py
@@ -6,6 +6,7 @@ from __future__ import absolute_import
 
 from nose.tools import raises
 from unittest import TestCase
+from plotly.tests.utils import PlotlyTestCase
 import json
 
 import plotly
@@ -21,6 +22,7 @@ fig = {
 
 PLOTLYJS = plotly.offline.offline.get_plotlyjs()
 
+
 class PlotlyOfflineTestCase(TestCase):
     def setUp(self):
         pass
@@ -78,3 +80,23 @@ class PlotlyOfflineTestCase(TestCase):
         })
         for resize_code_string in resize_code_strings:
             self.assertTrue(resize_code_string not in html)
+
+
+class PlotlyOfflineOtherDomainTestCase(PlotlyTestCase):
+    def setUp(self):
+        super(PlotlyOfflineOtherDomainTestCase, self).setUp()
+        plotly.tools.set_config_file(plotly_domain='https://stage.plot.ly',
+                                     plotly_api_domain='https://api-stage.plot.ly')
+        plotly.plotly.sign_in('PlotlyTestShark', 'kI2H0E7sTZ5RM9yoaK4X')
+
+    def test_plot_rendered_if_non_plotly_domain(self):
+        html = plotly.offline.plot(fig, output_type='div')
+
+        # test that 'Export to stage.plot.ly' is in the html
+        self.assertTrue('Export to stage.plot.ly' in html)
+
+    def tearDown(self):
+        plotly.tools.set_config_file(plotly_domain='https://plot.ly',
+                                     plotly_api_domain='https://api.plot.ly')
+        plotly.plotly.sign_in('PythonTest', '9v9f20pext')
+        super(PlotlyOfflineOtherDomainTestCase, self).tearDown()