code: def scatterplot_theme(
      dataframe,
      headers,
      diag,
      size,
      height,
      width,
      title,
      index,
      index_vals,
      endpts,
      colormap,
      colormap_type,
      **kwargs,
  ):
      """
      Refer to FigureFactory.create_scatterplotmatrix() for docstring
  
      Returns fig for scatterplotmatrix with both index and colormap picked
  
      """
  
      # Check if index is made of string values
      if isinstance(index_vals[0], str):
          unique_index_vals = []
          for name in index_vals:
              if name not in unique_index_vals:
                  unique_index_vals.append(name)
          n_colors_len = len(unique_index_vals)
  
          # Convert colormap to list of n RGB tuples
          if colormap_type == "seq":
              foo = clrs.color_parser(colormap, clrs.unlabel_rgb)
              foo = clrs.n_colors(foo[0], foo[1], n_colors_len)
              theme = clrs.color_parser(foo, clrs.label_rgb)
  
          if colormap_type == "cat":
              # leave list of colors the same way
              theme = colormap
  
          dim = len(dataframe)
          fig = make_subplots(rows=dim, cols=dim, print_grid=False)
          trace_list = []
          legend_param = 0
          # Work over all permutations of list pairs
          for listy in dataframe:
              for listx in dataframe:
                  # create a dictionary for index_vals
                  unique_index_vals = {}
                  for name in index_vals:
                      if name not in unique_index_vals:
                          unique_index_vals[name] = []
  
                  c_indx = 0  # color index
                  # Fill all the rest of the names into the dictionary
                  for name in sorted(unique_index_vals.keys()):
                      new_listx = []
                      new_listy = []
                      for j in range(len(index_vals)):
                          if index_vals[j] == name:
                              new_listx.append(listx[j])
                              new_listy.append(listy[j])
                      # Generate trace with VISIBLE icon
                      if legend_param == 1:
                          if (listx == listy) and (diag == "histogram"):
                              trace = graph_objs.Histogram(
                                  x=new_listx,
                                  marker=dict(color=theme[c_indx]),
                                  showlegend=True,
                              )
                          elif (listx == listy) and (diag == "box"):
                              trace = graph_objs.Box(
                                  y=new_listx,
                                  name=None,
                                  marker=dict(color=theme[c_indx]),
                                  showlegend=True,
                              )
                          else:
                              if "marker" in kwargs:
                                  kwargs["marker"]["size"] = size
                                  kwargs["marker"]["color"] = theme[
                                      c_indx
                                  ]
                                  trace = graph_objs.Scatter(
                                      x=new_listx,
                                      y=new_listy,
                                      mode="markers",
                                      name=name,
                                      showlegend=True,
                                      **kwargs,
                                  )
                              else:
                                  trace = graph_objs.Scatter(
                                      x=new_listx,
                                      y=new_listy,
                                      mode="markers",
                                      name=name,
                                      marker=dict(
                                          size=size, color=theme[c_indx]
                                      ),
                                      showlegend=True,
                                      **kwargs,
                                  )
                      # Generate trace with INVISIBLE icon
                      else:
                          if (listx == listy) and (diag == "histogram"):
                              trace = graph_objs.Histogram(
                                  x=new_listx,
                                  marker=dict(color=theme[c_indx]),
                                  showlegend=False,
                              )
                          elif (listx == listy) and (diag == "box"):
                              trace = graph_objs.Box(
                                  y=new_listx,
                                  name=None,
                                  marker=dict(color=theme[c_indx]),
                                  showlegend=False,
                              )
                          else:
                              if "marker" in kwargs:
                                  kwargs["marker"]["size"] = size
                                  kwargs["marker"]["color"] = theme[
                                      c_indx
                                  ]
                                  trace = graph_objs.Scatter(
                                      x=new_listx,
                                      y=new_listy,
                                      mode="markers",
                                      name=name,
                                      showlegend=False,
                                      **kwargs,
                                  )
                              else:
                                  trace = graph_objs.Scatter(
                                      x=new_listx,
                                      y=new_listy,
                                      mode="markers",
                                      name=name,
                                      marker=dict(
                                          size=size, color=theme[c_indx]
                                      ),
                                      showlegend=False,
                                      **kwargs,
                                  )
                      # Push the trace into dictionary
                      unique_index_vals[name] = trace
                      if c_indx >= (len(theme) - 1):
                          c_indx = -1
                      c_indx += 1
                  trace_list.append(unique_index_vals)
                  legend_param += 1
  
          trace_index = 0
          indices = range(1, dim + 1)
          for y_index in indices:
              for x_index in indices:
                  for name in sorted(trace_list[trace_index].keys()):
                      fig.append_trace(
                          trace_list[trace_index][name],
                          y_index,
                          x_index,
                      )
                  trace_index += 1
  
          # Insert headers into the figure
          for j in range(dim):
              xaxis_key = "xaxis{}".format((dim * dim) - dim + 1 + j)
              fig["layout"][xaxis_key].update(title=headers[j])
  
          for j in range(dim):
              yaxis_key = "yaxis{}".format(1 + (dim * j))
              fig["layout"][yaxis_key].update(title=headers[j])
  
          hide_tick_labels_from_box_subplots(fig)
  
          if diag == "histogram":
              fig["layout"].update(
                  height=height,
                  width=width,
                  title=title,
                  showlegend=True,
                  barmode="stack",
              )
              return fig
  
          elif diag == "box":
              fig["layout"].update(
                  height=height,
                  width=width,
                  title=title,
                  showlegend=True,
              )
              return fig
  
          else:
              fig["layout"].update(
                  height=height,
                  width=width,
                  title=title,
                  showlegend=True,
              )
              return fig
  
      else:
          if endpts:
              intervals = utils.endpts_to_intervals(endpts)
  
              # Convert colormap to list of n RGB tuples
              if colormap_type == "seq":
                  foo = clrs.color_parser(colormap, clrs.unlabel_rgb)
                  foo = clrs.n_colors(foo[0], foo[1], len(intervals))
                  theme = clrs.color_parser(foo, clrs.label_rgb)
  
              if colormap_type == "cat":
                  # leave list of colors the same way
                  theme = colormap
  
              dim = len(dataframe)
              fig = make_subplots(rows=dim, cols=dim, print_grid=False)
              trace_list = []
              legend_param = 0
              # Work over all permutations of list pairs
              for listy in dataframe:
                  for listx in dataframe:
                      interval_labels = {}
                      for interval in intervals:
                          interval_labels[str(interval)] = []
  
                      c_indx = 0  # color index
                      # Fill all the rest of the names into the dictionary
                      for interval in intervals:
                          new_listx = []
                          new_listy = []
                          for j in range(len(index_vals)):
                              if (
                                  interval[0]
                                  < index_vals[j]
                                  <= interval[1]
                              ):
                                  new_listx.append(listx[j])
                                  new_listy.append(listy[j])
                          # Generate trace with VISIBLE icon
                          if legend_param == 1:
                              if (listx == listy) and (
                                  diag == "histogram"
                              ):
                                  trace = graph_objs.Histogram(
                                      x=new_listx,
                                      marker=dict(color=theme[c_indx]),
                                      showlegend=True,
                                  )
                              elif (listx == listy) and (diag == "box"):
                                  trace = graph_objs.Box(
                                      y=new_listx,
                                      name=None,
                                      marker=dict(color=theme[c_indx]),
                                      showlegend=True,
                                  )
                              else:
                                  if "marker" in kwargs:
                                      kwargs["marker"]["size"] = size
                                      (
                                          kwargs["marker"]["color"]
                                      ) = theme[c_indx]
                                      trace = graph_objs.Scatter(
                                          x=new_listx,
                                          y=new_listy,
                                          mode="markers",
                                          name=str(interval),
                                          showlegend=True,
                                          **kwargs,
                                      )
                                  else:
                                      trace = graph_objs.Scatter(
                                          x=new_listx,
                                          y=new_listy,
                                          mode="markers",
                                          name=str(interval),
                                          marker=dict(
                                              size=size,
                                              color=theme[c_indx],
                                          ),
                                          showlegend=True,
                                          **kwargs,
                                      )
                          # Generate trace with INVISIBLE icon
                          else:
                              if (listx == listy) and (
                                  diag == "histogram"
                              ):
                                  trace = graph_objs.Histogram(
                                      x=new_listx,
                                      marker=dict(color=theme[c_indx]),
                                      showlegend=False,
                                  )
                              elif (listx == listy) and (diag == "box"):
                                  trace = graph_objs.Box(
                                      y=new_listx,
                                      name=None,
                                      marker=dict(color=theme[c_indx]),
                                      showlegend=False,
                                  )
                              else:
                                  if "marker" in kwargs:
                                      kwargs["marker"]["size"] = size
                                      (
                                          kwargs["marker"]["color"]
                                      ) = theme[c_indx]
                                      trace = graph_objs.Scatter(
                                          x=new_listx,
                                          y=new_listy,
                                          mode="markers",
                                          name=str(interval),
                                          showlegend=False,
                                          **kwargs,
                                      )
                                  else:
                                      trace = graph_objs.Scatter(
                                          x=new_listx,
                                          y=new_listy,
                                          mode="markers",
                                          name=str(interval),
                                          marker=dict(
                                              size=size,
                                              color=theme[c_indx],
                                          ),
                                          showlegend=False,
                                          **kwargs,
                                      )
                          # Push the trace into dictionary
                          interval_labels[str(interval)] = trace
                          if c_indx >= (len(theme) - 1):
                              c_indx = -1
                          c_indx += 1
                      trace_list.append(interval_labels)
                      legend_param += 1
  
              trace_index = 0
              indices = range(1, dim + 1)
              for y_index in indices:
                  for x_index in indices:
                      for interval in intervals:
                          fig.append_trace(
                              trace_list[trace_index][str(interval)],
                              y_index,
                              x_index,
                          )
                      trace_index += 1
  
              # Insert headers into the figure
              for j in range(dim):
                  xaxis_key = "xaxis{}".format(
                      (dim * dim) - dim + 1 + j
                  )
                  fig["layout"][xaxis_key].update(title=headers[j])
              for j in range(dim):
                  yaxis_key = "yaxis{}".format(1 + (dim * j))
                  fig["layout"][yaxis_key].update(title=headers[j])
  
              hide_tick_labels_from_box_subplots(fig)
  
              if diag == "histogram":
                  fig["layout"].update(
                      height=height,
                      width=width,
                      title=title,
                      showlegend=True,
                      barmode="stack",
                  )
                  return fig
  
              elif diag == "box":
                  fig["layout"].update(
                      height=height,
                      width=width,
                      title=title,
                      showlegend=True,
                  )
                  return fig
  
              else:
                  fig["layout"].update(
                      height=height,
                      width=width,
                      title=title,
                      showlegend=True,
                  )
                  return fig
  
          else:
              theme = colormap
  
              # add a copy of rgb color to theme if it contains one color
              if len(theme) <= 1:
                  theme.append(theme[0])
  
              color = []
              for incr in range(len(theme)):
                  color.append(
                      [1.0 / (len(theme) - 1) * incr, theme[incr]]
                  )
  
              dim = len(dataframe)
              fig = make_subplots(rows=dim, cols=dim, print_grid=False)
              trace_list = []
              legend_param = 0
              # Run through all permutations of list pairs
              for listy in dataframe:
                  for listx in dataframe:
                      # Generate trace with VISIBLE icon
                      if legend_param == 1:
                          if (listx == listy) and (diag == "histogram"):
                              trace = graph_objs.Histogram(
                                  x=listx,
                                  marker=dict(color=theme[0]),
                                  showlegend=False,
                              )
                          elif (listx == listy) and (diag == "box"):
                              trace = graph_objs.Box(
                                  y=listx,
                                  marker=dict(color=theme[0]),
                                  showlegend=False,
                              )
                          else:
                              if "marker" in kwargs:
                                  kwargs["marker"]["size"] = size
                                  kwargs["marker"]["color"] = index_vals
                                  kwargs["marker"]["colorscale"] = color
                                  kwargs["marker"]["showscale"] = True
                                  trace = graph_objs.Scatter(
                                      x=listx,
                                      y=listy,
                                      mode="markers",
                                      showlegend=False,
                                      **kwargs,
                                  )
                              else:
                                  trace = graph_objs.Scatter(
                                      x=listx,
                                      y=listy,
                                      mode="markers",
                                      marker=dict(
                                          size=size,
                                          color=index_vals,
                                          colorscale=color,
                                          showscale=True,
                                      ),
                                      showlegend=False,
                                      **kwargs,
                                  )
                      # Generate trace with INVISIBLE icon
                      else:
                          if (listx == listy) and (diag == "histogram"):
                              trace = graph_objs.Histogram(
                                  x=listx,
                                  marker=dict(color=theme[0]),
                                  showlegend=False,
                              )
                          elif (listx == listy) and (diag == "box"):
                              trace = graph_objs.Box(
                                  y=listx,
                                  marker=dict(color=theme[0]),
                                  showlegend=False,
                              )
                          else:
                              if "marker" in kwargs:
                                  kwargs["marker"]["size"] = size
                                  kwargs["marker"]["color"] = index_vals
                                  kwargs["marker"]["colorscale"] = color
                                  kwargs["marker"]["showscale"] = False
                                  trace = graph_objs.Scatter(
                                      x=listx,
                                      y=listy,
                                      mode="markers",
                                      showlegend=False,
                                      **kwargs,
                                  )
                              else:
                                  trace = graph_objs.Scatter(
                                      x=listx,
                                      y=listy,
                                      mode="markers",
                                      marker=dict(
                                          size=size,
                                          color=index_vals,
                                          colorscale=color,
                                          showscale=False,
                                      ),
                                      showlegend=False,
                                      **kwargs,
                                  )
                      # Push the trace into list
                      trace_list.append(trace)
                      legend_param += 1
  
              trace_index = 0
              indices = range(1, dim + 1)
              for y_index in indices:
                  for x_index in indices:
                      fig.append_trace(
                          trace_list[trace_index], y_index, x_index
                      )
                      trace_index += 1
  
              # Insert headers into the figure
              for j in range(dim):
                  xaxis_key = "xaxis{}".format(
                      (dim * dim) - dim + 1 + j
                  )
                  fig["layout"][xaxis_key].update(title=headers[j])
              for j in range(dim):
                  yaxis_key = "yaxis{}".format(1 + (dim * j))
                  fig["layout"][yaxis_key].update(title=headers[j])
  
              hide_tick_labels_from_box_subplots(fig)
  
              if diag == "histogram":
                  fig["layout"].update(
                      height=height,
                      width=width,
                      title=title,
                      showlegend=True,
                      barmode="stack",
                  )
                  return fig
  
              elif diag == "box":
                  fig["layout"].update(
                      height=height,
                      width=width,
                      title=title,
                      showlegend=True,
                  )
                  return fig
  
              else:
                  fig["layout"].update(
                      height=height,
                      width=width,
                      title=title,
                      showlegend=True,
                  )
                  return fig
  
file_path: plotly.py/packages/python/plotly/plotly/figure_factory/_scatterplot.py
imports: from plotly import exceptions, optional_imports
  import plotly.colors
  from plotly.figure_factory import utils
  from plotly.graph_objs import graph_objs
  from plotly.subplots import make_subplots
label_desc: Use image node_id 6 for calling a global function with example usage: scatterplot_theme(dataframe, headers, diag, size, height, width, title, index, index_vals, endpts, colormap, colormap_type) and returns: fig, fig, fig, fig, fig, fig, fig, fig, fig