diff --git a/plotly/__init__.py b/plotly/__init__.py index 0bd411480e6..3790d38161e 100644 --- a/plotly/__init__.py +++ b/plotly/__init__.py @@ -29,5 +29,5 @@ from __future__ import absolute_import from plotly import (plotly, graph_objs, grid_objs, tools, utils, session, - offline) + offline, colors) from plotly.version import __version__ diff --git a/plotly/colors.py b/plotly/colors.py new file mode 100644 index 00000000000..11e3f9c5f47 --- /dev/null +++ b/plotly/colors.py @@ -0,0 +1,514 @@ +""" +colors +===== + +Functions that manipulate colors and arrays of colors + +There are three basic types of color types: rgb, hex and tuple: + +rgb - An rgb color is a string of the form 'rgb(a,b,c)' where a, b and c are +floats between 0 and 255 inclusive. + +hex - A hex color is a string of the form '#xxxxxx' where each x is a +character that belongs to the set [0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f]. This is +just the list of characters used in the hexadecimal numeric system. + +tuple - A tuple color is a 3-tuple of the form (a,b,c) where a, b and c are +floats between 0 and 1 inclusive. + +""" +from __future__ import absolute_import +from plotly import exceptions +from numbers import Number + +DEFAULT_PLOTLY_COLORS = ['rgb(31, 119, 180)', 'rgb(255, 127, 14)', + 'rgb(44, 160, 44)', 'rgb(214, 39, 40)', + 'rgb(148, 103, 189)', 'rgb(140, 86, 75)', + 'rgb(227, 119, 194)', 'rgb(127, 127, 127)', + 'rgb(188, 189, 34)', 'rgb(23, 190, 207)'] + +PLOTLY_SCALES = { + 'Greys': [ + [0, 'rgb(0,0,0)'], [1, 'rgb(255,255,255)'] + ], + + 'YlGnBu': [ + [0, 'rgb(8,29,88)'], [0.125, 'rgb(37,52,148)'], + [0.25, 'rgb(34,94,168)'], [0.375, 'rgb(29,145,192)'], + [0.5, 'rgb(65,182,196)'], [0.625, 'rgb(127,205,187)'], + [0.75, 'rgb(199,233,180)'], [0.875, 'rgb(237,248,217)'], + [1, 'rgb(255,255,217)'] + ], + + 'Greens': [ + [0, 'rgb(0,68,27)'], [0.125, 'rgb(0,109,44)'], + [0.25, 'rgb(35,139,69)'], [0.375, 'rgb(65,171,93)'], + [0.5, 'rgb(116,196,118)'], [0.625, 'rgb(161,217,155)'], + [0.75, 'rgb(199,233,192)'], [0.875, 'rgb(229,245,224)'], + [1, 'rgb(247,252,245)'] + ], + + 'YlOrRd': [ + [0, 'rgb(128,0,38)'], [0.125, 'rgb(189,0,38)'], + [0.25, 'rgb(227,26,28)'], [0.375, 'rgb(252,78,42)'], + [0.5, 'rgb(253,141,60)'], [0.625, 'rgb(254,178,76)'], + [0.75, 'rgb(254,217,118)'], [0.875, 'rgb(255,237,160)'], + [1, 'rgb(255,255,204)'] + ], + + 'Bluered': [ + [0, 'rgb(0,0,255)'], [1, 'rgb(255,0,0)'] + ], + + # modified RdBu based on + # www.sandia.gov/~kmorel/documents/ColorMaps/ColorMapsExpanded.pdf + 'RdBu': [ + [0, 'rgb(5,10,172)'], [0.35, 'rgb(106,137,247)'], + [0.5, 'rgb(190,190,190)'], [0.6, 'rgb(220,170,132)'], + [0.7, 'rgb(230,145,90)'], [1, 'rgb(178,10,28)'] + ], + + # Scale for non-negative numeric values + 'Reds': [ + [0, 'rgb(220,220,220)'], [0.2, 'rgb(245,195,157)'], + [0.4, 'rgb(245,160,105)'], [1, 'rgb(178,10,28)'] + ], + + # Scale for non-positive numeric values + 'Blues': [ + [0, 'rgb(5,10,172)'], [0.35, 'rgb(40,60,190)'], + [0.5, 'rgb(70,100,245)'], [0.6, 'rgb(90,120,245)'], + [0.7, 'rgb(106,137,247)'], [1, 'rgb(220,220,220)'] + ], + + 'Picnic': [ + [0, 'rgb(0,0,255)'], [0.1, 'rgb(51,153,255)'], + [0.2, 'rgb(102,204,255)'], [0.3, 'rgb(153,204,255)'], + [0.4, 'rgb(204,204,255)'], [0.5, 'rgb(255,255,255)'], + [0.6, 'rgb(255,204,255)'], [0.7, 'rgb(255,153,255)'], + [0.8, 'rgb(255,102,204)'], [0.9, 'rgb(255,102,102)'], + [1, 'rgb(255,0,0)'] + ], + + 'Rainbow': [ + [0, 'rgb(150,0,90)'], [0.125, 'rgb(0,0,200)'], + [0.25, 'rgb(0,25,255)'], [0.375, 'rgb(0,152,255)'], + [0.5, 'rgb(44,255,150)'], [0.625, 'rgb(151,255,0)'], + [0.75, 'rgb(255,234,0)'], [0.875, 'rgb(255,111,0)'], + [1, 'rgb(255,0,0)'] + ], + + 'Portland': [ + [0, 'rgb(12,51,131)'], [0.25, 'rgb(10,136,186)'], + [0.5, 'rgb(242,211,56)'], [0.75, 'rgb(242,143,56)'], + [1, 'rgb(217,30,30)'] + ], + + 'Jet': [ + [0, 'rgb(0,0,131)'], [0.125, 'rgb(0,60,170)'], + [0.375, 'rgb(5,255,255)'], [0.625, 'rgb(255,255,0)'], + [0.875, 'rgb(250,0,0)'], [1, 'rgb(128,0,0)'] + ], + + 'Hot': [ + [0, 'rgb(0,0,0)'], [0.3, 'rgb(230,0,0)'], + [0.6, 'rgb(255,210,0)'], [1, 'rgb(255,255,255)'] + ], + + 'Blackbody': [ + [0, 'rgb(0,0,0)'], [0.2, 'rgb(230,0,0)'], + [0.4, 'rgb(230,210,0)'], [0.7, 'rgb(255,255,255)'], + [1, 'rgb(160,200,255)'] + ], + + 'Earth': [ + [0, 'rgb(0,0,130)'], [0.1, 'rgb(0,180,180)'], + [0.2, 'rgb(40,210,40)'], [0.4, 'rgb(230,230,50)'], + [0.6, 'rgb(120,70,20)'], [1, 'rgb(255,255,255)'] + ], + + 'Electric': [ + [0, 'rgb(0,0,0)'], [0.15, 'rgb(30,0,100)'], + [0.4, 'rgb(120,0,100)'], [0.6, 'rgb(160,90,0)'], + [0.8, 'rgb(230,200,0)'], [1, 'rgb(255,250,220)'] + ], + + 'Viridis': [ + [0, '#440154'], [0.06274509803921569, '#48186a'], + [0.12549019607843137, '#472d7b'], [0.18823529411764706, '#424086'], + [0.25098039215686274, '#3b528b'], [0.3137254901960784, '#33638d'], + [0.3764705882352941, '#2c728e'], [0.4392156862745098, '#26828e'], + [0.5019607843137255, '#21918c'], [0.5647058823529412, '#1fa088'], + [0.6274509803921569, '#28ae80'], [0.6901960784313725, '#3fbc73'], + [0.7529411764705882, '#5ec962'], [0.8156862745098039, '#84d44b'], + [0.8784313725490196, '#addc30'], [0.9411764705882353, '#d8e219'], + [1, '#fde725'] + ] +} + + +def color_parser(colors, function): + """ + Takes color(s) and a function and applies the function on the color(s) + + In particular, this function identifies whether the given color object + is an iterable or not and applies the given color-parsing function to + the color or iterable of colors. If given an iterable, it will only be + able to work with it if all items in the iterable are of the same type + - rgb string, hex string or tuple + + """ + if isinstance(colors, str): + return function(colors) + + if isinstance(colors, tuple) and isinstance(colors[0], Number): + return function(colors) + + if hasattr(colors, '__iter__'): + if isinstance(colors, tuple): + new_color_tuple = tuple(function(item) for item in colors) + return new_color_tuple + + else: + new_color_list = [function(item) for item in colors] + return new_color_list + + +def validate_colors(colors): + """ + Validates color(s) and returns an error for invalid colors + """ + colors_list = [] + + if isinstance(colors, str): + if colors in PLOTLY_SCALES: + return + elif 'rgb' in colors or '#' in colors: + colors_list = [colors] + else: + raise exceptions.PlotlyError( + "If your colors variable is a string, it must be a " + "Plotly scale, an rgb color or a hex color." + ) + + elif isinstance(colors, tuple): + if isinstance(colors[0], Number): + colors_list = [colors] + else: + colors_list = list(colors) + + if isinstance(colors, dict): + colors_list.extend(colors.values()) + + elif isinstance(colors, list): + colors_list = colors + + # Validate colors in colors_list + for j, each_color in enumerate(colors_list): + if 'rgb' in each_color: + each_color = color_parser( + each_color, unlabel_rgb + ) + for value in each_color: + if value > 255.0: + raise exceptions.PlotlyError( + "Whoops! The elements in your rgb colors " + "tuples cannot exceed 255.0." + ) + + elif '#' in each_color: + each_color = color_parser( + each_color, hex_to_rgb + ) + + elif isinstance(each_color, tuple): + for value in each_color: + if value > 1.0: + raise exceptions.PlotlyError( + "Whoops! The elements in your colors tuples " + "cannot exceed 1.0." + ) + return colors + + +def convert_colors_to_same_type(colors, colortype='rgb'): + """ + Converts color(s) to the specified color type + + Takes a single color or an iterable of colors and outputs a list of the + color(s) converted all to an rgb or tuple color type. If colors is a + Plotly Scale name then the cooresponding colorscale will be outputted and + colortype will not be applicable + """ + colors_list = [] + + if isinstance(colors, str): + if colors in PLOTLY_SCALES: + return PLOTLY_SCALES[colors] + elif 'rgb' in colors or '#' in colors: + colors_list = [colors] + else: + raise exceptions.PlotlyError( + "If your colors variable is a string, it must be a Plotly " + "scale, an rgb color or a hex color.") + + elif isinstance(colors, tuple): + if isinstance(colors[0], Number): + colors_list = [colors] + else: + colors_list = list(colors) + + elif isinstance(colors, list): + colors_list = colors + + # convert all colors to rgb + for j, each_color in enumerate(colors_list): + if '#' in each_color: + each_color = color_parser( + each_color, hex_to_rgb + ) + each_color = color_parser( + each_color, label_rgb + ) + colors_list[j] = each_color + + elif isinstance(each_color, tuple): + each_color = color_parser( + each_color, convert_to_RGB_255 + ) + each_color = color_parser( + each_color, label_rgb + ) + colors_list[j] = each_color + + if colortype == 'rgb': + return colors_list + elif colortype == 'tuple': + for j, each_color in enumerate(colors_list): + each_color = color_parser( + each_color, unlabel_rgb + ) + each_color = color_parser( + each_color, unconvert_from_RGB_255 + ) + colors_list[j] = each_color + return colors_list + else: + raise exceptions.PlotlyError("You must select either rgb or tuple " + "for your colortype variable.") + + +def convert_dict_colors_to_same_type(colors, colortype='rgb'): + """ + Converts color(s) to the specified color type + + Takes a single color or an iterable of colors and outputs a list of the + color(s) converted all to an rgb or tuple color type. If colors is a + Plotly Scale name then the cooresponding colorscale will be outputted + """ + for key in colors: + if '#' in colors[key]: + colors[key] = color_parser( + colors[key], hex_to_rgb + ) + colors[key] = color_parser( + colors[key], label_rgb + ) + + elif isinstance(colors[key], tuple): + colors[key] = color_parser( + colors[key], convert_to_RGB_255 + ) + colors[key] = color_parser( + colors[key], label_rgb + ) + + if colortype == 'rgb': + return colors + elif colortype == 'tuple': + for key in colors: + colors[key] = color_parser( + colors[key], unlabel_rgb + ) + colors[key] = color_parser( + colors[key], unconvert_from_RGB_255 + ) + return colors + else: + raise exceptions.PlotlyError("You must select either rgb or tuple " + "for your colortype variable.") + + +def make_colorscale(colors, scale=None): + """ + Makes a colorscale from a list of colors and a scale + + Takes a list of colors and scales and constructs a colorscale based + on the colors in sequential order. If 'scale' is left empty, a linear- + interpolated colorscale will be generated. If 'scale' is a specificed + list, it must be the same legnth as colors and must contain all floats + For documentation regarding to the form of the output, see + https://plot.ly/python/reference/#mesh3d-colorscale + """ + colorscale = [] + + # validate minimum colors length of 2 + if len(colors) < 2: + raise exceptions.PlotlyError("You must input a list of colors that " + "has at least two colors.") + + if not scale: + scale_incr = 1./(len(colors) - 1) + return [[i * scale_incr, color] for i, color in enumerate(colors)] + + else: + # validate scale + if len(colors) != len(scale): + raise exceptions.PlotlyError("The length of colors and scale " + "must be the same.") + + if (scale[0] != 0) or (scale[-1] != 1): + raise exceptions.PlotlyError( + "The first and last number in scale must be 0.0 and 1.0 " + "respectively." + ) + + for j in range(1, len(scale)): + if scale[j] <= scale[j-1]: + raise exceptions.PlotlyError( + "'scale' must be a list that contains an increasing " + "sequence of numbers where the first and last number are" + "0.0 and 1.0 respectively." + ) + + colorscale = [list(tup) for tup in zip(scale, colors)] + return colorscale + + +def find_intermediate_color(lowcolor, highcolor, intermed): + """ + Returns the color at a given distance between two colors + + This function takes two color tuples, where each element is between 0 + and 1, along with a value 0 < intermed < 1 and returns a color that is + intermed-percent from lowcolor to highcolor + + """ + diff_0 = float(highcolor[0] - lowcolor[0]) + diff_1 = float(highcolor[1] - lowcolor[1]) + diff_2 = float(highcolor[2] - lowcolor[2]) + + inter_colors = (lowcolor[0] + intermed * diff_0, + lowcolor[1] + intermed * diff_1, + lowcolor[2] + intermed * diff_2) + return inter_colors + + +def unconvert_from_RGB_255(colors): + """ + Return a tuple where each element gets divided by 255 + + Takes a (list of) color tuple(s) where each element is between 0 and + 255. Returns the same tuples where each tuple element is normalized to + a value between 0 and 1 + + """ + un_rgb_color = (colors[0]/(255.0), + colors[1]/(255.0), + colors[2]/(255.0)) + + return un_rgb_color + + +def convert_to_RGB_255(colors): + """ + Multiplies each element of a triplet by 255 + """ + return (colors[0]*255.0, colors[1]*255.0, colors[2]*255.0) + + +def n_colors(lowcolor, highcolor, n_colors): + """ + Splits a low and high color into a list of n_colors colors in it + + Accepts two color tuples and returns a list of n_colors colors + which form the intermediate colors between lowcolor and highcolor + from linearly interpolating through RGB space + + """ + diff_0 = float(highcolor[0] - lowcolor[0]) + incr_0 = diff_0/(n_colors - 1) + diff_1 = float(highcolor[1] - lowcolor[1]) + incr_1 = diff_1/(n_colors - 1) + diff_2 = float(highcolor[2] - lowcolor[2]) + incr_2 = diff_2/(n_colors - 1) + color_tuples = [] + + for index in range(n_colors): + new_tuple = (lowcolor[0] + (index * incr_0), + lowcolor[1] + (index * incr_1), + lowcolor[2] + (index * incr_2)) + color_tuples.append(new_tuple) + + return color_tuples + + +def label_rgb(colors): + """ + Takes tuple (a, b, c) and returns an rgb color 'rgb(a, b, c)' + """ + return ('rgb(%s, %s, %s)' % (colors[0], colors[1], colors[2])) + + +def unlabel_rgb(colors): + """ + Takes rgb color(s) 'rgb(a, b, c)' and returns tuple(s) (a, b, c) + + This function takes either an 'rgb(a, b, c)' color or a list of + such colors and returns the color tuples in tuple(s) (a, b, c) + + """ + str_vals = '' + for index in range(len(colors)): + try: + float(colors[index]) + str_vals = str_vals + colors[index] + except ValueError: + if colors[index] == ',' or colors[index] == '.': + str_vals = str_vals + colors[index] + + str_vals = str_vals + ',' + numbers = [] + str_num = '' + for char in str_vals: + if char != ',': + str_num = str_num + char + else: + numbers.append(float(str_num)) + str_num = '' + return (numbers[0], numbers[1], numbers[2]) + + +def hex_to_rgb(value): + """ + Calculates rgb values from a hex color code. + + :param (string) value: Hex color string + + :rtype (tuple) (r_value, g_value, b_value): tuple of rgb values + """ + value = value.lstrip('#') + hex_total_length = len(value) + rgb_section_length = hex_total_length // 3 + return tuple(int(value[i:i + rgb_section_length], 16) + for i in range(0, hex_total_length, rgb_section_length)) + + +def colorscale_to_colors(colorscale): + """ + Converts a colorscale into a list of colors + """ + color_list = [] + for color in colorscale: + color_list.append(color[1]) + return color_list diff --git a/plotly/graph_reference/default-schema.json b/plotly/graph_reference/default-schema.json index db24b739d2d..386ceededed 100644 --- a/plotly/graph_reference/default-schema.json +++ b/plotly/graph_reference/default-schema.json @@ -18,7 +18,8 @@ "any": { "description": "Any type.", "otherOpts": [ - "dflt" + "dflt", + "values" ], "requiredOpts": [] }, @@ -75,7 +76,8 @@ "info_array": { "description": "An {array} of plot information.", "otherOpts": [ - "dflt" + "dflt", + "freeLength" ], "requiredOpts": [ "items" @@ -1077,6 +1079,258 @@ ] } }, + "mapbox": { + "_isSubplotObj": true, + "accesstoken": { + "description": "Sets the mapbox access token to be used for this mapbox map. Alternatively, the mapbox access token can be set in the configuration options under `mapboxAccessToken`.", + "noBlank": true, + "role": "info", + "strict": true, + "valType": "string" + }, + "bearing": { + "description": "Sets the bearing angle of the map (in degrees counter-clockwise from North).", + "dflt": 0, + "role": "info", + "valType": "number" + }, + "center": { + "lat": { + "description": "Sets the latitude of the center of the map (in degrees North).", + "dflt": 0, + "role": "info", + "valType": "number" + }, + "lon": { + "description": "Sets the longitude of the center of the map (in degrees East).", + "dflt": 0, + "role": "info", + "valType": "number" + }, + "role": "object" + }, + "domain": { + "role": "object", + "x": { + "description": "Sets the horizontal domain of this subplot (in plot fraction).", + "dflt": [ + 0, + 1 + ], + "items": [ + { + "max": 1, + "min": 0, + "valType": "number" + }, + { + "max": 1, + "min": 0, + "valType": "number" + } + ], + "role": "info", + "valType": "info_array" + }, + "y": { + "description": "Sets the vertical domain of this subplot (in plot fraction).", + "dflt": [ + 0, + 1 + ], + "items": [ + { + "max": 1, + "min": 0, + "valType": "number" + }, + { + "max": 1, + "min": 0, + "valType": "number" + } + ], + "role": "info", + "valType": "info_array" + } + }, + "layers": { + "items": { + "layer": { + "below": { + "description": "Determines if the layer will be inserted before the layer with the specified ID. If omitted or set to '', the layer will be inserted above every existing layer.", + "dflt": "", + "role": "info", + "valType": "string" + }, + "circle": { + "radius": { + "description": "Sets the circle radius. Has an effect only when `type` is set to *circle*.", + "dflt": 15, + "role": "style", + "valType": "number" + }, + "role": "object" + }, + "color": { + "description": "Sets the primary layer color. If `type` is *circle*, color corresponds to the circle color If `type` is *line*, color corresponds to the line color If `type` is *fill*, color corresponds to the fill color If `type` is *symbol*, color corresponds to the icon color", + "dflt": "#444", + "role": "style", + "valType": "color" + }, + "fill": { + "outlinecolor": { + "description": "Sets the fill outline color. Has an effect only when `type` is set to *fill*.", + "dflt": "#444", + "role": "style", + "valType": "color" + }, + "role": "object" + }, + "line": { + "role": "object", + "width": { + "description": "Sets the line width. Has an effect only when `type` is set to *line*.", + "dflt": 2, + "role": "style", + "valType": "number" + } + }, + "opacity": { + "description": "Sets the opacity of the layer.", + "dflt": 1, + "max": 1, + "min": 0, + "role": "info", + "valType": "number" + }, + "role": "object", + "source": { + "description": "Sets the source data for this layer. Source can be either a URL, a geojson object (with `sourcetype` set to *geojson*) or an array of tile URLS (with `sourcetype` set to *vector*).", + "role": "info", + "valType": "any" + }, + "sourcelayer": { + "description": "Specifies the layer to use from a vector tile source. Required for *vector* source type that supports multiple layers.", + "dflt": "", + "role": "info", + "valType": "string" + }, + "sourcetype": { + "description": "Sets the source type for this layer. Support for *raster*, *image* and *video* source types is coming soon.", + "dflt": "geojson", + "role": "info", + "valType": "enumerated", + "values": [ + "geojson", + "vector" + ] + }, + "symbol": { + "icon": { + "description": "Sets the symbol icon image. Full list: https://www.mapbox.com/maki-icons/", + "dflt": "marker", + "role": "style", + "valType": "string" + }, + "iconsize": { + "description": "Sets the symbol icon size. Has an effect only when `type` is set to *symbol*.", + "dflt": 10, + "role": "style", + "valType": "number" + }, + "role": "object", + "text": { + "description": "Sets the symbol text.", + "dflt": "", + "role": "info", + "valType": "string" + }, + "textfont": { + "color": { + "role": "style", + "valType": "color" + }, + "description": "Sets the icon text font. Has an effect only when `type` is set to *symbol*.", + "family": { + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "dflt": "Open Sans Regular, Arial Unicode MS Regular", + "noBlank": true, + "role": "style", + "strict": true, + "valType": "string" + }, + "role": "object", + "size": { + "min": 1, + "role": "style", + "valType": "number" + } + }, + "textposition": { + "arrayOk": false, + "description": "Sets the positions of the `text` elements with respects to the (x,y) coordinates.", + "dflt": "middle center", + "role": "style", + "valType": "enumerated", + "values": [ + "top left", + "top center", + "top right", + "middle left", + "middle center", + "middle right", + "bottom left", + "bottom center", + "bottom right" + ] + } + }, + "type": { + "description": "Sets the layer type. Support for *raster*, *background* types is coming soon. Note that *line* and *fill* are not compatible with Point GeoJSON geometries.", + "dflt": "circle", + "role": "info", + "valType": "enumerated", + "values": [ + "circle", + "line", + "fill", + "symbol" + ] + } + } + }, + "role": "object" + }, + "pitch": { + "description": "Sets the pitch angle of the map (in degrees, where *0* means perpendicular to the surface of the map).", + "dflt": 0, + "role": "info", + "valType": "number" + }, + "role": "object", + "style": { + "description": "Sets the Mapbox map style. Either input one of the default Mapbox style names or the URL to a custom style or a valid Mapbox style JSON.", + "dflt": "basic", + "role": "style", + "valType": "any", + "values": [ + "basic", + "streets", + "outdoors", + "light", + "dark", + "satellite", + "satellite-streets" + ] + }, + "zoom": { + "description": "Sets the zoom level of the map.", + "dflt": 1, + "role": "info", + "valType": "number" + } + }, "margin": { "autoexpand": { "dflt": true, @@ -3626,6 +3880,145 @@ "valType": "number" } }, + "updatemenus": { + "items": { + "updatemenu": { + "active": { + "description": "Determines which button (by index starting from 0) is considered active.", + "dflt": 0, + "min": -1, + "role": "info", + "valType": "integer" + }, + "bgcolor": { + "description": "Sets the background color of the update menu buttons.", + "role": "style", + "valType": "color" + }, + "bordercolor": { + "description": "Sets the color of the border enclosing the update menu.", + "dflt": "#BEC8D9", + "role": "style", + "valType": "color" + }, + "borderwidth": { + "description": "Sets the width (in px) of the border enclosing the update menu.", + "dflt": 1, + "min": 0, + "role": "style", + "valType": "number" + }, + "buttons": { + "items": { + "button": { + "args": { + "description": "Sets the arguments values to be passed to the Plotly method set in `method` on click.", + "freeLength": true, + "items": [ + { + "valType": "any" + }, + { + "valType": "any" + }, + { + "valType": "any" + } + ], + "role": "info", + "valType": "info_array" + }, + "label": { + "description": "Sets the text label to appear on the button.", + "dflt": "", + "role": "info", + "valType": "string" + }, + "method": { + "description": "Sets the Plotly method to be called on click.", + "dflt": "restyle", + "role": "info", + "valType": "enumerated", + "values": [ + "restyle", + "relayout" + ] + }, + "role": "object" + } + }, + "role": "object" + }, + "font": { + "color": { + "role": "style", + "valType": "color" + }, + "description": "Sets the font of the update menu button text.", + "family": { + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "noBlank": true, + "role": "style", + "strict": true, + "valType": "string" + }, + "role": "object", + "size": { + "min": 1, + "role": "style", + "valType": "number" + } + }, + "role": "object", + "visible": { + "description": "Determines whether or not the update menu is visible.", + "role": "info", + "valType": "boolean" + }, + "x": { + "description": "Sets the x position (in normalized coordinates) of the update menu.", + "dflt": -0.05, + "max": 3, + "min": -2, + "role": "style", + "valType": "number" + }, + "xanchor": { + "description": "Sets the update menu's horizontal position anchor. This anchor binds the `x` position to the *left*, *center* or *right* of the range selector.", + "dflt": "right", + "role": "info", + "valType": "enumerated", + "values": [ + "auto", + "left", + "center", + "right" + ] + }, + "y": { + "description": "Sets the y position (in normalized coordinates) of the update menu.", + "dflt": 1, + "max": 3, + "min": -2, + "role": "style", + "valType": "number" + }, + "yanchor": { + "description": "Sets the update menu's vertical position anchor This anchor binds the `y` position to the *top*, *middle* or *bottom* of the range selector.", + "dflt": "bottom", + "role": "info", + "valType": "enumerated", + "values": [ + "auto", + "top", + "middle", + "bottom" + ] + } + } + }, + "role": "object" + }, "width": { "description": "Sets the plot's width (in px).", "dflt": 700, @@ -3833,6 +4226,11 @@ ] }, "rangeselector": { + "activecolor": { + "description": "Sets the background color of the active range selector button.", + "role": "style", + "valType": "color" + }, "bgcolor": { "description": "Sets the background color of the range selector buttons.", "dflt": "#eee", @@ -4443,6 +4841,11 @@ ] }, "rangeselector": { + "activecolor": { + "description": "Sets the background color of the active range selector button.", + "role": "style", + "valType": "color" + }, "bgcolor": { "description": "Sets the background color of the range selector buttons.", "dflt": "#eee", @@ -16342,6 +16745,676 @@ }, "description": "The data visualized as scatter point or lines is set in `x` and `y` using the WebGl plotting engine. Bubble charts are achieved by setting `marker.size` and/or `marker.color` to a numerical arrays." }, + "scattermapbox": { + "attributes": { + "connectgaps": { + "description": "Determines whether or not gaps (i.e. {nan} or missing values) in the provided data arrays are connected.", + "dflt": false, + "role": "info", + "valType": "boolean" + }, + "fill": { + "description": "Sets the area to fill with a solid color. Use with `fillcolor` if not *none*. *toself* connects the endpoints of the trace (or each segment of the trace if it has gaps) into a closed shape.", + "dflt": "none", + "role": "style", + "valType": "enumerated", + "values": [ + "none", + "toself" + ] + }, + "fillcolor": { + "description": "Sets the fill color. Defaults to a half-transparent variant of the line color, marker color, or marker line color, whichever is available.", + "role": "style", + "valType": "color" + }, + "hoverinfo": { + "description": "Determines which trace information appear on hover.", + "dflt": "all", + "extras": [ + "all", + "none" + ], + "flags": [ + "lon", + "lat", + "text", + "name" + ], + "role": "info", + "valType": "flaglist" + }, + "lat": { + "description": "Sets the latitude coordinates (in degrees North).", + "role": "data", + "valType": "data_array" + }, + "latsrc": { + "description": "Sets the source reference on plot.ly for lat .", + "role": "info", + "valType": "string" + }, + "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": "", + "role": "info", + "valType": "string" + }, + "line": { + "color": { + "description": "Sets the line color.", + "role": "style", + "valType": "color" + }, + "dash": { + "description": "Sets the style of the lines. Set to a dash string type or a dash length in px.", + "dflt": "solid", + "role": "style", + "valType": "string", + "values": [ + "solid", + "dot", + "dash", + "longdash", + "dashdot", + "longdashdot" + ] + }, + "role": "object", + "width": { + "description": "Sets the line width (in px).", + "dflt": 2, + "min": 0, + "role": "style", + "valType": "number" + } + }, + "lon": { + "description": "Sets the longitude coordinates (in degrees East).", + "role": "data", + "valType": "data_array" + }, + "lonsrc": { + "description": "Sets the source reference on plot.ly for lon .", + "role": "info", + "valType": "string" + }, + "marker": { + "autocolorscale": { + "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 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 `marker.color` is set to a numerical array. Sets the upper bound of the color domain. Value should be associated to the `marker.color` array index, and if set, `marker.cmin` must be set as well.", + "dflt": null, + "role": "info", + "valType": "number" + }, + "cmin": { + "description": "Has an effect only if `marker.color` is set to a numerical array. Sets the lower bound of the color domain. Value should be associated to the `marker.color` array index, and if set, `marker.cmax` must be set as well.", + "dflt": null, + "role": "info", + "valType": "number" + }, + "color": { + "arrayOk": true, + "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" + }, + "colorbar": { + "bgcolor": { + "description": "Sets the color of padded area.", + "dflt": "rgba(0,0,0,0)", + "role": "style", + "valType": "color" + }, + "bordercolor": { + "description": "Sets the axis line color.", + "dflt": "#444", + "role": "style", + "valType": "color" + }, + "borderwidth": { + "description": "Sets the width (in px) or the border enclosing this color bar.", + "dflt": 0, + "min": 0, + "role": "style", + "valType": "number" + }, + "dtick": { + "description": "Sets the step in-between ticks on this axis Use with `tick0`. If the axis `type` is *log*, then ticks are set every 10^(n*dtick) where n is the tick number. For example, to set a tick mark at 1, 10, 100, 1000, ... set dtick to 1. To set tick marks at 1, 100, 10000, ... set dtick to 2. To set tick marks at 1, 5, 25, 125, 625, 3125, ... set dtick to log_10(5), or 0.69897000433. If the axis `type` is *date*, then you must convert the time to milliseconds. For example, to set the interval between ticks to one day, set `dtick` to 86400000.0.", + "dflt": 1, + "role": "style", + "valType": "any" + }, + "exponentformat": { + "description": "Determines a formatting rule for the tick exponents. For example, consider the number 1,000,000,000. If *none*, it appears as 1,000,000,000. If *e*, 1e+9. If *E*, 1E+9. If *power*, 1x10^9 (with 9 in a super script). If *SI*, 1G. If *B*, 1B.", + "dflt": "B", + "role": "style", + "valType": "enumerated", + "values": [ + "none", + "e", + "E", + "power", + "SI", + "B" + ] + }, + "len": { + "description": "Sets the length of the color bar This measure excludes the padding of both ends. That is, the color bar length is this length minus the padding on both ends.", + "dflt": 1, + "min": 0, + "role": "style", + "valType": "number" + }, + "lenmode": { + "description": "Determines whether this color bar's length (i.e. the measure in the color variation direction) is set in units of plot *fraction* or in *pixels. Use `len` to set the value.", + "dflt": "fraction", + "role": "info", + "valType": "enumerated", + "values": [ + "fraction", + "pixels" + ] + }, + "nticks": { + "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", + "valType": "integer" + }, + "outlinecolor": { + "description": "Sets the axis line color.", + "dflt": "#444", + "role": "style", + "valType": "color" + }, + "outlinewidth": { + "description": "Sets the width (in px) of the axis line.", + "dflt": 1, + "min": 0, + "role": "style", + "valType": "number" + }, + "role": "object", + "showexponent": { + "description": "If *all*, all exponents are shown besides their significands. If *first*, only the exponent of the first tick is shown. If *last*, only the exponent of the last tick is shown. If *none*, no exponents appear.", + "dflt": "all", + "role": "style", + "valType": "enumerated", + "values": [ + "all", + "first", + "last", + "none" + ] + }, + "showticklabels": { + "description": "Determines whether or not the tick labels are drawn.", + "dflt": true, + "role": "style", + "valType": "boolean" + }, + "showtickprefix": { + "description": "If *all*, all tick labels are displayed with a prefix. If *first*, only the first tick is displayed with a prefix. If *last*, only the last tick is displayed with a suffix. If *none*, tick prefixes are hidden.", + "dflt": "all", + "role": "style", + "valType": "enumerated", + "values": [ + "all", + "first", + "last", + "none" + ] + }, + "showticksuffix": { + "description": "Same as `showtickprefix` but for tick suffixes.", + "dflt": "all", + "role": "style", + "valType": "enumerated", + "values": [ + "all", + "first", + "last", + "none" + ] + }, + "thickness": { + "description": "Sets the thickness of the color bar This measure excludes the size of the padding, ticks and labels.", + "dflt": 30, + "min": 0, + "role": "style", + "valType": "number" + }, + "thicknessmode": { + "description": "Determines whether this color bar's thickness (i.e. the measure in the constant color direction) is set in units of plot *fraction* or in *pixels*. Use `thickness` to set the value.", + "dflt": "pixels", + "role": "style", + "valType": "enumerated", + "values": [ + "fraction", + "pixels" + ] + }, + "tick0": { + "description": "Sets the placement of the first tick on this axis. Use with `dtick`. If the axis `type` is *log*, then you must take the log of your starting tick (e.g. to set the starting tick to 100, set the `tick0` to 2). If the axis `type` is *date*, then you must convert the date to unix time in milliseconds (the number of milliseconds since January 1st, 1970). For example, to set the starting tick to November 4th, 2013, set the range to 1380844800000.0.", + "dflt": 0, + "role": "style", + "valType": "number" + }, + "tickangle": { + "description": "Sets the angle of the tick labels with respect to the horizontal. For example, a `tickangle` of -90 draws the tick labels vertically.", + "dflt": "auto", + "role": "style", + "valType": "angle" + }, + "tickcolor": { + "description": "Sets the tick color.", + "dflt": "#444", + "role": "style", + "valType": "color" + }, + "tickfont": { + "color": { + "role": "style", + "valType": "color" + }, + "description": "Sets the tick font.", + "family": { + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "noBlank": true, + "role": "style", + "strict": true, + "valType": "string" + }, + "role": "object", + "size": { + "min": 1, + "role": "style", + "valType": "number" + } + }, + "tickformat": { + "description": "Sets the tick label formatting rule using the python/d3 number formatting language. See https://github.com/mbostock/d3/wiki/Formatting#numbers or https://docs.python.org/release/3.1.3/library/string.html#formatspec for more info.", + "dflt": "", + "role": "style", + "valType": "string" + }, + "ticklen": { + "description": "Sets the tick length (in px).", + "dflt": 5, + "min": 0, + "role": "style", + "valType": "number" + }, + "tickmode": { + "description": "Sets the tick mode for this axis. If *auto*, the number of ticks is set via `nticks`. If *linear*, the placement of the ticks is determined by a starting position `tick0` and a tick step `dtick` (*linear* is the default value if `tick0` and `dtick` are provided). If *array*, the placement of the ticks is set via `tickvals` and the tick text is `ticktext`. (*array* is the default value if `tickvals` is provided).", + "role": "info", + "valType": "enumerated", + "values": [ + "auto", + "linear", + "array" + ] + }, + "tickprefix": { + "description": "Sets a tick label prefix.", + "dflt": "", + "role": "style", + "valType": "string" + }, + "ticks": { + "description": "Determines whether ticks are drawn or not. If **, this axis' ticks are not drawn. If *outside* (*inside*), this axis' are drawn outside (inside) the axis lines.", + "dflt": "", + "role": "style", + "valType": "enumerated", + "values": [ + "outside", + "inside", + "" + ] + }, + "ticksuffix": { + "description": "Sets a tick label suffix.", + "dflt": "", + "role": "style", + "valType": "string" + }, + "ticktext": { + "description": "Sets the text displayed at the ticks position via `tickvals`. Only has an effect if `tickmode` is set to *array*. Used with `tickvals`.", + "role": "data", + "valType": "data_array" + }, + "ticktextsrc": { + "description": "Sets the source reference on plot.ly for ticktext .", + "role": "info", + "valType": "string" + }, + "tickvals": { + "description": "Sets the values at which ticks on this axis appear. Only has an effect if `tickmode` is set to *array*. Used with `ticktext`.", + "role": "data", + "valType": "data_array" + }, + "tickvalssrc": { + "description": "Sets the source reference on plot.ly for tickvals .", + "role": "info", + "valType": "string" + }, + "tickwidth": { + "description": "Sets the tick width (in px).", + "dflt": 1, + "min": 0, + "role": "style", + "valType": "number" + }, + "title": { + "description": "Sets the title of the color bar.", + "dflt": "Click to enter colorscale title", + "role": "info", + "valType": "string" + }, + "titlefont": { + "color": { + "role": "style", + "valType": "color" + }, + "description": "Sets this color bar's title font.", + "family": { + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "noBlank": true, + "role": "style", + "strict": true, + "valType": "string" + }, + "role": "object", + "size": { + "min": 1, + "role": "style", + "valType": "number" + } + }, + "titleside": { + "description": "Determines the location of the colorbar title with respect to the color bar.", + "dflt": "top", + "role": "style", + "valType": "enumerated", + "values": [ + "right", + "top", + "bottom" + ] + }, + "x": { + "description": "Sets the x position of the color bar (in plot fraction).", + "dflt": 1.02, + "max": 3, + "min": -2, + "role": "style", + "valType": "number" + }, + "xanchor": { + "description": "Sets this color bar's horizontal position anchor. This anchor binds the `x` position to the *left*, *center* or *right* of the color bar.", + "dflt": "left", + "role": "style", + "valType": "enumerated", + "values": [ + "left", + "center", + "right" + ] + }, + "xpad": { + "description": "Sets the amount of padding (in px) along the x direction.", + "dflt": 10, + "min": 0, + "role": "style", + "valType": "number" + }, + "y": { + "description": "Sets the y position of the color bar (in plot fraction).", + "dflt": 0.5, + "max": 3, + "min": -2, + "role": "style", + "valType": "number" + }, + "yanchor": { + "description": "Sets this color bar's vertical position anchor This anchor binds the `y` position to the *top*, *middle* or *bottom* of the color bar.", + "dflt": "middle", + "role": "style", + "valType": "enumerated", + "values": [ + "top", + "middle", + "bottom" + ] + }, + "ypad": { + "description": "Sets the amount of padding (in px) along the y direction.", + "dflt": 10, + "min": 0, + "role": "style", + "valType": "number" + } + }, + "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`. 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" + }, + "opacity": { + "arrayOk": false, + "description": "Sets the marker opacity.", + "max": 1, + "min": 0, + "role": "style", + "valType": "number" + }, + "reversescale": { + "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" + }, + "role": "object", + "showscale": { + "description": "Has an effect only if `marker.color` is set to a numerical array. Determines whether or not a colorbar is displayed.", + "dflt": false, + "role": "info", + "valType": "boolean" + }, + "size": { + "arrayOk": true, + "description": "Sets the marker size (in px).", + "dflt": 6, + "min": 0, + "role": "style", + "valType": "number" + }, + "sizemin": { + "description": "Has an effect only if `marker.size` is set to a numerical array. Sets the minimum size (in px) of the rendered marker points.", + "dflt": 0, + "min": 0, + "role": "style", + "valType": "number" + }, + "sizemode": { + "description": "Has an effect only if `marker.size` is set to a numerical array. Sets the rule for which the data in `size` is converted to pixels.", + "dflt": "diameter", + "role": "info", + "valType": "enumerated", + "values": [ + "diameter", + "area" + ] + }, + "sizeref": { + "description": "Has an effect only if `marker.size` is set to a numerical array. Sets the scale factor used to determine the rendered size of marker points. Use with `sizemin` and `sizemode`.", + "dflt": 1, + "role": "style", + "valType": "number" + }, + "sizesrc": { + "description": "Sets the source reference on plot.ly for size .", + "role": "info", + "valType": "string" + }, + "symbol": { + "arrayOk": true, + "description": "Sets the marker symbol. Full list: https://www.mapbox.com/maki-icons/ Note that the array `marker.color` and `marker.size` are only available for *circle* symbols.", + "dflt": "circle", + "role": "style", + "valType": "string" + }, + "symbolsrc": { + "description": "Sets the source reference on plot.ly for symbol .", + "role": "info", + "valType": "string" + } + }, + "mode": { + "description": "Determines the drawing mode for this scatter trace. If the provided `mode` includes *text* then the `text` elements appear at the coordinates. Otherwise, the `text` elements appear on hover.", + "dflt": "markers", + "extras": [ + "none" + ], + "flags": [ + "lines", + "markers", + "text" + ], + "role": "info", + "valType": "flaglist" + }, + "name": { + "description": "Sets the trace name. The trace name appear as the legend item and on hover.", + "role": "info", + "valType": "string" + }, + "opacity": { + "description": "Sets the opacity of the trace.", + "dflt": 1, + "max": 1, + "min": 0, + "role": "style", + "valType": "number" + }, + "showlegend": { + "description": "Determines whether or not an item corresponding to this trace is shown in the legend.", + "dflt": true, + "role": "info", + "valType": "boolean" + }, + "stream": { + "maxpoints": { + "description": "Sets the maximum number of points to keep on the plots from an incoming stream. If `maxpoints` is set to *50*, only the newest 50 points will be displayed on the plot.", + "min": 0, + "role": "info", + "valType": "number" + }, + "role": "object", + "token": { + "description": "The stream id number links a data trace on a plot with a stream. See https://plot.ly/settings for more details.", + "noBlank": true, + "role": "info", + "strict": true, + "valType": "string" + } + }, + "subplot": { + "description": "Sets a reference between this trace's data coordinates and a mapbox subplot. If *mapbox* (the default value), the data refer to `layout.mapbox`. If *mapbox2*, the data refer to `layout.mapbox2`, and so on.", + "dflt": "mapbox", + "role": "info", + "valType": "subplotid" + }, + "text": { + "arrayOk": true, + "description": "Sets text elements associated with each (lon,lat) pair If a single string, the same string appears over all the data points. If an array of string, the items are mapped in order to the this trace's (lon,lat) coordinates.", + "dflt": "", + "role": "info", + "valType": "string" + }, + "textfont": { + "color": { + "role": "style", + "valType": "color" + }, + "description": "Sets the icon text font. Has an effect only when `type` is set to *symbol*.", + "family": { + "description": "HTML font family - the typeface that will be applied by the web browser. The web browser will only be able to apply a font if it is available on the system which it operates. Provide multiple font families, separated by commas, to indicate the preference in which to apply fonts if they aren't available on the system. The plotly service (at https://plot.ly or on-premise) generates images on a server, where only a select number of fonts are installed and supported. These include *Arial*, *Balto*, *Courier New*, *Droid Sans*,, *Droid Serif*, *Droid Sans Mono*, *Gravitas One*, *Old Standard TT*, *Open Sans*, *Overpass*, *PT Sans Narrow*, *Raleway*, *Times New Roman*.", + "dflt": "Open Sans Regular, Arial Unicode MS Regular", + "noBlank": true, + "role": "style", + "strict": true, + "valType": "string" + }, + "role": "object", + "size": { + "min": 1, + "role": "style", + "valType": "number" + } + }, + "textposition": { + "arrayOk": false, + "description": "Sets the positions of the `text` elements with respects to the (x,y) coordinates.", + "dflt": "middle center", + "role": "style", + "valType": "enumerated", + "values": [ + "top left", + "top center", + "top right", + "middle left", + "middle center", + "middle right", + "bottom left", + "bottom center", + "bottom right" + ] + }, + "textsrc": { + "description": "Sets the source reference on plot.ly for text .", + "role": "info", + "valType": "string" + }, + "type": "scattermapbox", + "uid": { + "dflt": "", + "role": "info", + "valType": "string" + }, + "visible": { + "description": "Determines whether or not this trace is visible. If *legendonly*, the trace is not drawn, but can appear as a legend item (provided that the legend itself is visible).", + "dflt": true, + "role": "info", + "valType": "enumerated", + "values": [ + true, + false, + "legendonly" + ] + } + }, + "description": "The data visualized as scatter point, lines or marker symbols on a Mapbox GL geographic map is provided by longitude/latitude pairs in `lon` and `lat`.", + "hrName": "scatter_mapbox" + }, "scatterternary": { "attributes": { "a": { diff --git a/plotly/stuff.js b/plotly/stuff.js new file mode 100644 index 00000000000..447f6fc8d94 --- /dev/null +++ b/plotly/stuff.js @@ -0,0 +1 @@ +{"type": "FeatureCollection", "features": [{"geometry": {"type": "MultiPolygon", "coordinates": [[[[-124.194502, 40.961703], [-124.182694, 41.001312999999996], [-124.204984, 41.013638], [-124.227079, 41.046622], [-124.231202, 41.065501], [-124.249588, 41.099025], [-124.24916400000001, 41.120157], [-124.252474, 41.134074999999996], [-124.247236, 41.152817], [-124.237625, 41.165959], [-124.21941799999999, 41.177687], [-124.195532, 41.184582], [-124.176367, 41.237148], [-124.173316, 41.260995], [-124.160704, 41.289293], [-124.163398, 41.293169], [-124.192328, 41.29199], [-124.220032, 41.302994], [-124.23821, 41.321446], [-124.24242, 41.3433], [-124.238191, 41.358705], [-124.231087, 41.368856], [-124.206515, 41.384718], [-124.176556, 41.390352], [-124.154195, 41.387628], [-124.139973, 41.381820999999995], [-124.133231, 41.432311], [-124.136906, 41.446822999999995], [-124.136561, 41.464452], [-123.770551, 41.464193], [-123.770239, 41.380776], [-123.50117, 41.382567], [-123.474085, 41.366192999999996], [-123.48250999999999, 41.353649999999995], [-123.478641, 41.329648], [-123.472471, 41.321546999999995], [-123.46343999999999, 41.31773], [-123.459592, 41.310238999999996], [-123.460335, 41.303304], [-123.455475, 41.292819], [-123.463241, 41.286338], [-123.461889, 41.282589], [-123.443821, 41.273233], [-123.44214, 41.251396], [-123.455307, 41.236537], [-123.434376, 41.222874999999995], [-123.435313, 41.213301], [-123.42770999999999, 41.203340999999995], [-123.417095, 41.197002], [-123.40829099999999, 41.179944], [-123.410365, 41.170705999999996], [-123.416949, 41.16553], [-123.432608, 41.162327999999995], [-123.42876799999999, 41.152062], [-123.431491, 41.147726999999996], [-123.429251, 41.118], [-123.434289, 41.111655], [-123.439806, 41.092541], [-123.449479, 41.089106], [-123.464222, 41.094408], [-123.458282, 41.083785999999996], [-123.464006, 41.076347999999996], [-123.457942, 41.068214999999995], [-123.452525, 41.068531], [-123.445599, 41.061681], [-123.435219, 41.060615999999996], [-123.430723, 41.063266999999996], [-123.423272, 41.058157], [-123.423754, 41.043185], [-123.419282, 41.034528], [-123.407218, 41.030619], [-123.410312, 41.020674], [-123.40603999999999, 41.012896999999995], [-123.420059, 41.009674], [-123.425755, 41.003510999999996], [-123.427258, 40.988256], [-123.434855, 40.982552], [-123.436555, 40.973653], [-123.453258, 40.964152999999996], [-123.45295899999999, 40.960059], [-123.444859, 40.956157999999995], [-123.445661, 40.947054], [-123.449488, 40.943132999999996], [-123.467656, 40.938159], [-123.477958, 40.928056], [-123.481457, 40.914957], [-123.511758, 40.920356999999996], [-123.529659, 40.934855999999996], [-123.533859, 40.930755999999995], [-123.540959, 40.932255999999995], [-123.54115999999999, 40.939656], [-123.560163, 40.950257], [-123.569961, 40.946555], [-123.56766, 40.936555999999996], [-123.581556, 40.933157], [-123.587861, 40.927755], [-123.599261, 40.931155], [-123.611362, 40.929255], [-123.622387, 40.931703], [-123.623891, 40.928674], [-123.613423, 40.921551], [-123.615827, 40.914068], [-123.604725, 40.900369999999995], [-123.608542, 40.894937999999996], [-123.597211, 40.884104], [-123.601709, 40.879953], [-123.61025000000001, 40.878972], [-123.59799699999999, 40.877615], [-123.591109, 40.867281999999996], [-123.5806, 40.867999], [-123.58754, 40.858483], [-123.575841, 40.857994], [-123.573162, 40.843515], [-123.563059, 40.840416999999995], [-123.566243, 40.834978], [-123.559628, 40.830318999999996], [-123.568731, 40.819739999999996], [-123.562522, 40.809698], [-123.556215, 40.808817], [-123.554071, 40.796309], [-123.557779, 40.793741999999995], [-123.56584699999999, 40.796231], [-123.566253, 40.78881], [-123.560033, 40.790268999999995], [-123.55828, 40.781071], [-123.549865, 40.775808], [-123.554507, 40.766656], [-123.55019300000001, 40.762803999999996], [-123.554165, 40.759502], [-123.550907, 40.756085], [-123.551806, 40.748127], [-123.548096, 40.746373], [-123.543015, 40.733578], [-123.54445799999999, 40.001923], [-124.134889, 40.002469999999995], [-124.145333, 40.024170999999996], [-124.144099, 40.052400999999996], [-124.153762, 40.063544], [-124.23120399999999, 40.093382], [-124.272099, 40.133649999999996], [-124.287833, 40.137682999999996], [-124.33368899999999, 40.167175], [-124.403151, 40.218005], [-124.421287, 40.237102], [-124.42914999999999, 40.266915], [-124.427899, 40.288804], [-124.41827599999999, 40.314288999999995], [-124.427945, 40.338823], [-124.428055, 40.361785], [-124.44470799999999, 40.376411999999995], [-124.478625, 40.422101999999995], [-124.48200299999999, 40.440318], [-124.479158, 40.452636], [-124.455952, 40.484047], [-124.447677, 40.529709], [-124.427191, 40.562084999999996], [-124.403367, 40.61317], [-124.3429, 40.708832], [-124.29933299999999, 40.768481], [-124.292662, 40.788094], [-124.280181, 40.799932], [-124.23262199999999, 40.869285999999995], [-124.214964, 40.906403999999995], [-124.194502, 40.961703]]]]} \ No newline at end of file diff --git a/plotly/tests/test_core/temp-plot.html b/plotly/tests/test_core/temp-plot.html new file mode 100644 index 00000000000..3dfddae4dd4 --- /dev/null +++ b/plotly/tests/test_core/temp-plot.html @@ -0,0 +1 @@ +
\ No newline at end of file diff --git a/plotly/tests/test_core/test_colors/__init__.py b/plotly/tests/test_core/test_colors/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/plotly/tests/test_core/test_colors/test_colors.py b/plotly/tests/test_core/test_colors/test_colors.py new file mode 100644 index 00000000000..864ac7a3f18 --- /dev/null +++ b/plotly/tests/test_core/test_colors/test_colors.py @@ -0,0 +1,115 @@ +from unittest import TestCase + +from nose.tools import raises +import plotly.tools as tls +from plotly.exceptions import PlotlyError +import plotly.colors as colors + + +class TestColors(TestCase): + + def test_validate_colors(self): + + # test string input + color_string = 'foo' + + pattern = ("If your colors variable is a string, it must be a " + "Plotly scale, an rgb color or a hex color.") + + self.assertRaisesRegexp(PlotlyError, pattern, colors.validate_colors, + color_string) + + # test rgb color + color_string2 = 'rgb(265, 0, 0)' + + pattern2 = ("Whoops! The elements in your rgb colors tuples cannot " + "exceed 255.0.") + + self.assertRaisesRegexp(PlotlyError, pattern2, colors.validate_colors, + color_string2) + + # test tuple color + color_tuple = (1, 1, 2) + + pattern3 = ("Whoops! The elements in your colors tuples cannot " + "exceed 1.0.") + + self.assertRaisesRegexp(PlotlyError, pattern3, colors.validate_colors, + color_tuple) + + def test_convert_colors_to_same_type(self): + + # test string input + color_string = 'foo' + + pattern = ("If your colors variable is a string, it must be a " + "Plotly scale, an rgb color or a hex color.") + + self.assertRaisesRegexp(PlotlyError, pattern, + colors.convert_colors_to_same_type, + color_string) + + # test colortype + color_tuple = (1, 1, 1) + colortype = 2 + + pattern2 = ("You must select either rgb or tuple for your colortype " + "variable.") + + self.assertRaisesRegexp(PlotlyError, pattern2, + colors.convert_colors_to_same_type, + color_tuple, colortype) + + def test_convert_dict_colors_to_same_type(self): + + # test colortype + color_dict = dict(apple='rgb(1, 1, 1)') + colortype = 2 + + pattern = ("You must select either rgb or tuple for your colortype " + "variable.") + + self.assertRaisesRegexp(PlotlyError, pattern, + colors.convert_dict_colors_to_same_type, + color_dict, colortype) + + def test_make_colorscale(self): + + # test minimum colors length + color_list = [(0, 0, 0)] + + pattern = ( + "You must input a list of colors that has at least two colors." + ) + + self.assertRaisesRegexp(PlotlyError, pattern, colors.make_colorscale, + color_list) + + # test length of colors and scale + color_list2 = [(0, 0, 0), (1, 1, 1)] + scale = [0] + + pattern2 = ("The length of colors and scale must be the same.") + + self.assertRaisesRegexp(PlotlyError, pattern2, colors.make_colorscale, + color_list2, scale) + + # test first and last number of scale + scale2 = [0, 2] + + pattern3 = ("The first and last number in scale must be 0.0 and 1.0 " + "respectively.") + + self.assertRaisesRegexp(PlotlyError, pattern3, colors.make_colorscale, + color_list2, scale2) + + # test for strictly increasing scale + color_list3 = [(0, 0, 0), (0.5, 0.5, 0.5), (1, 1, 1)] + scale3 = [0, 1, 1] + + pattern4 = ("'scale' must be a list that contains an increasing " + "sequence of numbers where the first and last number are" + "0.0 and 1.0 respectively.") + + self.assertRaisesRegexp(PlotlyError, pattern4, colors.make_colorscale, + color_list3, scale3) diff --git a/plotly/tests/test_optional/temp-plot.html b/plotly/tests/test_optional/temp-plot.html new file mode 100644 index 00000000000..f4f6146b005 --- /dev/null +++ b/plotly/tests/test_optional/temp-plot.html @@ -0,0 +1,45 @@ + \ No newline at end of file diff --git a/plotly/tests/test_optional/test_figure_factory.py b/plotly/tests/test_optional/test_figure_factory.py index c2a0f3da624..f8fcafcd947 100644 --- a/plotly/tests/test_optional/test_figure_factory.py +++ b/plotly/tests/test_optional/test_figure_factory.py @@ -842,72 +842,101 @@ def test_trisurf_all_args(self): ) exp_trisurf_plot = { - 'data': [ - { - 'facecolor': ['rgb(144.0, 94.5, 132.0)', - 'rgb(23.0, 190.0, 207.0)', - 'rgb(144.0, 94.5, 132.0)', - 'rgb(31.0, 119.0, 180.0)', - 'rgb(144.0, 94.5, 132.0)', - 'rgb(31.0, 119.0, 180.0)', - 'rgb(144.0, 94.5, 132.0)', - 'rgb(23.0, 190.0, 207.0)'], - 'i': [3, 1, 1, 5, 7, 3, 5, 7], - 'j': [1, 3, 5, 1, 3, 7, 7, 5], - 'k': [4, 0, 4, 2, 4, 6, 4, 8], - 'name': '', - 'type': 'mesh3d', - 'x': np.array([-1., 0., 1., -1., 0., 1., -1., 0., 1.]), - 'y': np.array([-1., -1., -1., 0., 0., 0., 1., 1., 1.]), - 'z': np.array([ 1., -0., -1., -0., 0., 0., -1., 0., 1.]) - }, - { - 'line': {'color': 'rgb(50, 50, 50)', 'width': 1.5}, - 'mode': 'lines', - 'type': 'scatter3d', - 'x': [-1.0, 0.0, 0.0, -1.0, None, 0.0, -1.0, -1.0, 0.0, None, - 0.0, 1.0, 0.0, 0.0, None, 1.0, 0.0, 1.0, 1.0, None, 0.0, - -1.0, 0.0, 0.0, None, -1.0, 0.0, -1.0, -1.0, None, 1.0, - 0.0, 0.0, 1.0, None, 0.0, 1.0, 1.0, 0.0, None], - 'y': [0.0, -1.0, 0.0, 0.0, None, -1.0, 0.0, -1.0, -1.0, None, - -1.0, 0.0, 0.0, -1.0, None, 0.0, -1.0, -1.0, 0.0, None, - 1.0, 0.0, 0.0, 1.0, None, 0.0, 1.0, 1.0, 0.0, None, 0.0, - 1.0, 0.0, 0.0, None, 1.0, 0.0, 1.0, 1.0, None], - 'z': [-0.0, -0.0, 0.0, -0.0, None, -0.0, -0.0, 1.0, -0.0, - None, -0.0, 0.0, 0.0, -0.0, None, 0.0, -0.0, -1.0, 0.0, - None, 0.0, -0.0, 0.0, 0.0, None, -0.0, 0.0, -1.0, -0.0, - None, 0.0, 0.0, 0.0, 0.0, None, 0.0, 0.0, 1.0, 0.0, None] - } - ], - 'layout': { - 'height': 800, - 'scene': {'aspectratio': {'x': 1, 'y': 1, 'z': 1}, - 'xaxis': {'backgroundcolor': 'rgb(230, 230, 230)', - 'gridcolor': 'rgb(255, 255, 255)', - 'showbackground': True, - 'zerolinecolor': 'rgb(255, 255, 255)'}, - 'yaxis': {'backgroundcolor': 'rgb(230, 230, 230)', - 'gridcolor': 'rgb(255, 255, 255)', - 'showbackground': True, - 'zerolinecolor': 'rgb(255, 255, 255)'}, - 'zaxis': {'backgroundcolor': 'rgb(230, 230, 230)', - 'gridcolor': 'rgb(255, 255, 255)', - 'showbackground': True, - 'zerolinecolor': 'rgb(255, 255, 255)'}}, - 'title': 'Trisurf Plot', - 'width': 800 - } + 'data': [{'facecolor': np.array( + ['rgb(145.0, 96.0, 143.0)', + 'rgb(29.0, 190.0, 201.0)', + 'rgb(145.0, 96.0, 143.0)', + 'rgb(31.0, 119.0, 180.0)', + 'rgb(145.0, 96.0, 143.0)', + 'rgb(31.0, 119.0, 180.0)', + 'rgb(145.0, 96.0, 143.0)', + 'rgb(29.0, 190.0, 201.0)'], + ), + 'i': np.array([3, 1, 1, 5, 7, 3, 5, 7]), + 'j': np.array([1, 3, 5, 1, 3, 7, 7, 5]), + 'k': np.array([4, 0, 4, 2, 4, 6, 4, 8]), + 'name': '', + 'type': 'mesh3d', + 'x': np.array([-1., 0., 1., -1., 0., 1., + -1., 0., 1.]), + 'y': np.array([-1., -1., -1., 0., 0., 0., + 1., 1., 1.]), + 'z': np.array([1., -0., -1., -0., 0., 0., + -1., 0., 1.])}, + {'line': {'color': 'rgb(50, 50, 50)', 'width': 1.5}, + 'mode': 'lines', + 'type': 'scatter3d', + 'x': np.array([-1.0, 0.0, 0.0, -1.0, None, 0.0, -1.0, + -1.0, 0.0, None, 0.0, 1.0, 0.0, 0.0, + None, 1.0, 0.0, 1.0, 1.0, None, 0.0, + -1.0, 0.0, 0.0, None, -1.0, 0.0, -1.0, + -1.0, None, 1.0, 0.0, 0.0, 1.0, None, + 0.0, 1.0, 1.0, 0.0, None]), + 'y': np.array([0.0, -1.0, 0.0, 0.0, None, -1.0, 0.0, + -1.0, -1.0, None, -1.0, 0.0, 0.0, -1.0, + None, 0.0, -1.0, -1.0, 0.0, None, 1.0, + 0.0, 0.0, 1.0, None, 0.0, 1.0, 1.0, 0.0, + None, 0.0, 1.0, 0.0, 0.0, None, 1.0, 0.0, + 1.0, 1.0, None]), + 'z': np.array([-0.0, -0.0, 0.0, -0.0, None, -0.0, -0.0, + 1.0, -0.0, None, -0.0, 0.0, 0.0, -0.0, + None, 0.0, -0.0, -1.0, 0.0, None, 0.0, + -0.0, 0.0, 0.0, None, -0.0, 0.0, -1.0, + -0.0, None, 0.0, 0.0, 0.0, 0.0, None, + 0.0, 0.0, 1.0, 0.0, None])}, + {'colorscale': [[0.0, 'rgb(31.0, 119.0, 180.0)'], + [0.1111111111111111, 'rgb(255.0, 127.0, 14.0)'], + [0.2222222222222222, 'rgb(44.0, 160.0, 44.0)'], + [0.3333333333333333, 'rgb(214.0, 39.0, 40.0)'], + [0.4444444444444444, 'rgb(148.0, 103.0, 189.0)'], + [0.5555555555555556, 'rgb(140.0, 86.0, 75.0)'], + [0.6666666666666666, 'rgb(227.0, 119.0, 194.0)'], + [0.7777777777777778, 'rgb(127.0, 127.0, 127.0)'], + [0.8888888888888888, 'rgb(188.0, 189.0, 34.0)'], + [1.0, 'rgb(23.0, 190.0, 207.0)']], + 'intensity': [0, 1], + 'showscale': True, + 'type': 'mesh3d', + 'x': [0, 1], + 'y': [0, 1], + 'z': [0, 1]}], + 'layout': {'height': 800, + 'scene': {'aspectratio': {'x': 1, 'y': 1, 'z': 1}, + 'xaxis': {'backgroundcolor': + 'rgb(230, 230, 230)', + 'gridcolor': + 'rgb(255, 255, 255)', + 'showbackground': True, + 'zerolinecolor': + 'rgb(255, 255, 255)'}, + 'yaxis': {'backgroundcolor': + 'rgb(230, 230, 230)', + 'gridcolor': 'rgb(255, 255, 255)', + 'showbackground': True, + 'zerolinecolor': + 'rgb(255, 255, 255)'}, + 'zaxis': {'backgroundcolor': + 'rgb(230, 230, 230)', + 'gridcolor': 'rgb(255, 255, 255)', + 'showbackground': True, + 'zerolinecolor': + 'rgb(255, 255, 255)'}}, + 'title': 'Trisurf Plot', + 'width': 800} } - self.assert_dict_equal(test_trisurf_plot['layout'], - exp_trisurf_plot['layout']) - self.assert_dict_equal(test_trisurf_plot['data'][0], exp_trisurf_plot['data'][0]) self.assert_dict_equal(test_trisurf_plot['data'][1], exp_trisurf_plot['data'][1]) + self.assert_dict_equal(test_trisurf_plot['data'][2], + exp_trisurf_plot['data'][2]) + + self.assert_dict_equal(test_trisurf_plot['layout'], + exp_trisurf_plot['layout']) + # Test passing custom colors colors_raw = np.random.randn(simplices.shape[0]) colors_str = ['rgb(%s, %s, %s)' % (i, j, k)