From f051573d72a842a849a96921bc3935dff25b7869 Mon Sep 17 00:00:00 2001 From: Adam Kulidjian Date: Tue, 5 Jul 2016 12:53:30 -0400 Subject: [PATCH 1/7] Added _make_colorscale method and 2D Density Plot --- plotly/tools.py | 143 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+) diff --git a/plotly/tools.py b/plotly/tools.py index bdef4f8081d..9062d150e7e 100644 --- a/plotly/tools.py +++ b/plotly/tools.py @@ -1476,6 +1476,149 @@ class FigureFactory(object): more information and examples of a specific chart type. """ + @staticmethod + def _make_colorscale(colors): + """ + Makes a list of colors into a colorscale-acceptable form + + For documentation regarding to the form of the output, see + https://plot.ly/python/reference/#mesh3d-colorscale + """ + colorscale = [] + diff = 1./(len(colors) - 1) + + for j in range(len(colors)): + colorscale.append([j * diff, colors[j]]) + return colorscale + + @staticmethod + def create_2D_density(x, y, colorscale='Earth', ncontours=20, + hist_color=(0, 0, 0.5), pt_color=(0, 0, 0.5), + pt_size=2, height=600, width=600): + """ + Returns figure for a 2D density plot + + :param (list) x: x-axis data for plot generation + :param (list) y: y-axis data for plot generation + :param (str|tuple|list) colormap: either a plotly scale name, an rgb + or hex color, a color tuple or a list or tuple of colors. An rgb + color is of the form 'rgb(x, y, z)' where x, y, z belong to the + interval [0, 255] and a color tuple is a tuple of the form + (a, b, c) where a, b and c belong to [0, 1]. If colormap is a + list, it must contain the valid color types aforementioned as its + members. + :param (int) ncontours: the number of 2D contours to draw on the plot + :param (str) hist_color: the color of the plotted histograms + :param (str) pt_color: the color of the scatter points + :param (str) pt_size: the color of the scatter points + :param (float) height: the height of the chart + :param (float) width: the width of the chart + + Example 1: Simple 2D Density Plot + ``` + import plotly.plotly as py + from plotly.tools import FigureFactory as FF + + # Make data points + t = np.linspace(-1,1.2,2000) + x = (t**3)+(0.3*np.random.randn(2000)) + y = (t**6)+(0.3*np.random.randn(2000)) + + # Create a figure + fig = FF.create_2D_density(x, y) + + # Plot the data + py.iplot(fig, filename='simple-2d-density') + ``` + + Example 2: Use Parameters + ``` + import plotly.plotly as py + from plotly.tools import FigureFactory as FF + + # Make data points + t = np.linspace(-1,1.2,2000) + x = (t**3)+(0.3*np.random.randn(2000)) + y = (t**6)+(0.3*np.random.randn(2000)) + + # Create custom colorscale + colorscale = ['#7A4579', '#D56073', 'rgb(236,158,105)', + (1, 1, 0.2), (0.98,0.98,0.98)] + + # Create a figure + fig = FF.create_2D_density( + x, y, colorscale=colorscale, hist_color='rgb(255, 237, 222)', pt_size=3) + + # Plot the data + py.iplot(fig, filename='use-parameters') + ``` + """ + from plotly.graph_objs import graph_objs + colorscale = FigureFactory._validate_colors(colorscale, 'rgb') + colorscale = FigureFactory._make_colorscale(colorscale) + + # validate hist_color and pt_color + hist_color = FigureFactory._validate_colors(hist_color, 'rgb') + pt_color = FigureFactory._validate_colors(pt_color, 'rgb') + + trace1 = graph_objs.Scatter( + x=x, y=y, mode='markers', name='points', + marker=dict( + color=pt_color[0], + size=pt_size, + opacity=0.4 + ) + ) + trace2 = graph_objs.Histogram2dcontour( + x=x, y=y, name='density', ncontours=ncontours, + colorscale=colorscale, reversescale=True, showscale=False + ) + trace3 = graph_objs.Histogram( + x=x, name='x density', + marker=dict(color=hist_color[0]), yaxis='y2' + ) + trace4 = graph_objs.Histogram( + y=y, name='y density', + marker=dict(color=hist_color[0]), xaxis='x2' + ) + data = [trace1, trace2, trace3, trace4] + + layout = graph_objs.Layout( + showlegend=False, + autosize=False, + title='Love', + height=height, + width=width, + xaxis=dict( + domain=[0, 0.85], + showgrid=False, + zeroline=False + ), + yaxis=dict( + domain=[0, 0.85], + showgrid=False, + zeroline=False + ), + margin=dict( + t=50 + ), + hovermode='closest', + bargap=0, + xaxis2=dict( + domain=[0.85, 1], + showgrid=False, + zeroline=False + ), + yaxis2=dict( + domain=[0.85, 1], + showgrid=False, + zeroline=False + ) + ) + + fig = graph_objs.Figure(data=data, layout=layout) + return fig + @staticmethod def _validate_gantt(df): """ From 7f95dcfd3b4dfc0c8f8405b39e321edf61d63fbf Mon Sep 17 00:00:00 2001 From: Adam Kulidjian Date: Tue, 5 Jul 2016 15:20:54 -0400 Subject: [PATCH 2/7] Updated schema --- plotly/graph_reference/default-schema.json | 305 +++++++++++++-------- 1 file changed, 195 insertions(+), 110 deletions(-) diff --git a/plotly/graph_reference/default-schema.json b/plotly/graph_reference/default-schema.json index a14218abfd3..2c412a45320 100644 --- a/plotly/graph_reference/default-schema.json +++ b/plotly/graph_reference/default-schema.json @@ -253,17 +253,37 @@ "valType": "number" }, "ax": { - "description": "Sets the x component of the arrow tail about the arrow head. A positive (negative) component corresponds to an arrow pointing from right to left (left to right)", + "description": "Sets the x component of the arrow tail about the arrow head. If `axref` is `pixel`, a positive (negative) component corresponds to an arrow pointing from right to left (left to right). If `axref` is an axis, this is a value on that axis.", "dflt": -10, "role": "info", "valType": "number" }, + "axref": { + "description": "Indicates in what terms the tail of the annotation (ax,ay) is specified. If `pixel`, `ax` is a relative offset in pixels from `x`. If set to an x axis id (e.g. *x* or *x2*), `ax` is specified in the same terms as that axis. This is useful for trendline annotations which should continue to indicate the correct trend when zoomed.", + "dflt": "pixel", + "role": "info", + "valType": "enumerated", + "values": [ + "pixel", + "/^x([2-9]|[1-9][0-9]+)?$/" + ] + }, "ay": { - "description": "Sets the y component of the arrow tail about the arrow head. A positive (negative) component corresponds to an arrow pointing from bottom to top (top to bottom)", + "description": "Sets the y component of the arrow tail about the arrow head. If `ayref` is `pixel`, a positive (negative) component corresponds to an arrow pointing from bottom to top (top to bottom). If `ayref` is an axis, this is a value on that axis.", "dflt": -30, "role": "info", "valType": "number" }, + "ayref": { + "description": "Indicates in what terms the tail of the annotation (ax,ay) is specified. If `pixel`, `ay` is a relative offset in pixels from `y`. If set to a y axis id (e.g. *y* or *y2*), `ay` is specified in the same terms as that axis. This is useful for trendline annotations which should continue to indicate the correct trend when zoomed.", + "dflt": "pixel", + "role": "info", + "valType": "enumerated", + "values": [ + "pixel", + "/^y([2-9]|[1-9][0-9]+)?$/" + ] + }, "bgcolor": { "description": "Sets the background color of the annotation.", "dflt": "rgba(0,0,0,0)", @@ -1494,7 +1514,7 @@ ] }, "nticks": { - "description": "Sets the number of ticks. Has an effect only if `tickmode` is set to *auto*.", + "description": "Specifies the maximum number of ticks for the particular axis. The actual number of ticks will be chosen automatically to be less than or equal to `nticks`. Has an effect only if `tickmode` is set to *auto*.", "dflt": 0, "min": 0, "role": "style", @@ -1899,7 +1919,7 @@ ] }, "nticks": { - "description": "Sets the number of ticks. Has an effect only if `tickmode` is set to *auto*.", + "description": "Specifies the maximum number of ticks for the particular axis. The actual number of ticks will be chosen automatically to be less than or equal to `nticks`. Has an effect only if `tickmode` is set to *auto*.", "dflt": 0, "min": 0, "role": "style", @@ -2304,7 +2324,7 @@ ] }, "nticks": { - "description": "Sets the number of ticks. Has an effect only if `tickmode` is set to *auto*.", + "description": "Specifies the maximum number of ticks for the particular axis. The actual number of ticks will be chosen automatically to be less than or equal to `nticks`. Has an effect only if `tickmode` is set to *auto*.", "dflt": 0, "min": 0, "role": "style", @@ -2795,7 +2815,7 @@ "valType": "number" }, "nticks": { - "description": "Sets the number of ticks. Has an effect only if `tickmode` is set to *auto*.", + "description": "Specifies the maximum number of ticks for the particular axis. The actual number of ticks will be chosen automatically to be less than or equal to `nticks`. Has an effect only if `tickmode` is set to *auto*.", "dflt": 6, "min": 1, "role": "style", @@ -3059,7 +3079,7 @@ "valType": "number" }, "nticks": { - "description": "Sets the number of ticks. Has an effect only if `tickmode` is set to *auto*.", + "description": "Specifies the maximum number of ticks for the particular axis. The actual number of ticks will be chosen automatically to be less than or equal to `nticks`. Has an effect only if `tickmode` is set to *auto*.", "dflt": 6, "min": 1, "role": "style", @@ -3329,7 +3349,7 @@ "valType": "number" }, "nticks": { - "description": "Sets the number of ticks. Has an effect only if `tickmode` is set to *auto*.", + "description": "Specifies the maximum number of ticks for the particular axis. The actual number of ticks will be chosen automatically to be less than or equal to `nticks`. Has an effect only if `tickmode` is set to *auto*.", "dflt": 6, "min": 1, "role": "style", @@ -3764,7 +3784,7 @@ ] }, "nticks": { - "description": "Sets the number of ticks. Has an effect only if `tickmode` is set to *auto*.", + "description": "Specifies the maximum number of ticks for the particular axis. The actual number of ticks will be chosen automatically to be less than or equal to `nticks`. Has an effect only if `tickmode` is set to *auto*.", "dflt": 0, "min": 0, "role": "style", @@ -4374,7 +4394,7 @@ ] }, "nticks": { - "description": "Sets the number of ticks. Has an effect only if `tickmode` is set to *auto*.", + "description": "Specifies the maximum number of ticks for the particular axis. The actual number of ticks will be chosen automatically to be less than or equal to `nticks`. Has an effect only if `tickmode` is set to *auto*.", "dflt": 0, "min": 0, "role": "style", @@ -4864,7 +4884,7 @@ "marker": { "color": { "arrayOk": true, - "description": "Sets the marker color. It accepts either a specific color or an array of values that are mapped to the colorscale relative to the max and min values of the array or relative to `cmin` and `cmax` if set.", + "description": "Sets the marker color. It accepts either a specific color or an array of numbers that are mapped to the colorscale relative to the max and min values of the array or relative to `cmin` and `cmax` if set.", "role": "style", "valType": "color" }, @@ -5529,13 +5549,13 @@ }, "marker": { "autocolorscale": { - "description": "Has an effect only if `marker.color` is set to a numerical array. Determines whether or not the colorscale is picked using values inside `marker.color`.", + "description": "Has an effect only if `marker.color` is set to a numerical array. Determines whether the colorscale is a default palette (`autocolorscale: true`) or the palette determined by `marker.colorscale`. In case `colorscale` is unspecified or `autocolorscale` is true, the default palette will be chosen according to whether numbers in the `color` array are all positive, all negative or mixed.", "dflt": true, "role": "style", "valType": "boolean" }, "cauto": { - "description": "Has an effect only if `marker.color` is set to a numerical array. Determines the whether or not the color domain is computed automatically.", + "description": "Has an effect only if `marker.color` is set to a numerical array and `cmin`, `cmax` are set by the user. In this case, it controls whether the range of colors in `colorscale` is mapped to the range of values in the `color` array (`cauto: true`), or the `cmin`/`cmax` values (`cauto: false`). Defaults to `false` when `cmin`, `cmax` are set by the user.", "dflt": true, "role": "info", "valType": "boolean" @@ -5554,7 +5574,7 @@ }, "color": { "arrayOk": true, - "description": "Sets the marker color. It accepts either a specific color or an array of values that are mapped to the colorscale relative to the max and min values of the array or relative to `cmin` and `cmax` if set.", + "description": "Sets the marker color. It accepts either a specific color or an array of numbers that are mapped to the colorscale relative to the max and min values of the array or relative to `cmin` and `cmax` if set.", "role": "style", "valType": "color" }, @@ -5616,7 +5636,7 @@ ] }, "nticks": { - "description": "Sets the number of ticks. Has an effect only if `tickmode` is set to *auto*.", + "description": "Specifies the maximum number of ticks for the particular axis. The actual number of ticks will be chosen automatically to be less than or equal to `nticks`. Has an effect only if `tickmode` is set to *auto*.", "dflt": 0, "min": 0, "role": "style", @@ -5897,7 +5917,7 @@ } }, "colorscale": { - "description": "Sets the colorscale and only has an effect if `marker.color` is set to a numerical array. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in color space, use `marker.cmin` and `marker.cmax`.", + "description": "Sets the colorscale and only has an effect if `marker.color` is set to a numerical array. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in color space, use `marker.cmin` and `marker.cmax`. Alternatively, `colorscale` may be a palette name string of the following list: Greys, YlGnBu, Greens, YlOrRd, Bluered, RdBu, Reds, Blues, Picnic, Rainbow, Portland, Jet, Hot, Blackbody, Earth, Electric, Viridis", "role": "style", "valType": "colorscale" }, @@ -5908,13 +5928,13 @@ }, "line": { "autocolorscale": { - "description": "Has an effect only if `marker.line.color` is set to a numerical array. Determines whether or not the colorscale is picked using values inside `marker.line.color`.", + "description": "Has an effect only if `marker.line.color` is set to a numerical array. Determines whether the colorscale is a default palette (`autocolorscale: true`) or the palette determined by `marker.line.colorscale`. In case `colorscale` is unspecified or `autocolorscale` is true, the default palette will be chosen according to whether numbers in the `color` array are all positive, all negative or mixed.", "dflt": true, "role": "style", "valType": "boolean" }, "cauto": { - "description": "Has an effect only if `marker.line.color` is set to a numerical array. Determines the whether or not the color domain is computed automatically.", + "description": "Has an effect only if `marker.line.color` is set to a numerical array and `cmin`, `cmax` are set by the user. In this case, it controls whether the range of colors in `colorscale` is mapped to the range of values in the `color` array (`cauto: true`), or the `cmin`/`cmax` values (`cauto: false`). Defaults to `false` when `cmin`, `cmax` are set by the user.", "dflt": true, "role": "info", "valType": "boolean" @@ -5933,12 +5953,12 @@ }, "color": { "arrayOk": true, - "description": "Sets the marker.line color. It accepts either a specific color or an array of values that are mapped to the colorscale relative to the max and min values of the array or relative to `cmin` and `cmax` if set.", + "description": "Sets the marker.line color. It accepts either a specific color or an array of numbers that are mapped to the colorscale relative to the max and min values of the array or relative to `cmin` and `cmax` if set.", "role": "style", "valType": "color" }, "colorscale": { - "description": "Sets the colorscale and only has an effect if `marker.line.color` is set to a numerical array. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in color space, use `marker.line.cmin` and `marker.line.cmax`.", + "description": "Sets the colorscale and only has an effect if `marker.line.color` is set to a numerical array. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in color space, use `marker.line.cmin` and `marker.line.cmax`. Alternatively, `colorscale` may be a palette name string of the following list: Greys, YlGnBu, Greens, YlOrRd, Bluered, RdBu, Reds, Blues, Picnic, Rainbow, Portland, Jet, Hot, Blackbody, Earth, Electric, Viridis", "role": "style", "valType": "colorscale" }, @@ -5948,7 +5968,7 @@ "valType": "string" }, "reversescale": { - "description": "Has an effect only if `marker.line.color` is set to a numerical array. Reverses the colorscale.", + "description": "Has an effect only if `marker.line.color` is set to a numerical array. Reverses the color mapping if true (`cmin` will correspond to the last color in the array and `cmax` will correspond to the first color).", "dflt": false, "role": "style", "valType": "boolean" @@ -5968,7 +5988,7 @@ } }, "reversescale": { - "description": "Has an effect only if `marker.color` is set to a numerical array. Reverses the colorscale.", + "description": "Has an effect only if `marker.color` is set to a numerical array. Reverses the color mapping if true (`cmin` will correspond to the last color in the array and `cmax` will correspond to the first color).", "dflt": false, "role": "style", "valType": "boolean" @@ -6239,14 +6259,14 @@ "marker": { "color": { "arrayOk": false, - "description": "Sets the marker color. It accepts either a specific color or an array of values that are mapped to the colorscale relative to the max and min values of the array or relative to `cmin` and `cmax` if set.", + "description": "Sets the marker color. It accepts either a specific color or an array of numbers that are mapped to the colorscale relative to the max and min values of the array or relative to `cmin` and `cmax` if set.", "role": "style", "valType": "color" }, "line": { "color": { "arrayOk": false, - "description": "Sets the marker.line color. It accepts either a specific color or an array of values that are mapped to the colorscale relative to the max and min values of the array or relative to `cmin` and `cmax` if set.", + "description": "Sets the marker.line color. It accepts either a specific color or an array of numbers that are mapped to the colorscale relative to the max and min values of the array or relative to `cmin` and `cmax` if set.", "dflt": "#444", "role": "style", "valType": "color" @@ -6806,7 +6826,7 @@ ] }, "nticks": { - "description": "Sets the number of ticks. Has an effect only if `tickmode` is set to *auto*.", + "description": "Specifies the maximum number of ticks for the particular axis. The actual number of ticks will be chosen automatically to be less than or equal to `nticks`. Has an effect only if `tickmode` is set to *auto*.", "dflt": 0, "min": 0, "role": "style", @@ -7144,7 +7164,7 @@ "line": { "color": { "arrayOk": true, - "description": "Sets the marker.line color. It accepts either a specific color or an array of values that are mapped to the colorscale relative to the max and min values of the array or relative to `cmin` and `cmax` if set.", + "description": "Sets the marker.line color. It accepts either a specific color or an array of numbers that are mapped to the colorscale relative to the max and min values of the array or relative to `cmin` and `cmax` if set.", "role": "style", "valType": "color" }, @@ -7346,7 +7366,7 @@ ] }, "nticks": { - "description": "Sets the number of ticks. Has an effect only if `tickmode` is set to *auto*.", + "description": "Specifies the maximum number of ticks for the particular axis. The actual number of ticks will be chosen automatically to be less than or equal to `nticks`. Has an effect only if `tickmode` is set to *auto*.", "dflt": 0, "min": 0, "role": "style", @@ -7754,7 +7774,7 @@ "valType": "string" }, "ncontours": { - "description": "Sets the number of contour levels. Has an effect only if `autocontour` is *true*.", + "description": "Sets the maximum number of contour levels. The actual number of contours will be chosen automatically to be less than or equal to the value of `ncontours`. Has an effect only if `autocontour` is *true*.", "dflt": 0, "role": "style", "valType": "integer" @@ -7993,7 +8013,7 @@ ] }, "nticks": { - "description": "Sets the number of ticks. Has an effect only if `tickmode` is set to *auto*.", + "description": "Specifies the maximum number of ticks for the particular axis. The actual number of ticks will be chosen automatically to be less than or equal to `nticks`. Has an effect only if `tickmode` is set to *auto*.", "dflt": 0, "min": 0, "role": "style", @@ -8785,13 +8805,13 @@ }, "marker": { "autocolorscale": { - "description": "Has an effect only if `marker.color` is set to a numerical array. Determines whether or not the colorscale is picked using values inside `marker.color`.", + "description": "Has an effect only if `marker.color` is set to a numerical array. Determines whether the colorscale is a default palette (`autocolorscale: true`) or the palette determined by `marker.colorscale`. In case `colorscale` is unspecified or `autocolorscale` is true, the default palette will be chosen according to whether numbers in the `color` array are all positive, all negative or mixed.", "dflt": true, "role": "style", "valType": "boolean" }, "cauto": { - "description": "Has an effect only if `marker.color` is set to a numerical array. Determines the whether or not the color domain is computed automatically.", + "description": "Has an effect only if `marker.color` is set to a numerical array and `cmin`, `cmax` are set by the user. In this case, it controls whether the range of colors in `colorscale` is mapped to the range of values in the `color` array (`cauto: true`), or the `cmin`/`cmax` values (`cauto: false`). Defaults to `false` when `cmin`, `cmax` are set by the user.", "dflt": true, "role": "info", "valType": "boolean" @@ -8810,7 +8830,7 @@ }, "color": { "arrayOk": true, - "description": "Sets the marker color. It accepts either a specific color or an array of values that are mapped to the colorscale relative to the max and min values of the array or relative to `cmin` and `cmax` if set.", + "description": "Sets the marker color. It accepts either a specific color or an array of numbers that are mapped to the colorscale relative to the max and min values of the array or relative to `cmin` and `cmax` if set.", "role": "style", "valType": "color" }, @@ -8872,7 +8892,7 @@ ] }, "nticks": { - "description": "Sets the number of ticks. Has an effect only if `tickmode` is set to *auto*.", + "description": "Specifies the maximum number of ticks for the particular axis. The actual number of ticks will be chosen automatically to be less than or equal to `nticks`. Has an effect only if `tickmode` is set to *auto*.", "dflt": 0, "min": 0, "role": "style", @@ -9153,7 +9173,7 @@ } }, "colorscale": { - "description": "Sets the colorscale and only has an effect if `marker.color` is set to a numerical array. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in color space, use `marker.cmin` and `marker.cmax`.", + "description": "Sets the colorscale and only has an effect if `marker.color` is set to a numerical array. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in color space, use `marker.cmin` and `marker.cmax`. Alternatively, `colorscale` may be a palette name string of the following list: Greys, YlGnBu, Greens, YlOrRd, Bluered, RdBu, Reds, Blues, Picnic, Rainbow, Portland, Jet, Hot, Blackbody, Earth, Electric, Viridis", "role": "style", "valType": "colorscale" }, @@ -9164,13 +9184,13 @@ }, "line": { "autocolorscale": { - "description": "Has an effect only if `marker.line.color` is set to a numerical array. Determines whether or not the colorscale is picked using values inside `marker.line.color`.", + "description": "Has an effect only if `marker.line.color` is set to a numerical array. Determines whether the colorscale is a default palette (`autocolorscale: true`) or the palette determined by `marker.line.colorscale`. In case `colorscale` is unspecified or `autocolorscale` is true, the default palette will be chosen according to whether numbers in the `color` array are all positive, all negative or mixed.", "dflt": true, "role": "style", "valType": "boolean" }, "cauto": { - "description": "Has an effect only if `marker.line.color` is set to a numerical array. Determines the whether or not the color domain is computed automatically.", + "description": "Has an effect only if `marker.line.color` is set to a numerical array and `cmin`, `cmax` are set by the user. In this case, it controls whether the range of colors in `colorscale` is mapped to the range of values in the `color` array (`cauto: true`), or the `cmin`/`cmax` values (`cauto: false`). Defaults to `false` when `cmin`, `cmax` are set by the user.", "dflt": true, "role": "info", "valType": "boolean" @@ -9189,12 +9209,12 @@ }, "color": { "arrayOk": true, - "description": "Sets the marker.line color. It accepts either a specific color or an array of values that are mapped to the colorscale relative to the max and min values of the array or relative to `cmin` and `cmax` if set.", + "description": "Sets the marker.line color. It accepts either a specific color or an array of numbers that are mapped to the colorscale relative to the max and min values of the array or relative to `cmin` and `cmax` if set.", "role": "style", "valType": "color" }, "colorscale": { - "description": "Sets the colorscale and only has an effect if `marker.line.color` is set to a numerical array. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in color space, use `marker.line.cmin` and `marker.line.cmax`.", + "description": "Sets the colorscale and only has an effect if `marker.line.color` is set to a numerical array. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in color space, use `marker.line.cmin` and `marker.line.cmax`. Alternatively, `colorscale` may be a palette name string of the following list: Greys, YlGnBu, Greens, YlOrRd, Bluered, RdBu, Reds, Blues, Picnic, Rainbow, Portland, Jet, Hot, Blackbody, Earth, Electric, Viridis", "role": "style", "valType": "colorscale" }, @@ -9204,7 +9224,7 @@ "valType": "string" }, "reversescale": { - "description": "Has an effect only if `marker.line.color` is set to a numerical array. Reverses the colorscale.", + "description": "Has an effect only if `marker.line.color` is set to a numerical array. Reverses the color mapping if true (`cmin` will correspond to the last color in the array and `cmax` will correspond to the first color).", "dflt": false, "role": "style", "valType": "boolean" @@ -9225,7 +9245,7 @@ } }, "reversescale": { - "description": "Has an effect only if `marker.color` is set to a numerical array. Reverses the colorscale.", + "description": "Has an effect only if `marker.color` is set to a numerical array. Reverses the color mapping if true (`cmin` will correspond to the last color in the array and `cmax` will correspond to the first color).", "dflt": false, "role": "style", "valType": "boolean" @@ -9520,7 +9540,7 @@ ] }, "nticks": { - "description": "Sets the number of ticks. Has an effect only if `tickmode` is set to *auto*.", + "description": "Specifies the maximum number of ticks for the particular axis. The actual number of ticks will be chosen automatically to be less than or equal to `nticks`. Has an effect only if `tickmode` is set to *auto*.", "dflt": 0, "min": 0, "role": "style", @@ -10146,7 +10166,7 @@ ] }, "nticks": { - "description": "Sets the number of ticks. Has an effect only if `tickmode` is set to *auto*.", + "description": "Specifies the maximum number of ticks for the particular axis. The actual number of ticks will be chosen automatically to be less than or equal to `nticks`. Has an effect only if `tickmode` is set to *auto*.", "dflt": 0, "min": 0, "role": "style", @@ -10589,7 +10609,7 @@ "valType": "integer" }, "ncontours": { - "description": "Sets the number of contour levels. Has an effect only if `autocontour` is *true*.", + "description": "Sets the maximum number of contour levels. The actual number of contours will be chosen automatically to be less than or equal to the value of `ncontours`. Has an effect only if `autocontour` is *true*.", "dflt": 0, "role": "style", "valType": "integer" @@ -10830,7 +10850,7 @@ ] }, "nticks": { - "description": "Sets the number of ticks. Has an effect only if `tickmode` is set to *auto*.", + "description": "Specifies the maximum number of ticks for the particular axis. The actual number of ticks will be chosen automatically to be less than or equal to `nticks`. Has an effect only if `tickmode` is set to *auto*.", "dflt": 0, "min": 0, "role": "style", @@ -12053,6 +12073,15 @@ "role": "info", "valType": "flaglist" }, + "hoveron": { + "description": "Do the hover effects highlight individual points (markers or line points) or do they highlight filled regions? If the fill is *toself* or *tonext* and there are no markers or text, then the default is *fills*, otherwise it is *points*.", + "flags": [ + "points", + "fills" + ], + "role": "info", + "valType": "flaglist" + }, "legendgroup": { "description": "Sets the legend group for this trace. Traces part of the same legend group hide/show at the same time when toggling legend items.", "dflt": "", @@ -12112,13 +12141,13 @@ }, "marker": { "autocolorscale": { - "description": "Has an effect only if `marker.color` is set to a numerical array. Determines whether or not the colorscale is picked using values inside `marker.color`.", + "description": "Has an effect only if `marker.color` is set to a numerical array. Determines whether the colorscale is a default palette (`autocolorscale: true`) or the palette determined by `marker.colorscale`. In case `colorscale` is unspecified or `autocolorscale` is true, the default palette will be chosen according to whether numbers in the `color` array are all positive, all negative or mixed.", "dflt": true, "role": "style", "valType": "boolean" }, "cauto": { - "description": "Has an effect only if `marker.color` is set to a numerical array. Determines the whether or not the color domain is computed automatically.", + "description": "Has an effect only if `marker.color` is set to a numerical array and `cmin`, `cmax` are set by the user. In this case, it controls whether the range of colors in `colorscale` is mapped to the range of values in the `color` array (`cauto: true`), or the `cmin`/`cmax` values (`cauto: false`). Defaults to `false` when `cmin`, `cmax` are set by the user.", "dflt": true, "role": "info", "valType": "boolean" @@ -12137,7 +12166,7 @@ }, "color": { "arrayOk": true, - "description": "Sets the marker color. It accepts either a specific color or an array of values that are mapped to the colorscale relative to the max and min values of the array or relative to `cmin` and `cmax` if set.", + "description": "Sets the marker color. It accepts either a specific color or an array of numbers that are mapped to the colorscale relative to the max and min values of the array or relative to `cmin` and `cmax` if set.", "role": "style", "valType": "color" }, @@ -12199,7 +12228,7 @@ ] }, "nticks": { - "description": "Sets the number of ticks. Has an effect only if `tickmode` is set to *auto*.", + "description": "Specifies the maximum number of ticks for the particular axis. The actual number of ticks will be chosen automatically to be less than or equal to `nticks`. Has an effect only if `tickmode` is set to *auto*.", "dflt": 0, "min": 0, "role": "style", @@ -12480,7 +12509,7 @@ } }, "colorscale": { - "description": "Sets the colorscale and only has an effect if `marker.color` is set to a numerical array. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in color space, use `marker.cmin` and `marker.cmax`.", + "description": "Sets the colorscale and only has an effect if `marker.color` is set to a numerical array. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in color space, use `marker.cmin` and `marker.cmax`. Alternatively, `colorscale` may be a palette name string of the following list: Greys, YlGnBu, Greens, YlOrRd, Bluered, RdBu, Reds, Blues, Picnic, Rainbow, Portland, Jet, Hot, Blackbody, Earth, Electric, Viridis", "role": "style", "valType": "colorscale" }, @@ -12491,13 +12520,13 @@ }, "line": { "autocolorscale": { - "description": "Has an effect only if `marker.line.color` is set to a numerical array. Determines whether or not the colorscale is picked using values inside `marker.line.color`.", + "description": "Has an effect only if `marker.line.color` is set to a numerical array. Determines whether the colorscale is a default palette (`autocolorscale: true`) or the palette determined by `marker.line.colorscale`. In case `colorscale` is unspecified or `autocolorscale` is true, the default palette will be chosen according to whether numbers in the `color` array are all positive, all negative or mixed.", "dflt": true, "role": "style", "valType": "boolean" }, "cauto": { - "description": "Has an effect only if `marker.line.color` is set to a numerical array. Determines the whether or not the color domain is computed automatically.", + "description": "Has an effect only if `marker.line.color` is set to a numerical array and `cmin`, `cmax` are set by the user. In this case, it controls whether the range of colors in `colorscale` is mapped to the range of values in the `color` array (`cauto: true`), or the `cmin`/`cmax` values (`cauto: false`). Defaults to `false` when `cmin`, `cmax` are set by the user.", "dflt": true, "role": "info", "valType": "boolean" @@ -12516,12 +12545,12 @@ }, "color": { "arrayOk": true, - "description": "Sets the marker.line color. It accepts either a specific color or an array of values that are mapped to the colorscale relative to the max and min values of the array or relative to `cmin` and `cmax` if set.", + "description": "Sets the marker.line color. It accepts either a specific color or an array of numbers that are mapped to the colorscale relative to the max and min values of the array or relative to `cmin` and `cmax` if set.", "role": "style", "valType": "color" }, "colorscale": { - "description": "Sets the colorscale and only has an effect if `marker.line.color` is set to a numerical array. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in color space, use `marker.line.cmin` and `marker.line.cmax`.", + "description": "Sets the colorscale and only has an effect if `marker.line.color` is set to a numerical array. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in color space, use `marker.line.cmin` and `marker.line.cmax`. Alternatively, `colorscale` may be a palette name string of the following list: Greys, YlGnBu, Greens, YlOrRd, Bluered, RdBu, Reds, Blues, Picnic, Rainbow, Portland, Jet, Hot, Blackbody, Earth, Electric, Viridis", "role": "style", "valType": "colorscale" }, @@ -12531,7 +12560,7 @@ "valType": "string" }, "reversescale": { - "description": "Has an effect only if `marker.line.color` is set to a numerical array. Reverses the colorscale.", + "description": "Has an effect only if `marker.line.color` is set to a numerical array. Reverses the color mapping if true (`cmin` will correspond to the last color in the array and `cmax` will correspond to the first color).", "dflt": false, "role": "style", "valType": "boolean" @@ -12571,7 +12600,7 @@ "valType": "string" }, "reversescale": { - "description": "Has an effect only if `marker.color` is set to a numerical array. Reverses the colorscale.", + "description": "Has an effect only if `marker.color` is set to a numerical array. Reverses the color mapping if true (`cmin` will correspond to the last color in the array and `cmax` will correspond to the first color).", "dflt": false, "role": "style", "valType": "boolean" @@ -13463,11 +13492,46 @@ "valType": "string" }, "line": { + "autocolorscale": { + "description": "Has an effect only if `line.color` is set to a numerical array. Determines whether the colorscale is a default palette (`autocolorscale: true`) or the palette determined by `line.colorscale`. In case `colorscale` is unspecified or `autocolorscale` is true, the default palette will be chosen according to whether numbers in the `color` array are all positive, all negative or mixed.", + "dflt": true, + "role": "style", + "valType": "boolean" + }, + "cauto": { + "description": "Has an effect only if `line.color` is set to a numerical array and `cmin`, `cmax` are set by the user. In this case, it controls whether the range of colors in `colorscale` is mapped to the range of values in the `color` array (`cauto: true`), or the `cmin`/`cmax` values (`cauto: false`). Defaults to `false` when `cmin`, `cmax` are set by the user.", + "dflt": true, + "role": "info", + "valType": "boolean" + }, + "cmax": { + "description": "Has an effect only if `line.color` is set to a numerical array. Sets the upper bound of the color domain. Value should be associated to the `line.color` array index, and if set, `line.cmin` must be set as well.", + "dflt": null, + "role": "info", + "valType": "number" + }, + "cmin": { + "description": "Has an effect only if `line.color` is set to a numerical array. Sets the lower bound of the color domain. Value should be associated to the `line.color` array index, and if set, `line.cmax` must be set as well.", + "dflt": null, + "role": "info", + "valType": "number" + }, "color": { - "description": "Sets the line color.", + "arrayOk": true, + "description": "Sets the line color. It accepts either a specific color or an array of numbers that are mapped to the colorscale relative to the max and min values of the array or relative to `cmin` and `cmax` if set.", "role": "style", "valType": "color" }, + "colorscale": { + "description": "Sets the colorscale and only has an effect if `line.color` is set to a numerical array. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in color space, use `line.cmin` and `line.cmax`. Alternatively, `colorscale` may be a palette name string of the following list: Greys, YlGnBu, Greens, YlOrRd, Bluered, RdBu, Reds, Blues, Picnic, Rainbow, Portland, Jet, Hot, Blackbody, Earth, Electric, Viridis", + "role": "style", + "valType": "colorscale" + }, + "colorsrc": { + "description": "Sets the source reference on plot.ly for color .", + "role": "info", + "valType": "string" + }, "dash": { "description": "Sets the style of the lines. Set to a dash string type or a dash length in px.", "dflt": "solid", @@ -13482,7 +13546,19 @@ "longdashdot" ] }, + "reversescale": { + "description": "Has an effect only if `line.color` is set to a numerical array. Reverses the color mapping if true (`cmin` will correspond to the last color in the array and `cmax` will correspond to the first color).", + "dflt": false, + "role": "style", + "valType": "boolean" + }, "role": "object", + "showscale": { + "description": "Has an effect only if `line.color` is set to a numerical array. Determines whether or not a colorbar is displayed.", + "dflt": false, + "role": "info", + "valType": "boolean" + }, "width": { "description": "Sets the line width (in px).", "dflt": 2, @@ -13493,13 +13569,13 @@ }, "marker": { "autocolorscale": { - "description": "Has an effect only if `marker.color` is set to a numerical array. Determines whether or not the colorscale is picked using values inside `marker.color`.", + "description": "Has an effect only if `marker.color` is set to a numerical array. Determines whether the colorscale is a default palette (`autocolorscale: true`) or the palette determined by `marker.colorscale`. In case `colorscale` is unspecified or `autocolorscale` is true, the default palette will be chosen according to whether numbers in the `color` array are all positive, all negative or mixed.", "dflt": true, "role": "style", "valType": "boolean" }, "cauto": { - "description": "Has an effect only if `marker.color` is set to a numerical array. Determines the whether or not the color domain is computed automatically.", + "description": "Has an effect only if `marker.color` is set to a numerical array and `cmin`, `cmax` are set by the user. In this case, it controls whether the range of colors in `colorscale` is mapped to the range of values in the `color` array (`cauto: true`), or the `cmin`/`cmax` values (`cauto: false`). Defaults to `false` when `cmin`, `cmax` are set by the user.", "dflt": true, "role": "info", "valType": "boolean" @@ -13518,7 +13594,7 @@ }, "color": { "arrayOk": true, - "description": "Sets the marker color. It accepts either a specific color or an array of values that are mapped to the colorscale relative to the max and min values of the array or relative to `cmin` and `cmax` if set.", + "description": "Sets the marker color. It accepts either a specific color or an array of numbers that are mapped to the colorscale relative to the max and min values of the array or relative to `cmin` and `cmax` if set.", "role": "style", "valType": "color" }, @@ -13580,7 +13656,7 @@ ] }, "nticks": { - "description": "Sets the number of ticks. Has an effect only if `tickmode` is set to *auto*.", + "description": "Specifies the maximum number of ticks for the particular axis. The actual number of ticks will be chosen automatically to be less than or equal to `nticks`. Has an effect only if `tickmode` is set to *auto*.", "dflt": 0, "min": 0, "role": "style", @@ -13861,7 +13937,7 @@ } }, "colorscale": { - "description": "Sets the colorscale and only has an effect if `marker.color` is set to a numerical array. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in color space, use `marker.cmin` and `marker.cmax`.", + "description": "Sets the colorscale and only has an effect if `marker.color` is set to a numerical array. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in color space, use `marker.cmin` and `marker.cmax`. Alternatively, `colorscale` may be a palette name string of the following list: Greys, YlGnBu, Greens, YlOrRd, Bluered, RdBu, Reds, Blues, Picnic, Rainbow, Portland, Jet, Hot, Blackbody, Earth, Electric, Viridis", "role": "style", "valType": "colorscale" }, @@ -13872,13 +13948,13 @@ }, "line": { "autocolorscale": { - "description": "Has an effect only if `marker.line.color` is set to a numerical array. Determines whether or not the colorscale is picked using values inside `marker.line.color`.", + "description": "Has an effect only if `marker.line.color` is set to a numerical array. Determines whether the colorscale is a default palette (`autocolorscale: true`) or the palette determined by `marker.line.colorscale`. In case `colorscale` is unspecified or `autocolorscale` is true, the default palette will be chosen according to whether numbers in the `color` array are all positive, all negative or mixed.", "dflt": true, "role": "style", "valType": "boolean" }, "cauto": { - "description": "Has an effect only if `marker.line.color` is set to a numerical array. Determines the whether or not the color domain is computed automatically.", + "description": "Has an effect only if `marker.line.color` is set to a numerical array and `cmin`, `cmax` are set by the user. In this case, it controls whether the range of colors in `colorscale` is mapped to the range of values in the `color` array (`cauto: true`), or the `cmin`/`cmax` values (`cauto: false`). Defaults to `false` when `cmin`, `cmax` are set by the user.", "dflt": true, "role": "info", "valType": "boolean" @@ -13897,12 +13973,12 @@ }, "color": { "arrayOk": true, - "description": "Sets the marker.line color. It accepts either a specific color or an array of values that are mapped to the colorscale relative to the max and min values of the array or relative to `cmin` and `cmax` if set.", + "description": "Sets the marker.line color. It accepts either a specific color or an array of numbers that are mapped to the colorscale relative to the max and min values of the array or relative to `cmin` and `cmax` if set.", "role": "style", "valType": "color" }, "colorscale": { - "description": "Sets the colorscale and only has an effect if `marker.line.color` is set to a numerical array. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in color space, use `marker.line.cmin` and `marker.line.cmax`.", + "description": "Sets the colorscale and only has an effect if `marker.line.color` is set to a numerical array. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in color space, use `marker.line.cmin` and `marker.line.cmax`. Alternatively, `colorscale` may be a palette name string of the following list: Greys, YlGnBu, Greens, YlOrRd, Bluered, RdBu, Reds, Blues, Picnic, Rainbow, Portland, Jet, Hot, Blackbody, Earth, Electric, Viridis", "role": "style", "valType": "colorscale" }, @@ -13912,7 +13988,7 @@ "valType": "string" }, "reversescale": { - "description": "Has an effect only if `marker.line.color` is set to a numerical array. Reverses the colorscale.", + "description": "Has an effect only if `marker.line.color` is set to a numerical array. Reverses the color mapping if true (`cmin` will correspond to the last color in the array and `cmax` will correspond to the first color).", "dflt": false, "role": "style", "valType": "boolean" @@ -13935,7 +14011,7 @@ "valType": "number" }, "reversescale": { - "description": "Has an effect only if `marker.color` is set to a numerical array. Reverses the colorscale.", + "description": "Has an effect only if `marker.color` is set to a numerical array. Reverses the color mapping if true (`cmin` will correspond to the last color in the array and `cmax` will correspond to the first color).", "dflt": false, "role": "style", "valType": "boolean" @@ -14382,13 +14458,13 @@ }, "marker": { "autocolorscale": { - "description": "Has an effect only if `marker.color` is set to a numerical array. Determines whether or not the colorscale is picked using values inside `marker.color`.", + "description": "Has an effect only if `marker.color` is set to a numerical array. Determines whether the colorscale is a default palette (`autocolorscale: true`) or the palette determined by `marker.colorscale`. In case `colorscale` is unspecified or `autocolorscale` is true, the default palette will be chosen according to whether numbers in the `color` array are all positive, all negative or mixed.", "dflt": true, "role": "style", "valType": "boolean" }, "cauto": { - "description": "Has an effect only if `marker.color` is set to a numerical array. Determines the whether or not the color domain is computed automatically.", + "description": "Has an effect only if `marker.color` is set to a numerical array and `cmin`, `cmax` are set by the user. In this case, it controls whether the range of colors in `colorscale` is mapped to the range of values in the `color` array (`cauto: true`), or the `cmin`/`cmax` values (`cauto: false`). Defaults to `false` when `cmin`, `cmax` are set by the user.", "dflt": true, "role": "info", "valType": "boolean" @@ -14407,7 +14483,7 @@ }, "color": { "arrayOk": true, - "description": "Sets the marker color. It accepts either a specific color or an array of values that are mapped to the colorscale relative to the max and min values of the array or relative to `cmin` and `cmax` if set.", + "description": "Sets the marker color. It accepts either a specific color or an array of numbers that are mapped to the colorscale relative to the max and min values of the array or relative to `cmin` and `cmax` if set.", "role": "style", "valType": "color" }, @@ -14469,7 +14545,7 @@ ] }, "nticks": { - "description": "Sets the number of ticks. Has an effect only if `tickmode` is set to *auto*.", + "description": "Specifies the maximum number of ticks for the particular axis. The actual number of ticks will be chosen automatically to be less than or equal to `nticks`. Has an effect only if `tickmode` is set to *auto*.", "dflt": 0, "min": 0, "role": "style", @@ -14750,7 +14826,7 @@ } }, "colorscale": { - "description": "Sets the colorscale and only has an effect if `marker.color` is set to a numerical array. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in color space, use `marker.cmin` and `marker.cmax`.", + "description": "Sets the colorscale and only has an effect if `marker.color` is set to a numerical array. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in color space, use `marker.cmin` and `marker.cmax`. Alternatively, `colorscale` may be a palette name string of the following list: Greys, YlGnBu, Greens, YlOrRd, Bluered, RdBu, Reds, Blues, Picnic, Rainbow, Portland, Jet, Hot, Blackbody, Earth, Electric, Viridis", "role": "style", "valType": "colorscale" }, @@ -14761,13 +14837,13 @@ }, "line": { "autocolorscale": { - "description": "Has an effect only if `marker.line.color` is set to a numerical array. Determines whether or not the colorscale is picked using values inside `marker.line.color`.", + "description": "Has an effect only if `marker.line.color` is set to a numerical array. Determines whether the colorscale is a default palette (`autocolorscale: true`) or the palette determined by `marker.line.colorscale`. In case `colorscale` is unspecified or `autocolorscale` is true, the default palette will be chosen according to whether numbers in the `color` array are all positive, all negative or mixed.", "dflt": true, "role": "style", "valType": "boolean" }, "cauto": { - "description": "Has an effect only if `marker.line.color` is set to a numerical array. Determines the whether or not the color domain is computed automatically.", + "description": "Has an effect only if `marker.line.color` is set to a numerical array and `cmin`, `cmax` are set by the user. In this case, it controls whether the range of colors in `colorscale` is mapped to the range of values in the `color` array (`cauto: true`), or the `cmin`/`cmax` values (`cauto: false`). Defaults to `false` when `cmin`, `cmax` are set by the user.", "dflt": true, "role": "info", "valType": "boolean" @@ -14786,12 +14862,12 @@ }, "color": { "arrayOk": true, - "description": "Sets the marker.line color. It accepts either a specific color or an array of values that are mapped to the colorscale relative to the max and min values of the array or relative to `cmin` and `cmax` if set.", + "description": "Sets the marker.line color. It accepts either a specific color or an array of numbers that are mapped to the colorscale relative to the max and min values of the array or relative to `cmin` and `cmax` if set.", "role": "style", "valType": "color" }, "colorscale": { - "description": "Sets the colorscale and only has an effect if `marker.line.color` is set to a numerical array. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in color space, use `marker.line.cmin` and `marker.line.cmax`.", + "description": "Sets the colorscale and only has an effect if `marker.line.color` is set to a numerical array. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in color space, use `marker.line.cmin` and `marker.line.cmax`. Alternatively, `colorscale` may be a palette name string of the following list: Greys, YlGnBu, Greens, YlOrRd, Bluered, RdBu, Reds, Blues, Picnic, Rainbow, Portland, Jet, Hot, Blackbody, Earth, Electric, Viridis", "role": "style", "valType": "colorscale" }, @@ -14801,7 +14877,7 @@ "valType": "string" }, "reversescale": { - "description": "Has an effect only if `marker.line.color` is set to a numerical array. Reverses the colorscale.", + "description": "Has an effect only if `marker.line.color` is set to a numerical array. Reverses the color mapping if true (`cmin` will correspond to the last color in the array and `cmax` will correspond to the first color).", "dflt": false, "role": "style", "valType": "boolean" @@ -14834,7 +14910,7 @@ "valType": "string" }, "reversescale": { - "description": "Has an effect only if `marker.color` is set to a numerical array. Reverses the colorscale.", + "description": "Has an effect only if `marker.color` is set to a numerical array. Reverses the color mapping if true (`cmin` will correspond to the last color in the array and `cmax` will correspond to the first color).", "dflt": false, "role": "style", "valType": "boolean" @@ -15619,13 +15695,13 @@ }, "marker": { "autocolorscale": { - "description": "Has an effect only if `marker.color` is set to a numerical array. Determines whether or not the colorscale is picked using values inside `marker.color`.", + "description": "Has an effect only if `marker.color` is set to a numerical array. Determines whether the colorscale is a default palette (`autocolorscale: true`) or the palette determined by `marker.colorscale`. In case `colorscale` is unspecified or `autocolorscale` is true, the default palette will be chosen according to whether numbers in the `color` array are all positive, all negative or mixed.", "dflt": true, "role": "style", "valType": "boolean" }, "cauto": { - "description": "Has an effect only if `marker.color` is set to a numerical array. Determines the whether or not the color domain is computed automatically.", + "description": "Has an effect only if `marker.color` is set to a numerical array and `cmin`, `cmax` are set by the user. In this case, it controls whether the range of colors in `colorscale` is mapped to the range of values in the `color` array (`cauto: true`), or the `cmin`/`cmax` values (`cauto: false`). Defaults to `false` when `cmin`, `cmax` are set by the user.", "dflt": true, "role": "info", "valType": "boolean" @@ -15644,7 +15720,7 @@ }, "color": { "arrayOk": true, - "description": "Sets the marker color. It accepts either a specific color or an array of values that are mapped to the colorscale relative to the max and min values of the array or relative to `cmin` and `cmax` if set.", + "description": "Sets the marker color. It accepts either a specific color or an array of numbers that are mapped to the colorscale relative to the max and min values of the array or relative to `cmin` and `cmax` if set.", "role": "style", "valType": "color" }, @@ -15706,7 +15782,7 @@ ] }, "nticks": { - "description": "Sets the number of ticks. Has an effect only if `tickmode` is set to *auto*.", + "description": "Specifies the maximum number of ticks for the particular axis. The actual number of ticks will be chosen automatically to be less than or equal to `nticks`. Has an effect only if `tickmode` is set to *auto*.", "dflt": 0, "min": 0, "role": "style", @@ -15987,7 +16063,7 @@ } }, "colorscale": { - "description": "Sets the colorscale and only has an effect if `marker.color` is set to a numerical array. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in color space, use `marker.cmin` and `marker.cmax`.", + "description": "Sets the colorscale and only has an effect if `marker.color` is set to a numerical array. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in color space, use `marker.cmin` and `marker.cmax`. Alternatively, `colorscale` may be a palette name string of the following list: Greys, YlGnBu, Greens, YlOrRd, Bluered, RdBu, Reds, Blues, Picnic, Rainbow, Portland, Jet, Hot, Blackbody, Earth, Electric, Viridis", "role": "style", "valType": "colorscale" }, @@ -15998,13 +16074,13 @@ }, "line": { "autocolorscale": { - "description": "Has an effect only if `marker.line.color` is set to a numerical array. Determines whether or not the colorscale is picked using values inside `marker.line.color`.", + "description": "Has an effect only if `marker.line.color` is set to a numerical array. Determines whether the colorscale is a default palette (`autocolorscale: true`) or the palette determined by `marker.line.colorscale`. In case `colorscale` is unspecified or `autocolorscale` is true, the default palette will be chosen according to whether numbers in the `color` array are all positive, all negative or mixed.", "dflt": true, "role": "style", "valType": "boolean" }, "cauto": { - "description": "Has an effect only if `marker.line.color` is set to a numerical array. Determines the whether or not the color domain is computed automatically.", + "description": "Has an effect only if `marker.line.color` is set to a numerical array and `cmin`, `cmax` are set by the user. In this case, it controls whether the range of colors in `colorscale` is mapped to the range of values in the `color` array (`cauto: true`), or the `cmin`/`cmax` values (`cauto: false`). Defaults to `false` when `cmin`, `cmax` are set by the user.", "dflt": true, "role": "info", "valType": "boolean" @@ -16023,12 +16099,12 @@ }, "color": { "arrayOk": true, - "description": "Sets the marker.line color. It accepts either a specific color or an array of values that are mapped to the colorscale relative to the max and min values of the array or relative to `cmin` and `cmax` if set.", + "description": "Sets the marker.line color. It accepts either a specific color or an array of numbers that are mapped to the colorscale relative to the max and min values of the array or relative to `cmin` and `cmax` if set.", "role": "style", "valType": "color" }, "colorscale": { - "description": "Sets the colorscale and only has an effect if `marker.line.color` is set to a numerical array. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in color space, use `marker.line.cmin` and `marker.line.cmax`.", + "description": "Sets the colorscale and only has an effect if `marker.line.color` is set to a numerical array. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in color space, use `marker.line.cmin` and `marker.line.cmax`. Alternatively, `colorscale` may be a palette name string of the following list: Greys, YlGnBu, Greens, YlOrRd, Bluered, RdBu, Reds, Blues, Picnic, Rainbow, Portland, Jet, Hot, Blackbody, Earth, Electric, Viridis", "role": "style", "valType": "colorscale" }, @@ -16038,7 +16114,7 @@ "valType": "string" }, "reversescale": { - "description": "Has an effect only if `marker.line.color` is set to a numerical array. Reverses the colorscale.", + "description": "Has an effect only if `marker.line.color` is set to a numerical array. Reverses the color mapping if true (`cmin` will correspond to the last color in the array and `cmax` will correspond to the first color).", "dflt": false, "role": "style", "valType": "boolean" @@ -16071,7 +16147,7 @@ "valType": "string" }, "reversescale": { - "description": "Has an effect only if `marker.color` is set to a numerical array. Reverses the colorscale.", + "description": "Has an effect only if `marker.color` is set to a numerical array. Reverses the color mapping if true (`cmin` will correspond to the last color in the array and `cmax` will correspond to the first color).", "dflt": false, "role": "style", "valType": "boolean" @@ -16336,6 +16412,15 @@ "role": "info", "valType": "flaglist" }, + "hoveron": { + "description": "Do the hover effects highlight individual points (markers or line points) or do they highlight filled regions? If the fill is *toself* or *tonext* and there are no markers or text, then the default is *fills*, otherwise it is *points*.", + "flags": [ + "points", + "fills" + ], + "role": "info", + "valType": "flaglist" + }, "legendgroup": { "description": "Sets the legend group for this trace. Traces part of the same legend group hide/show at the same time when toggling legend items.", "dflt": "", @@ -16391,13 +16476,13 @@ }, "marker": { "autocolorscale": { - "description": "Has an effect only if `marker.color` is set to a numerical array. Determines whether or not the colorscale is picked using values inside `marker.color`.", + "description": "Has an effect only if `marker.color` is set to a numerical array. Determines whether the colorscale is a default palette (`autocolorscale: true`) or the palette determined by `marker.colorscale`. In case `colorscale` is unspecified or `autocolorscale` is true, the default palette will be chosen according to whether numbers in the `color` array are all positive, all negative or mixed.", "dflt": true, "role": "style", "valType": "boolean" }, "cauto": { - "description": "Has an effect only if `marker.color` is set to a numerical array. Determines the whether or not the color domain is computed automatically.", + "description": "Has an effect only if `marker.color` is set to a numerical array and `cmin`, `cmax` are set by the user. In this case, it controls whether the range of colors in `colorscale` is mapped to the range of values in the `color` array (`cauto: true`), or the `cmin`/`cmax` values (`cauto: false`). Defaults to `false` when `cmin`, `cmax` are set by the user.", "dflt": true, "role": "info", "valType": "boolean" @@ -16416,7 +16501,7 @@ }, "color": { "arrayOk": true, - "description": "Sets the marker color. It accepts either a specific color or an array of values that are mapped to the colorscale relative to the max and min values of the array or relative to `cmin` and `cmax` if set.", + "description": "Sets the marker color. It accepts either a specific color or an array of numbers that are mapped to the colorscale relative to the max and min values of the array or relative to `cmin` and `cmax` if set.", "role": "style", "valType": "color" }, @@ -16478,7 +16563,7 @@ ] }, "nticks": { - "description": "Sets the number of ticks. Has an effect only if `tickmode` is set to *auto*.", + "description": "Specifies the maximum number of ticks for the particular axis. The actual number of ticks will be chosen automatically to be less than or equal to `nticks`. Has an effect only if `tickmode` is set to *auto*.", "dflt": 0, "min": 0, "role": "style", @@ -16759,7 +16844,7 @@ } }, "colorscale": { - "description": "Sets the colorscale and only has an effect if `marker.color` is set to a numerical array. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in color space, use `marker.cmin` and `marker.cmax`.", + "description": "Sets the colorscale and only has an effect if `marker.color` is set to a numerical array. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in color space, use `marker.cmin` and `marker.cmax`. Alternatively, `colorscale` may be a palette name string of the following list: Greys, YlGnBu, Greens, YlOrRd, Bluered, RdBu, Reds, Blues, Picnic, Rainbow, Portland, Jet, Hot, Blackbody, Earth, Electric, Viridis", "role": "style", "valType": "colorscale" }, @@ -16770,13 +16855,13 @@ }, "line": { "autocolorscale": { - "description": "Has an effect only if `.color` is set to a numerical array. Determines whether or not the colorscale is picked using values inside `.color`.", + "description": "Has an effect only if `.color` is set to a numerical array. Determines whether the colorscale is a default palette (`autocolorscale: true`) or the palette determined by `.colorscale`. In case `colorscale` is unspecified or `autocolorscale` is true, the default palette will be chosen according to whether numbers in the `color` array are all positive, all negative or mixed.", "dflt": true, "role": "style", "valType": "boolean" }, "cauto": { - "description": "Has an effect only if `.color` is set to a numerical array. Determines the whether or not the color domain is computed automatically.", + "description": "Has an effect only if `.color` is set to a numerical array and `cmin`, `cmax` are set by the user. In this case, it controls whether the range of colors in `colorscale` is mapped to the range of values in the `color` array (`cauto: true`), or the `cmin`/`cmax` values (`cauto: false`). Defaults to `false` when `cmin`, `cmax` are set by the user.", "dflt": true, "role": "info", "valType": "boolean" @@ -16795,12 +16880,12 @@ }, "color": { "arrayOk": true, - "description": "Sets the color. It accepts either a specific color or an array of values that are mapped to the colorscale relative to the max and min values of the array or relative to `cmin` and `cmax` if set.", + "description": "Sets the color. It accepts either a specific color or an array of numbers that are mapped to the colorscale relative to the max and min values of the array or relative to `cmin` and `cmax` if set.", "role": "style", "valType": "color" }, "colorscale": { - "description": "Sets the colorscale and only has an effect if `.color` is set to a numerical array. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in color space, use `.cmin` and `.cmax`.", + "description": "Sets the colorscale and only has an effect if `.color` is set to a numerical array. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rgb(0,0,255)', [1, 'rgb(255,0,0)']]`. To control the bounds of the colorscale in color space, use `.cmin` and `.cmax`. Alternatively, `colorscale` may be a palette name string of the following list: Greys, YlGnBu, Greens, YlOrRd, Bluered, RdBu, Reds, Blues, Picnic, Rainbow, Portland, Jet, Hot, Blackbody, Earth, Electric, Viridis", "role": "style", "valType": "colorscale" }, @@ -16810,7 +16895,7 @@ "valType": "string" }, "reversescale": { - "description": "Has an effect only if `.color` is set to a numerical array. Reverses the colorscale.", + "description": "Has an effect only if `.color` is set to a numerical array. Reverses the color mapping if true (`cmin` will correspond to the last color in the array and `cmax` will correspond to the first color).", "dflt": false, "role": "style", "valType": "boolean" @@ -16850,7 +16935,7 @@ "valType": "string" }, "reversescale": { - "description": "Has an effect only if `marker.color` is set to a numerical array. Reverses the colorscale.", + "description": "Has an effect only if `marker.color` is set to a numerical array. Reverses the color mapping if true (`cmin` will correspond to the last color in the array and `cmax` will correspond to the first color).", "dflt": false, "role": "style", "valType": "boolean" @@ -17456,7 +17541,7 @@ ] }, "nticks": { - "description": "Sets the number of ticks. Has an effect only if `tickmode` is set to *auto*.", + "description": "Specifies the maximum number of ticks for the particular axis. The actual number of ticks will be chosen automatically to be less than or equal to `nticks`. Has an effect only if `tickmode` is set to *auto*.", "dflt": 0, "min": 0, "role": "style", @@ -17773,19 +17858,19 @@ "project": { "role": "object", "x": { - "description": "Determines whether or not these contour lines are projected on the x axis walls. If `highlight` is set to *true* (the default), the projected lines are shown on hover. If `show` is set to *true*, the projected lines are shown in permanence.", + "description": "Determines whether or not these contour lines are projected on the x plane. If `highlight` is set to *true* (the default), the projected lines are shown on hover. If `show` is set to *true*, the projected lines are shown in permanence.", "dflt": false, "role": "info", "valType": "boolean" }, "y": { - "description": "Determines whether or not these contour lines are projected on the y axis walls. If `highlight` is set to *true* (the default), the projected lines are shown on hover. If `show` is set to *true*, the projected lines are shown in permanence.", + "description": "Determines whether or not these contour lines are projected on the y plane. If `highlight` is set to *true* (the default), the projected lines are shown on hover. If `show` is set to *true*, the projected lines are shown in permanence.", "dflt": false, "role": "info", "valType": "boolean" }, "z": { - "description": "Determines whether or not these contour lines are projected on the z axis walls. If `highlight` is set to *true* (the default), the projected lines are shown on hover. If `show` is set to *true*, the projected lines are shown in permanence.", + "description": "Determines whether or not these contour lines are projected on the z plane. If `highlight` is set to *true* (the default), the projected lines are shown on hover. If `show` is set to *true*, the projected lines are shown in permanence.", "dflt": false, "role": "info", "valType": "boolean" @@ -17843,19 +17928,19 @@ "project": { "role": "object", "x": { - "description": "Determines whether or not these contour lines are projected on the x axis walls. If `highlight` is set to *true* (the default), the projected lines are shown on hover. If `show` is set to *true*, the projected lines are shown in permanence.", + "description": "Determines whether or not these contour lines are projected on the x plane. If `highlight` is set to *true* (the default), the projected lines are shown on hover. If `show` is set to *true*, the projected lines are shown in permanence.", "dflt": false, "role": "info", "valType": "boolean" }, "y": { - "description": "Determines whether or not these contour lines are projected on the y axis walls. If `highlight` is set to *true* (the default), the projected lines are shown on hover. If `show` is set to *true*, the projected lines are shown in permanence.", + "description": "Determines whether or not these contour lines are projected on the y plane. If `highlight` is set to *true* (the default), the projected lines are shown on hover. If `show` is set to *true*, the projected lines are shown in permanence.", "dflt": false, "role": "info", "valType": "boolean" }, "z": { - "description": "Determines whether or not these contour lines are projected on the z axis walls. If `highlight` is set to *true* (the default), the projected lines are shown on hover. If `show` is set to *true*, the projected lines are shown in permanence.", + "description": "Determines whether or not these contour lines are projected on the z plane. If `highlight` is set to *true* (the default), the projected lines are shown on hover. If `show` is set to *true*, the projected lines are shown in permanence.", "dflt": false, "role": "info", "valType": "boolean" @@ -17913,19 +17998,19 @@ "project": { "role": "object", "x": { - "description": "Determines whether or not these contour lines are projected on the x axis walls. If `highlight` is set to *true* (the default), the projected lines are shown on hover. If `show` is set to *true*, the projected lines are shown in permanence.", + "description": "Determines whether or not these contour lines are projected on the x plane. If `highlight` is set to *true* (the default), the projected lines are shown on hover. If `show` is set to *true*, the projected lines are shown in permanence.", "dflt": false, "role": "info", "valType": "boolean" }, "y": { - "description": "Determines whether or not these contour lines are projected on the y axis walls. If `highlight` is set to *true* (the default), the projected lines are shown on hover. If `show` is set to *true*, the projected lines are shown in permanence.", + "description": "Determines whether or not these contour lines are projected on the y plane. If `highlight` is set to *true* (the default), the projected lines are shown on hover. If `show` is set to *true*, the projected lines are shown in permanence.", "dflt": false, "role": "info", "valType": "boolean" }, "z": { - "description": "Determines whether or not these contour lines are projected on the z axis walls. If `highlight` is set to *true* (the default), the projected lines are shown on hover. If `show` is set to *true*, the projected lines are shown in permanence.", + "description": "Determines whether or not these contour lines are projected on the z plane. If `highlight` is set to *true* (the default), the projected lines are shown on hover. If `show` is set to *true*, the projected lines are shown in permanence.", "dflt": false, "role": "info", "valType": "boolean" From 8cf26dc5df1c7eda7409dd3f6d48711b113b6c54 Mon Sep 17 00:00:00 2001 From: Adam Kulidjian Date: Wed, 6 Jul 2016 11:09:08 -0400 Subject: [PATCH 3/7] Renaming variables and optimizing _make_linear_colorscale --- plotly/tools.py | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/plotly/tools.py b/plotly/tools.py index 9062d150e7e..a7a51897a51 100644 --- a/plotly/tools.py +++ b/plotly/tools.py @@ -1477,30 +1477,26 @@ class FigureFactory(object): """ @staticmethod - def _make_colorscale(colors): + def _make_linear_colorscale(colors): """ Makes a list of colors into a colorscale-acceptable form For documentation regarding to the form of the output, see https://plot.ly/python/reference/#mesh3d-colorscale """ - colorscale = [] - diff = 1./(len(colors) - 1) - - for j in range(len(colors)): - colorscale.append([j * diff, colors[j]]) - return colorscale + scale = 1./(len(colors) - 1) + return[[i * scale, color] for i, color in enumerate(colors)] @staticmethod def create_2D_density(x, y, colorscale='Earth', ncontours=20, - hist_color=(0, 0, 0.5), pt_color=(0, 0, 0.5), - pt_size=2, height=600, width=600): + hist_color=(0, 0, 0.5), point_color=(0, 0, 0.5), + point_size=2, height=600, width=600): """ Returns figure for a 2D density plot :param (list) x: x-axis data for plot generation :param (list) y: y-axis data for plot generation - :param (str|tuple|list) colormap: either a plotly scale name, an rgb + :param (str|tuple|list) colorscale: either a plotly scale name, an rgb or hex color, a color tuple or a list or tuple of colors. An rgb color is of the form 'rgb(x, y, z)' where x, y, z belong to the interval [0, 255] and a color tuple is a tuple of the form @@ -1509,8 +1505,8 @@ def create_2D_density(x, y, colorscale='Earth', ncontours=20, members. :param (int) ncontours: the number of 2D contours to draw on the plot :param (str) hist_color: the color of the plotted histograms - :param (str) pt_color: the color of the scatter points - :param (str) pt_size: the color of the scatter points + :param (str) point_color: the color of the scatter points + :param (str) point_size: the color of the scatter points :param (float) height: the height of the chart :param (float) width: the width of the chart @@ -1547,7 +1543,8 @@ def create_2D_density(x, y, colorscale='Earth', ncontours=20, # Create a figure fig = FF.create_2D_density( - x, y, colorscale=colorscale, hist_color='rgb(255, 237, 222)', pt_size=3) + x, y, colorscale=colorscale, + hist_color='rgb(255, 237, 222)', point_size=3) # Plot the data py.iplot(fig, filename='use-parameters') @@ -1555,17 +1552,17 @@ def create_2D_density(x, y, colorscale='Earth', ncontours=20, """ from plotly.graph_objs import graph_objs colorscale = FigureFactory._validate_colors(colorscale, 'rgb') - colorscale = FigureFactory._make_colorscale(colorscale) + colorscale = FigureFactory._make_linear_colorscale(colorscale) - # validate hist_color and pt_color + # validate hist_color and point_color hist_color = FigureFactory._validate_colors(hist_color, 'rgb') - pt_color = FigureFactory._validate_colors(pt_color, 'rgb') + point_color = FigureFactory._validate_colors(point_color, 'rgb') trace1 = graph_objs.Scatter( x=x, y=y, mode='markers', name='points', marker=dict( - color=pt_color[0], - size=pt_size, + color=point_color[0], + size=point_size, opacity=0.4 ) ) From d7cf2de91ae430e7d894c691e2c7594778b50029 Mon Sep 17 00:00:00 2001 From: Adam Kulidjian Date: Mon, 11 Jul 2016 15:32:43 -0400 Subject: [PATCH 4/7] Added tests to 2d_density --- .../test_tools/test_figure_factory.py | 110 ++++++++++++++++++ plotly/tools.py | 21 +++- 2 files changed, 128 insertions(+), 3 deletions(-) diff --git a/plotly/tests/test_core/test_tools/test_figure_factory.py b/plotly/tests/test_core/test_tools/test_figure_factory.py index 97fb061b213..7395d126c2c 100644 --- a/plotly/tests/test_core/test_tools/test_figure_factory.py +++ b/plotly/tests/test_core/test_tools/test_figure_factory.py @@ -1365,6 +1365,116 @@ def test_gantt_all_args(self): self.assertEqual(test_gantt_chart['layout'], exp_gantt_chart['layout']) + +class Test2D_Density(TestCase): + + def test_validate_2D_density(self): + + # validate that x and y contain only numbers + + x = [1, 2] + + y = ['a', 2] + + pattern = ("All elements of your 'x' and 'y' lists must be numbers.") + + self.assertRaisesRegexp(PlotlyError, pattern, + tls.FigureFactory.create_2D_density, x, y) + + # validate that x and y are the same length + + x2 = [1] + + y2 = [1, 2] + + pattern2 = ("Both lists 'x' and 'y' must be the same length.") + + self.assertRaisesRegexp(PlotlyError, pattern2, + tls.FigureFactory.create_2D_density, x2, y2) + + def test_2D_density_all_args(self): + + # check if 2D_density data matches with expected output + + x = [1, 2] + y = [2, 4] + + colorscale = ['#7A4579', '#D56073', 'rgb(236,158,105)', + (1, 1, 0.2), (0.98, 0.98, 0.98)] + + test_2D_density_chart = tls.FigureFactory.create_2D_density( + x, y, colorscale=colorscale, hist_color='rgb(255, 237, 222)', + point_size=3, height=800, width=800) + + exp_2D_density_chart = { + 'data': [{'marker': {'color': 'rgb(0.0, 0.0, 127.5)', + 'opacity': 0.4, + 'size': 3}, + 'mode': 'markers', + 'name': 'points', + 'type': 'scatter', + 'x': [1, 2], + 'y': [2, 4]}, + {'colorscale': [[0.0, 'rgb(122.0, 69.0, 121.0)'], + [0.25, 'rgb(213.0, 96.0, 115.0)'], + [0.5, 'rgb(236.0, 158.0, 105.0)'], + [0.75, 'rgb(255.0, 255.0, 51.0)'], + [1.0, 'rgb(249.9, 249.9, 249.9)']], + 'name': 'density', + 'ncontours': 20, + 'reversescale': True, + 'showscale': False, + 'type': 'histogram2dcontour', + 'x': [1, 2], + 'y': [2, 4]}, + {'marker': {'color': 'rgb(255.0, 237.0, 222.0)'}, + 'name': 'x density', + 'type': 'histogram', + 'x': [1, 2], + 'yaxis': 'y2'}, + {'marker': {'color': 'rgb(255.0, 237.0, 222.0)'}, + 'name': 'y density', + 'type': 'histogram', + 'xaxis': 'x2', + 'y': [2, 4]}], + 'layout': {'autosize': False, + 'bargap': 0, + 'height': 800, + 'hovermode': 'closest', + 'margin': {'t': 50}, + 'showlegend': False, + 'title': 'Love', + 'width': 800, + 'xaxis': {'domain': [0, 0.85], + 'showgrid': False, + 'zeroline': False}, + 'xaxis2': {'domain': [0.85, 1], + 'showgrid': False, + 'zeroline': False}, + 'yaxis': {'domain': [0, 0.85], + 'showgrid': False, + 'zeroline': False}, + 'yaxis2': {'domain': [0.85, 1], + 'showgrid': False, + 'zeroline': False}} + } + + self.assertEqual(test_2D_density_chart['data'][0], + exp_2D_density_chart['data'][0]) + + self.assertEqual(test_2D_density_chart['data'][1], + exp_2D_density_chart['data'][1]) + + self.assertEqual(test_2D_density_chart['data'][2], + exp_2D_density_chart['data'][2]) + + self.assertEqual(test_2D_density_chart['data'][3], + exp_2D_density_chart['data'][3]) + + self.assertEqual(test_2D_density_chart['layout'], + exp_2D_density_chart['layout']) + + # class TestDistplot(TestCase): # def test_scipy_import_error(self): diff --git a/plotly/tools.py b/plotly/tools.py index a7a51897a51..4c3b7dd96f2 100644 --- a/plotly/tools.py +++ b/plotly/tools.py @@ -1494,8 +1494,8 @@ def create_2D_density(x, y, colorscale='Earth', ncontours=20, """ Returns figure for a 2D density plot - :param (list) x: x-axis data for plot generation - :param (list) y: y-axis data for plot generation + :param (list|array) x: x-axis data for plot generation + :param (list|array) y: y-axis data for plot generation :param (str|tuple|list) colorscale: either a plotly scale name, an rgb or hex color, a color tuple or a list or tuple of colors. An rgb color is of the form 'rgb(x, y, z)' where x, y, z belong to the @@ -1527,7 +1527,7 @@ def create_2D_density(x, y, colorscale='Earth', ncontours=20, py.iplot(fig, filename='simple-2d-density') ``` - Example 2: Use Parameters + Example 2: Using Parameters ``` import plotly.plotly as py from plotly.tools import FigureFactory as FF @@ -1551,6 +1551,21 @@ def create_2D_density(x, y, colorscale='Earth', ncontours=20, ``` """ from plotly.graph_objs import graph_objs + from numbers import Number + + # validate x and y are filled with numbers only + for array in [x, y]: + if not all(isinstance(element, Number) for element in array): + raise exceptions.PlotlyError( + "All elements of your 'x' and 'y' lists must be numbers." + ) + + # validate x and y are the same length + if len(x) != len(y): + raise exceptions.PlotlyError( + "Both lists 'x' and 'y' must be the same length." + ) + colorscale = FigureFactory._validate_colors(colorscale, 'rgb') colorscale = FigureFactory._make_linear_colorscale(colorscale) From 886efa6b2a949203c4cb6fe79c8e0eb31be8bde3 Mon Sep 17 00:00:00 2001 From: Adam Kulidjian Date: Thu, 14 Jul 2016 14:46:50 -0400 Subject: [PATCH 5/7] Fixed Spacing in Test --- plotly/tests/test_core/test_tools/test_figure_factory.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/plotly/tests/test_core/test_tools/test_figure_factory.py b/plotly/tests/test_core/test_tools/test_figure_factory.py index 7395d126c2c..8d7c5a36fdd 100644 --- a/plotly/tests/test_core/test_tools/test_figure_factory.py +++ b/plotly/tests/test_core/test_tools/test_figure_factory.py @@ -1371,9 +1371,7 @@ class Test2D_Density(TestCase): def test_validate_2D_density(self): # validate that x and y contain only numbers - x = [1, 2] - y = ['a', 2] pattern = ("All elements of your 'x' and 'y' lists must be numbers.") @@ -1382,9 +1380,7 @@ def test_validate_2D_density(self): tls.FigureFactory.create_2D_density, x, y) # validate that x and y are the same length - x2 = [1] - y2 = [1, 2] pattern2 = ("Both lists 'x' and 'y' must be the same length.") @@ -1395,7 +1391,6 @@ def test_validate_2D_density(self): def test_2D_density_all_args(self): # check if 2D_density data matches with expected output - x = [1, 2] y = [2, 4] From 4d88ea7e710bfb216247d3b65305f3fdb463a96f Mon Sep 17 00:00:00 2001 From: Adam Kulidjian Date: Thu, 14 Jul 2016 14:47:37 -0400 Subject: [PATCH 6/7] Changed ver # to '1.12.3' --- plotly/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plotly/version.py b/plotly/version.py index 96ddfeb7847..3081afbab00 100644 --- a/plotly/version.py +++ b/plotly/version.py @@ -1 +1 @@ -__version__ = '1.12.2' +__version__ = '1.12.3' From 704492250b4af694421e024dfc8af3beb944e78a Mon Sep 17 00:00:00 2001 From: Adam Kulidjian Date: Thu, 14 Jul 2016 14:57:41 -0400 Subject: [PATCH 7/7] Update default schema --- plotly/graph_reference/default-schema.json | 1 + 1 file changed, 1 insertion(+) diff --git a/plotly/graph_reference/default-schema.json b/plotly/graph_reference/default-schema.json index 2c412a45320..ed1b0407183 100644 --- a/plotly/graph_reference/default-schema.json +++ b/plotly/graph_reference/default-schema.json @@ -5977,6 +5977,7 @@ "width": { "arrayOk": true, "description": "Sets the width (in px) of the lines bounding the marker points.", + "dflt": 0, "min": 0, "role": "style", "valType": "number"