internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: plotly/plotly.py

Issue:
plotlyServerURL config option overridden by plotly_domain from ~/.plotly/.config
Setting plotlyServerURL in the config dict passed to iplot will always create a plot where the "Edit in Chart Studio" button sends the plot to the base url defined by plotly_domain. 

This code won't change the plotly url used by the "Edit in Chart Studio" button
```python
import plotly.offline as py
import plotly.graph_objs as go
py.init_notebook_mode()

py.iplot([go.Scatter(y=[2,3,4])], config=dict(showSendToCloud = True, plotlyServerURL='https://myserver.com'))
```

and this code will

```python
import plotly.offline as py
import plotly.graph_objs as go
import plotly.tools as tls
py.init_notebook_mode()

tls.set_config_file(plotly_domain='https://www.myserver.com')
py.iplot([go.Scatter(y=[2,3,4])], config=dict(showSendToCloud = True))
```

I think it would be good to add a check to see if plotlyServerURL is already present in the config dict before setting it to plotly_domain ([relevant code](https://github.com/plotly/plotly.py/blob/d0950b8085d26c2025333f0114c419b70e8391fc/plotly/offline/offline.py#L158-L164)).


Discussion:

Resolving patch:
diff --git a/plotly/offline/offline.py b/plotly/offline/offline.py
--- a/plotly/offline/offline.py
+++ b/plotly/offline/offline.py
@@ -161,7 +161,8 @@ def _get_jconfig(config):
 
     plotly_platform_url = plotly.tools.get_config_plotly_server_url()
 
-    clean_config['plotlyServerURL'] = plotly_platform_url
+    if not clean_config.get('plotlyServerURL', None):
+        clean_config['plotlyServerURL'] = plotly_platform_url
 
     if (plotly_platform_url != 'https://plot.ly' and
         clean_config.get('linkText', None) == 'Export to plot.ly'):


Test patch:
Repository: plotly/plotly.py

Issue:
Documentation for `_set_trace_grid_reference` from plotly.subplots.py mentions `plotly.subplots.make_subplot`, which does not exist
Line 1336 from plotly.subplots.py reads
```
See the docstring for the specs argument to plotly.subplots.make_subplot 
```

Minor issue, but this is meant to be `plotly.subplots.make_subplots` (with an `s` at the end). I was rather confused when I got the above message in an error, typed `help(plotly.subplots.make_subplot)`, only to be told it doesn't exist


Discussion:

Resolving patch:
diff --git a/packages/python/plotly/plotly/subplots.py b/packages/python/plotly/plotly/subplots.py
--- a/packages/python/plotly/plotly/subplots.py
+++ b/packages/python/plotly/plotly/subplots.py
@@ -1333,7 +1333,7 @@ def _set_trace_grid_reference(trace, layout, grid_ref, row, col, secondary_y=Fal
 Trace type '{typ}' is not compatible with subplot type '{subplot_type}'
 at grid position ({row}, {col}) 
 
-See the docstring for the specs argument to plotly.subplots.make_subplot 
+See the docstring for the specs argument to plotly.subplots.make_subplots 
 for more information on subplot types""".format(
                     typ=trace.type,
                     subplot_type=subplot_refs[0].subplot_type,


Test patch:
Repository: plotly/plotly.py

Issue:
Python 2.7 incompatibility in the iframe renderer
Plotly with python 2.7 fails when using the `iframe` renderer, due to a Python 3 call to os.makedirs with the exist_ok flag.

Minimum failing example:
`import plotly.graph_objects as go
fig = go.Figure(
    data=[go.Bar(y=[2, 1, 3])],
    layout_title_text="A Figure Displayed with the 'png' Renderer"
)
fig.show(renderer="iframe")`



Discussion:

Resolving patch:
diff --git a/packages/python/plotly/codegen/utils.py b/packages/python/plotly/codegen/utils.py
--- a/packages/python/plotly/codegen/utils.py
+++ b/packages/python/plotly/codegen/utils.py
@@ -6,6 +6,7 @@
 from io import StringIO
 from typing import List
 import re
+import errno
 
 
 # Source code utilities
@@ -30,7 +31,11 @@ def write_source_py(py_source, filepath, leading_newlines=0):
         # Make dir if needed
         # ------------------
         filedir = opath.dirname(filepath)
-        os.makedirs(filedir, exist_ok=True)
+        try:
+            os.makedirs(filedir)
+        except OSError as error:
+            if error.errno != errno.EEXIST:
+                raise
 
         # Write file
         # ----------
diff --git a/packages/python/plotly/plotly/io/_base_renderers.py b/packages/python/plotly/plotly/io/_base_renderers.py
--- a/packages/python/plotly/plotly/io/_base_renderers.py
+++ b/packages/python/plotly/plotly/io/_base_renderers.py
@@ -4,6 +4,7 @@
 import webbrowser
 import inspect
 import os
+import errno
 
 import six
 from plotly.io import to_json, to_image, write_image, write_html
@@ -564,7 +565,11 @@ def to_mimebundle(self, fig_dict):
         filename = self.build_filename()
 
         # Make directory for
-        os.makedirs(self.html_directory, exist_ok=True)
+        try:
+            os.makedirs(self.html_directory)
+        except OSError as error:
+            if error.errno != errno.EEXIST:
+                raise
 
         write_html(
             fig_dict,


Test patch:
Repository: plotly/plotly.py

Issue:
Does Plotly 4.2.0 depend on scikit-image?
I failed to `import plotly.figure_factory` because plotly seems not to install `scikit-image` when running `pip install -U plotly`. After I manually installed `scikit-image`, `import plotly.figure_factory` worked.

This was not a problem in version 4.1.1.

But the source code shows it depends on it.
https://github.com/plotly/plotly.py/blob/b7ad5433c4e0882715781fa6c4816fc7fff62965/packages/python/plotly/plotly/figure_factory/_ternary_contour.py#L11


Discussion:
One of our figure factories depends on scikit-image, yes, but not the library as a whole.
Related: #1829
So the answer is that in 4.2 we accidentally made all figure factories depend on scikit-image, rather than just the one that needs it, and we'll fix that.

Resolving patch:
diff --git a/packages/python/plotly/plotly/express/__init__.py b/packages/python/plotly/plotly/express/__init__.py
--- a/packages/python/plotly/plotly/express/__init__.py
+++ b/packages/python/plotly/plotly/express/__init__.py
@@ -2,6 +2,16 @@
 `plotly_express` is a terse, consistent, high-level wrapper around `plotly` for rapid \
 data exploration and figure generation. See the gallery at https://plotly.github.io/plotly_express
 """
+from __future__ import absolute_import
+from plotly import optional_imports
+
+pd = optional_imports.get_module("pandas")
+if pd is None:
+    raise ImportError(
+        """\
+Plotly express requires pandas to be installed."""
+    )
+
 
 from ._chart_types import (  # noqa: F401
     scatter,
diff --git a/packages/python/plotly/plotly/figure_factory/__init__.py b/packages/python/plotly/plotly/figure_factory/__init__.py
--- a/packages/python/plotly/plotly/figure_factory/__init__.py
+++ b/packages/python/plotly/plotly/figure_factory/__init__.py
@@ -24,18 +24,31 @@
 from plotly.figure_factory._scatterplot import create_scatterplotmatrix
 from plotly.figure_factory._streamline import create_streamline
 from plotly.figure_factory._table import create_table
-from plotly.figure_factory._ternary_contour import create_ternary_contour
 from plotly.figure_factory._trisurf import create_trisurf
 from plotly.figure_factory._violin import create_violin
 
 if optional_imports.get_module("pandas") is not None:
     from plotly.figure_factory._county_choropleth import create_choropleth
+else:
+
+    def create_choropleth(*args, **kwargs):
+        raise ImportError("Please install pandas to use `create_choropleth`")
+
+
+if optional_imports.get_module("skimage") is not None:
+    from plotly.figure_factory._ternary_contour import create_ternary_contour
+else:
+
+    def create_ternary_contour(*args, **kwargs):
+        raise ImportError("Please install scikit-image to use `create_ternary_contour`")
+
 
 __all__ = [
     "create_2d_density",
     "create_annotated_heatmap",
     "create_bullet",
     "create_candlestick",
+    "create_choropleth",
     "create_dendrogram",
     "create_distplot",
     "create_facet_grid",


Test patch:
Repository: plotly/plotly.py

Issue:
Clarify work with external server
I started orca as shown here: https://github.com/plotly/orca#method-3-docker
So I got it on 9091 port on localhost accessible

I've installed plotly==4.3.0 with latest "feature" from #1850 

Now, when running following code, I get two terminal screens of errors and cool stories about how to install that orca executable, which I actually should not have to keep in my host system when using orca *server*:
```
import plotly.io as pio
import plotly.graph_objects as go
pio.orca.config.server_url = "localhost"
pio.orca.config.port = 9091
pio.to_image(go.Figure())
```

Could you _please_ clarify, how to use that new feature? since for now it is just useless without binary in PATH.


Discussion:
Please try including the port directly in server_url, such as "localhost:9091"

The port field is intended for use with a locally managed server, and setting will override the server_url field
Thanks @miriad for such quick answer!

However, with following lines
```
import plotly.io as pio
import plotly.graph_objects as go
pio.orca.config.server_url = "http://localhost:9091"
pio.to_image(go.Figure())
```

I still get completely the same output with the same errors. 
Attaching traceback for a better understanding of what is happening:
```
>>> pio.to_image(go.Figure())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ns.ops/.local/share/virtualenvs/project-BSL7RaPy/lib/python3.6/site-packages/plotly/io/_orca.py", line 1533, in to_image
    ensure_server()
  File "/home/ns.ops/.local/share/virtualenvs/project-BSL7RaPy/lib/python3.6/site-packages/plotly/io/_orca.py", line 1389, in ensure_server
    validate_executable()
  File "/home/ns.ops/.local/share/virtualenvs/project-BSL7RaPy/lib/python3.6/site-packages/plotly/io/_orca.py", line 1087, in validate_executable
    instructions=install_location_instructions,
ValueError: 
The orca executable is required to export figures as static images,
but it could not be found on the system path.

...
```

Resolving patch:
diff --git a/packages/python/plotly/plotly/io/_orca.py b/packages/python/plotly/plotly/io/_orca.py
--- a/packages/python/plotly/plotly/io/_orca.py
+++ b/packages/python/plotly/plotly/io/_orca.py
@@ -1384,11 +1384,10 @@ def ensure_server():
 """
         )
 
-    # Validate orca executable
-    if status.state == "unvalidated":
-        validate_executable()
-
     if not config.server_url:
+        # Validate orca executable only if server_url is not provided
+        if status.state == "unvalidated":
+            validate_executable()
         # Acquire lock to make sure that we keep the properties of orca_state
         # consistent across threads
         with orca_lock:


Test patch:
Repository: plotly/plotly.py

Issue:
PX docstrings and `data_frame`
Right now all the PX doctrings talk about "rows of `data_frame`" but this is a bit out of date with respect to input formats. We should update it somehow, perhaps with a note that `data_frame`, while technically optional, gets constructed under the hood if you pass in array-like objects.


Discussion:

Resolving patch:
diff --git a/packages/python/plotly/plotly/express/_doc.py b/packages/python/plotly/plotly/express/_doc.py
--- a/packages/python/plotly/plotly/express/_doc.py
+++ b/packages/python/plotly/plotly/express/_doc.py
@@ -22,6 +22,7 @@
         "DataFrame or array-like or dict",
         "This argument needs to be passed for column names (and not keyword names) to be used.",
         "Array-like and dict are tranformed internally to a pandas DataFrame.",
+        "Optional: if missing, a DataFrame gets constructed under the hood using the other arguments.",
     ],
     x=[
         colref_type,


Test patch:
Repository: plotly/plotly.py

Issue:
PX facet labels don't respect labels kwarg
```python
px.scatter(tips, x="total_bill", y="tip", facet_row="time",  facet_col="day", 
          labels={"time": "THE TIME", "day": "THE DAY"})
```

![image](https://user-images.githubusercontent.com/203523/70057695-94e75180-15ab-11ea-8643-1579ceedbc03.png)

Reported in https://github.com/plotly/plotly_express/pull/164


Discussion:

Resolving patch:
diff --git a/packages/python/plotly/plotly/express/_core.py b/packages/python/plotly/plotly/express/_core.py
--- a/packages/python/plotly/plotly/express/_core.py
+++ b/packages/python/plotly/plotly/express/_core.py
@@ -1267,7 +1267,9 @@ def make_figure(args, constructor, trace_patch={}, layout_patch={}):
                 if m.facet == "row":
                     row = m.val_map[val]
                     if args["facet_row"] and len(row_labels) < row:
-                        row_labels.append(args["facet_row"] + "=" + str(val))
+                        row_labels.append(
+                            get_label(args, args["facet_row"]) + "=" + str(val)
+                        )
                 else:
                     if (
                         bool(args.get("marginal_x", False))
@@ -1282,7 +1284,9 @@ def make_figure(args, constructor, trace_patch={}, layout_patch={}):
                 if m.facet == "col":
                     col = m.val_map[val]
                     if args["facet_col"] and len(col_labels) < col:
-                        col_labels.append(args["facet_col"] + "=" + str(val))
+                        col_labels.append(
+                            get_label(args, args["facet_col"]) + "=" + str(val)
+                        )
                     if facet_col_wrap:  # assumes no facet_row, no marginals
                         row = 1 + ((col - 1) // facet_col_wrap)
                         col = 1 + ((col - 1) % facet_col_wrap)


Test patch:
diff --git a/packages/python/plotly/plotly/tests/test_core/test_px/test_px.py b/packages/python/plotly/plotly/tests/test_core/test_px/test_px.py
--- a/packages/python/plotly/plotly/tests/test_core/test_px/test_px.py
+++ b/packages/python/plotly/plotly/tests/test_core/test_px/test_px.py
@@ -53,6 +53,30 @@ def test_custom_data_scatter():
     )
 
 
+def test_labels():
+    tips = px.data.tips()
+    fig = px.scatter(
+        tips,
+        x="total_bill",
+        y="tip",
+        facet_row="time",
+        facet_col="day",
+        color="size",
+        symbol="sex",
+        labels={c: c[::-1] for c in tips.columns},
+    )
+    assert "xes" in fig.data[0].hovertemplate
+    assert "llib_latot" in fig.data[0].hovertemplate
+    assert "ezis" in fig.data[0].hovertemplate
+    assert "yad" in fig.data[0].hovertemplate
+    assert "emit" in fig.data[0].hovertemplate
+    assert fig.data[0].name.startswith("xes")
+    assert fig.layout.xaxis.title.text == "llib_latot"
+    assert fig.layout.coloraxis.colorbar.title.text == "ezis"
+    assert fig.layout.annotations[0].text.startswith("yad")
+    assert fig.layout.annotations[4].text.startswith("emit")
+
+
 def test_px_templates():
     import plotly.io as pio
     import plotly.graph_objects as go
Repository: plotly/plotly.py

Issue:
plotly.figure_factory._gantt.py.validate_gantt uses deprecated .ix
This gives the warning:
```
.ix is deprecated. Please use
.loc for label based indexing or
.iloc for positional indexing
```


Discussion:

Resolving patch:
diff --git a/packages/python/plotly/plotly/figure_factory/_gantt.py b/packages/python/plotly/plotly/figure_factory/_gantt.py
--- a/packages/python/plotly/plotly/figure_factory/_gantt.py
+++ b/packages/python/plotly/plotly/figure_factory/_gantt.py
@@ -46,7 +46,7 @@ def validate_gantt(df):
         for index in range(num_of_rows):
             task_dict = {}
             for key in df:
-                task_dict[key] = df.ix[index][key]
+                task_dict[key] = df.iloc[index][key]
             chart.append(task_dict)
 
         return chart


Test patch:
Repository: plotly/plotly.py

Issue:
Error when using two image scrappers together
### Introduction to the problem 
I am trying to move the current Jupyter Notebook examples of the [poliastro project](https://github.com/poliastro/poliastro) to an [Sphinx-Gallery](https://github.com/sphinx-gallery/sphinx-gallery) set. Since we are making use of **plotly figures** we need to **capture them** as output figures and therefore, make use of the **plotly image scrapper**. We also need to capture `matplotlib` figures, so this image scrapper must be also added to the `conf.py` file.

#### How to reproduce this issue :beetle: 

If you download the [official example repository](https://github.com/plotly/plotly-sphinx-gallery)  from @emmanuelle for achieving this task and you add the following [simple Python file](https://gist.github.com/jorgepiloto/db807a7ee3a0bcfbaea38fc9cd7ac95e) in the `examples/` directory for plotting a sinusoidal wave with `matplotlib` and error is raised:

```bash
generating gallery...
generating gallery for auto_examples... [ 25%] plot_sin.py                                                                                                                                       
Exception occurred:
  File "/home/lobo/anaconda3/envs/poliastro/lib/python3.7/site-packages/plotly/io/_sg_scraper.py", line 91, in figure_rst
    figure_name = figure_paths[0]
IndexError: list index out of range
```


Discussion:

Resolving patch:
diff --git a/packages/python/plotly/plotly/io/_sg_scraper.py b/packages/python/plotly/plotly/io/_sg_scraper.py
--- a/packages/python/plotly/plotly/io/_sg_scraper.py
+++ b/packages/python/plotly/plotly/io/_sg_scraper.py
@@ -88,6 +88,8 @@ def figure_rst(figure_list, sources_dir):
         for figure_path in figure_list
     ]
     images_rst = ""
+    if not figure_paths:
+        return images_rst
     figure_name = figure_paths[0]
     ext = os.path.splitext(figure_name)[1]
     figure_path = os.path.join("images", os.path.basename(figure_name))


Test patch:
Repository: plotly/plotly.py

Issue:
[bug] Suboptimal number formatting for trendline coefficients in plotly.express
In https://github.com/plotly/plotly.py/blob/master/packages/python/plotly/plotly/express/_core.py#L239 we should use `%g` instead of `%f` so that enough significant digits are displayed even for very small numbers (for the slope in particular). Raised by https://community.plot.ly/t/how-to-extend-ols-trendline/32270


Discussion:
@nicolaskruchten do you agree that this should be changed?

Resolving patch:
diff --git a/packages/python/plotly/plotly/express/_core.py b/packages/python/plotly/plotly/express/_core.py
--- a/packages/python/plotly/plotly/express/_core.py
+++ b/packages/python/plotly/plotly/express/_core.py
@@ -236,7 +236,7 @@ def make_trace_kwargs(args, trace_spec, g, mapping_labels, sizeref):
                         fit_results = sm.OLS(y.values, sm.add_constant(x.values)).fit()
                         result["y"] = fit_results.predict()
                         hover_header = "<b>OLS trendline</b><br>"
-                        hover_header += "%s = %f * %s + %f<br>" % (
+                        hover_header += "%s = %g * %s + %g<br>" % (
                             args["y"],
                             fit_results.params[1],
                             args["x"],


Test patch:
Repository: plotly/plotly.py

Issue:
inspect.getargspec() is deprecated
[This line](https://github.com/plotly/plotly.py/blob/81f3922722672fbd6ce7ff50acfac8771c7c7ac2/packages/python/plotly/plotly/express/_doc.py#L503) triggers a `DeprecationWarning` on Python 3:
```
[...]/lib/python3.6/site-packages/plotly/express/_doc.py:503: DeprecationWarning:
inspect.getargspec() is deprecated, use inspect.signature() or inspect.getfullargspec()
```
`getfullargspec` from the same `inspect` package is usually a [drop-in replacement on Python 3](https://docs.python.org/3/library/inspect.html#inspect.getargspec).


Discussion:
Thank you @anders-kiaer !

Resolving patch:
diff --git a/packages/python/plotly/plotly/express/_doc.py b/packages/python/plotly/plotly/express/_doc.py
--- a/packages/python/plotly/plotly/express/_doc.py
+++ b/packages/python/plotly/plotly/express/_doc.py
@@ -1,6 +1,10 @@
 import inspect
 from textwrap import TextWrapper
 
+try:
+    getfullargspec = inspect.getfullargspec
+except AttributeError:  # python 2
+    getfullargspec = inspect.getargspec
 
 # TODO contents of columns
 # TODO explain categorical
@@ -505,7 +509,7 @@
 def make_docstring(fn, override_dict={}):
     tw = TextWrapper(width=75, initial_indent="    ", subsequent_indent="    ")
     result = (fn.__doc__ or "") + "\nParameters\n----------\n"
-    for param in inspect.getargspec(fn)[0]:
+    for param in getfullargspec(fn)[0]:
         if override_dict.get(param):
             param_doc = override_dict[param]
         else:


Test patch:
Repository: plotly/plotly.py

Issue:
plotly.express import raises ModuleNotFound in environment without pandas.
Importing plotly.express when pandas is not available raises `ModuleNotFoundError: No module named 'pandas'`, instead of the intended `ImportError: Plotly express requires pandas to be installed.`
This happens on `from ._imshow import imshow`.
Perhaps this import should be moved below the code that will output a more helpful message?


Discussion:

Resolving patch:
diff --git a/packages/python/plotly/plotly/express/__init__.py b/packages/python/plotly/plotly/express/__init__.py
--- a/packages/python/plotly/plotly/express/__init__.py
+++ b/packages/python/plotly/plotly/express/__init__.py
@@ -4,7 +4,6 @@
 """
 from __future__ import absolute_import
 from plotly import optional_imports
-from ._imshow import imshow
 
 pd = optional_imports.get_module("pandas")
 if pd is None:
@@ -13,6 +12,7 @@
 Plotly express requires pandas to be installed."""
     )
 
+from ._imshow import imshow
 from ._chart_types import (  # noqa: F401
     scatter,
     scatter_3d,


Test patch: