@@ -3805,7 +3805,7 @@ def dist_origin(x, y, z):
3805
3805
return graph_objs .Figure (data = data1 , layout = layout )
3806
3806
3807
3807
@staticmethod
3808
- def _scatterplot (dataframe , headers , diag , size ,
3808
+ def _scatterplot (dataframe , headers , diag , size , webgl ,
3809
3809
height , width , title , ** kwargs ):
3810
3810
"""
3811
3811
Refer to FigureFactory.create_scatterplotmatrix() for docstring
@@ -3879,10 +3879,13 @@ def _scatterplot(dataframe, headers, diag, size,
3879
3879
3880
3880
FigureFactory ._hide_tick_labels_from_box_subplots (fig )
3881
3881
3882
+ if webgl is True :
3883
+ FigureFactory ._change_figure_to_webgl (fig )
3884
+
3882
3885
return fig
3883
3886
3884
3887
@staticmethod
3885
- def _scatterplot_dict (dataframe , headers , diag , size ,
3888
+ def _scatterplot_dict (dataframe , headers , diag , size , webgl ,
3886
3889
height , width , title , index , index_vals ,
3887
3890
endpts , colormap , colormap_type , ** kwargs ):
3888
3891
"""
@@ -4028,6 +4031,9 @@ def _scatterplot_dict(dataframe, headers, diag, size,
4028
4031
4029
4032
FigureFactory ._hide_tick_labels_from_box_subplots (fig )
4030
4033
4034
+ if webgl is True :
4035
+ FigureFactory ._change_figure_to_webgl (fig )
4036
+
4031
4037
if diag == 'histogram' :
4032
4038
fig ['layout' ].update (
4033
4039
height = height , width = width ,
@@ -4044,7 +4050,7 @@ def _scatterplot_dict(dataframe, headers, diag, size,
4044
4050
return fig
4045
4051
4046
4052
@staticmethod
4047
- def _scatterplot_theme (dataframe , headers , diag , size , height ,
4053
+ def _scatterplot_theme (dataframe , headers , diag , size , webgl , height ,
4048
4054
width , title , index , index_vals , endpts ,
4049
4055
colormap , colormap_type , ** kwargs ):
4050
4056
"""
@@ -4213,6 +4219,9 @@ def _scatterplot_theme(dataframe, headers, diag, size, height,
4213
4219
4214
4220
FigureFactory ._hide_tick_labels_from_box_subplots (fig )
4215
4221
4222
+ if webgl is True :
4223
+ FigureFactory ._change_figure_to_webgl (fig )
4224
+
4216
4225
if diag == 'histogram' :
4217
4226
fig ['layout' ].update (
4218
4227
height = height , width = width ,
@@ -4388,6 +4397,9 @@ def _scatterplot_theme(dataframe, headers, diag, size, height,
4388
4397
4389
4398
FigureFactory ._hide_tick_labels_from_box_subplots (fig )
4390
4399
4400
+ if webgl is True :
4401
+ FigureFactory ._change_figure_to_webgl (fig )
4402
+
4391
4403
if diag == 'histogram' :
4392
4404
fig ['layout' ].update (
4393
4405
height = height , width = width ,
@@ -4535,6 +4547,9 @@ def _scatterplot_theme(dataframe, headers, diag, size, height,
4535
4547
4536
4548
FigureFactory ._hide_tick_labels_from_box_subplots (fig )
4537
4549
4550
+ if webgl is True :
4551
+ FigureFactory ._change_figure_to_webgl (fig )
4552
+
4538
4553
if diag == 'histogram' :
4539
4554
fig ['layout' ].update (
4540
4555
height = height , width = width ,
@@ -4558,10 +4573,20 @@ def _scatterplot_theme(dataframe, headers, diag, size, height,
4558
4573
return fig
4559
4574
4560
4575
@staticmethod
4561
- def _hide_tick_labels_from_box_subplots (fig ):
4576
+ def _change_figure_to_webgl (fig ):
4562
4577
"""
4563
- Hides tick labels for box plots in scatterplotmatrix subplots.
4578
+ Changes all scatter traces in figure to 'scattergl' type.
4579
+
4580
+ Only works if all traces are of type 'scatter'.
4564
4581
"""
4582
+ if all (trace ['type' ] == 'scatter' for trace in fig ['data' ]):
4583
+ for trace in fig ['data' ]:
4584
+ if trace ['type' ] == 'scatter' :
4585
+ trace ['type' ] = 'scattergl'
4586
+
4587
+ @staticmethod
4588
+ def _hide_tick_labels_from_box_subplots (fig ):
4589
+ """Hides tick labels for box plots in scatterplotmatrix subplots."""
4565
4590
boxplot_xaxes = []
4566
4591
for trace in fig ['data' ]:
4567
4592
if trace ['type' ] == 'box' :
@@ -4808,24 +4833,25 @@ def _unlabel_rgb(colors):
4808
4833
4809
4834
@staticmethod
4810
4835
def create_scatterplotmatrix (df , index = None , endpts = None , diag = 'scatter' ,
4811
- height = 500 , width = 500 , size = 6 ,
4836
+ height = 500 , width = 500 , size = 6 , webgl = False ,
4812
4837
title = 'Scatterplot Matrix' , colormap = None ,
4813
4838
colormap_type = 'cat' , dataframe = None ,
4814
4839
headers = None , index_vals = None , ** kwargs ):
4815
4840
"""
4816
4841
Returns data for a scatterplot matrix.
4817
4842
4818
- :param (array) df: array of the data with column headers
4819
- :param (str) index: name of the index column in data array
4843
+ :param (array) df: array of the data with column headers.
4844
+ :param (str) index: name of the index column in data array.
4820
4845
:param (list|tuple) endpts: takes an increasing sequece of numbers
4821
4846
that defines intervals on the real line. They are used to group
4822
4847
the entries in an index of numbers into their corresponding
4823
- interval and therefore can be treated as categorical data
4848
+ interval and therefore can be treated as categorical data.
4824
4849
:param (str) diag: sets the chart type for the main diagonal plots.
4825
4850
The options are 'scatter', 'histogram' and 'box'.
4826
- :param (int|float) height: sets the height of the chart
4827
- :param (int|float) width: sets the width of the chart
4828
- :param (float) size: sets the marker size (in px)
4851
+ :param (int|float) height: sets the height of the chart.
4852
+ :param (int|float) width: sets the width of the chart.
4853
+ :param (float) size: sets the marker size (in px).
4854
+ :param (bool) webgl: if True, plots all scatterplots with WebGL.
4829
4855
:param (str) title: the title label of the scatterplot matrix
4830
4856
:param (str|tuple|list|dict) colormap: either a plotly scale name,
4831
4857
an rgb or hex color, a color tuple, a list of colors or a
@@ -4836,7 +4862,7 @@ def create_scatterplotmatrix(df, index=None, endpts=None, diag='scatter',
4836
4862
members.
4837
4863
If colormap is a dictionary, all the string entries in
4838
4864
the index column must be a key in colormap. In this case, the
4839
- colormap_type is forced to 'cat' or categorical
4865
+ colormap_type is forced to 'cat' or categorical.
4840
4866
:param (str) colormap_type: determines how colormap is interpreted.
4841
4867
Valid choices are 'seq' (sequential) and 'cat' (categorical). If
4842
4868
'seq' is selected, only the first two colors in colormap will be
@@ -4845,10 +4871,10 @@ def create_scatterplotmatrix(df, index=None, endpts=None, diag='scatter',
4845
4871
forced if all index values are numeric.
4846
4872
If 'cat' is selected, a color from colormap will be assigned to
4847
4873
each category from index, including the intervals if endpts is
4848
- being used
4874
+ being used.
4849
4875
:param (dict) **kwargs: a dictionary of scatterplot arguments
4850
4876
The only forbidden parameters are 'size', 'color' and
4851
- 'colorscale' in 'marker'
4877
+ 'colorscale' in 'marker'.
4852
4878
4853
4879
Example 1: Vanilla Scatterplot Matrix
4854
4880
```
@@ -5035,8 +5061,8 @@ def create_scatterplotmatrix(df, index=None, endpts=None, diag='scatter',
5035
5061
# Check for same data-type in df columns
5036
5062
FigureFactory ._validate_dataframe (dataframe )
5037
5063
figure = FigureFactory ._scatterplot (dataframe , headers , diag ,
5038
- size , height , width , title ,
5039
- ** kwargs )
5064
+ size , webgl , height , width ,
5065
+ title , ** kwargs )
5040
5066
return figure
5041
5067
else :
5042
5068
# Validate index selection
@@ -5066,16 +5092,16 @@ def create_scatterplotmatrix(df, index=None, endpts=None, diag='scatter',
5066
5092
"names in the index "
5067
5093
"must be keys." )
5068
5094
figure = FigureFactory ._scatterplot_dict (
5069
- dataframe , headers , diag , size , height , width , title ,
5070
- index , index_vals , endpts , colormap , colormap_type ,
5095
+ dataframe , headers , diag , size , webgl , height , width ,
5096
+ title , index , index_vals , endpts , colormap , colormap_type ,
5071
5097
** kwargs
5072
5098
)
5073
5099
return figure
5074
5100
5075
5101
else :
5076
5102
figure = FigureFactory ._scatterplot_theme (
5077
- dataframe , headers , diag , size , height , width , title ,
5078
- index , index_vals , endpts , colormap , colormap_type ,
5103
+ dataframe , headers , diag , size , webgl , height , width ,
5104
+ title , index , index_vals , endpts , colormap , colormap_type ,
5079
5105
** kwargs
5080
5106
)
5081
5107
return figure
0 commit comments