def yerrorbar(self, ax, X, Y, error, Z=None, color=Tango.colorsHex['mediumBlue'], label=None, error_kwargs=None, **kwargs): error_kwargs = error_kwargs or {} if (error.shape[0] == 2) and (error.ndim == 2): error_kwargs.update( dict(array=error[1], arrayminus=error[0], symmetric=False)) else: error_kwargs.update(dict(array=error, symmetric=True)) if Z is not None: return Scatter3d(x=X, y=Y, z=Z, mode='markers', error_y=ErrorY(color=color, **error_kwargs or {}), marker=Marker(size='0'), name=label, showlegend=label is not None, **kwargs) return Scatter(x=X, y=Y, mode='markers', error_y=ErrorY(color=color, **error_kwargs or {}), marker=Marker(size='0'), name=label, showlegend=label is not None, **kwargs)
def plot_linear_prediction(results, data, filename): x_transform = (add_month(data[0][-1]) - min(data[0])).days x_val = add_month(data[0][-1]) prediction = results.params["x"] * x_transform + results.params["Intercept"] trace1 = Scatter(x=data[0], y=data[1], mode='lines', marker=Marker(color='rgb(255, 127, 14)'), name='Data') trace2 = Scatter(x=[x_val], y=[prediction], mode='markers', marker=Marker(color='rgb(31, 119, 180)'), name='Fit') layout = Layout(title='Linear Fit in Python', plot_bgcolor='rgb(229, 229, 229)', xaxis=XAxis(zerolinecolor='rgb(255,255,255)', gridcolor='rgb(255,255,255)'), yaxis=YAxis(zerolinecolor='rgb(255,255,255)', gridcolor='rgb(255,255,255)')) to_scatter = [trace1, trace2] plotly.offline.plot({"data": to_scatter, "layout": layout}) shutil.move("temp-plot.html", filename)
def _addDetections(self, name, symbol, FP, TP): """Plot markers at anomaly detections; standard is for open shapes.""" symbol = symbol + "-open" # FPs: fpTrace = Scatter(x=FP["timestamp"], y=FP["value"], mode="markers", name=name, text=["anomalous data"], marker=Marker(color="rgb(200, 20, 20)", size=15.0, symbol=symbol, line=Line(color="rgb(200, 20, 20)", width=2))) # TPs: tpTrace = Scatter(x=[tp[1]["timestamp"] for tp in TP], y=[tp[1]["value"] for tp in TP], mode="markers", name=name, text=["anomalous data"], marker=Marker(color="rgb(20, 200, 20)", size=15.0, symbol=symbol, line=Line(color="rgb(20, 200, 20)", width=2))) return fpTrace, tpTrace
def setUp(self): super(TestToDataframe, self).setUp() self.fig = Figure(data=Data([ Scatter(x=[52698, 43117], y=[53, 31], mode='markers', name='North America', text=['United States', 'Canada'], marker=Marker(color='rgb(164, 194, 244)', size=12, line=Line(color='white', width=0.5))), Scatter(x=[ 39317, 37236, 35650, 30066, 29570, 27159, 23557, 21046, 18007 ], y=[33, 20, 13, 19, 27, 19, 49, 44, 38], mode='markers', name='Europe', text=[ 'Germany', 'Britain', 'France', 'Spain', 'Italy', 'Czech Rep.', 'Greece', 'Poland' ], marker=Marker(color='rgb(255, 217, 102)', size=12, line=Line(color='white', width=0.5))), Scatter(x=[42952, 37037, 33106, 17478, 9813, 5253, 4692, 3899], y=[23, 42, 54, 89, 14, 99, 93, 70], mode='markers', name='Asia/Pacific', text=[ 'Australia', 'Japan', 'South Korea', 'Malaysia', 'China', 'Indonesia', 'Philippines', 'India' ], marker=Marker(color='rgb(234, 153, 153)', size=12, line=Line(color='white', width=0.5))), Scatter(x=[19097, 18601, 15595, 13546, 12026, 7434, 5419], y=[43, 47, 56, 80, 86, 93, 80], mode='markers', name='Latin America', text=[ 'Chile', 'Argentina', 'Mexico', 'Venezuela', 'Venezuela', 'El Salvador', 'Bolivia' ], marker=Marker(color='rgb(142, 124, 195)', size=12, line=Line(color='white', width=0.5))) ]), layout=Layout(title='Quarter 1 Growth', autosize=False, width=500, height=500, xaxis=XAxis(title='GDP per Capita', showgrid=False, zeroline=False), yaxis=YAxis(title='Percent', showline=False), margin=Margin(l=65, r=50, b=65, t=90)))
def features_tsne(feats, feat_names, grp_col, grp_colors, title='', lrate=200.0, niter=1000, save_res=[], show_pt_nums=False): """Creats a T-SNE plot for features given grouping column Args: feats: A dataframe where the columns are the features and the rows are the samples. feat_names: A list containing the features to transform. grp_col: The column name in feats where the grouping indices are. grp_colors: A dictionary indicating the color to use for each group title: An optional plot title Returns: A plotly figure. """ t_sne = TSNE(n_components=2, random_state=0, learning_rate=lrate, n_iter=niter) feats_2d = t_sne.fit_transform(np.array(feats.loc[:, feat_names])) grps = np.unique(feats[grp_col]) traces = [] for g in grps: inds = np.array(feats[grp_col]) == g if show_pt_nums: txt = np.where(inds)[0] traces.append( go.Scatter(x=feats_2d[inds, 0], y=feats_2d[inds, 1], text=txt, name=g, mode='markers+text', marker=Marker(color=grp_colors[g]))) else: traces.append( go.Scatter(x=feats_2d[inds, 0], y=feats_2d[inds, 1], name=g, mode='markers', marker=Marker(color=grp_colors[g]))) fig = go.Figure(data=traces, layout=go.Layout(title=title)) save_res.append(feats_2d) return fig
def createGraph(): dataX = [] dataY = [] trainingSet = get_training_set() testSet = get_test_set() for k in range(1, len(trainingSet)): dataX.append(k) dataY.append(calculateWithKFofGraph(testSet, trainingSet, k)) trace1 = Scatter(x=dataX, y=dataY, mode='markers', name="Actual Value") z = np.polyfit(dataX, dataY, 3) f = np.poly1d(z) x_new = np.linspace(dataX[0], dataX[-1], 50) y_new = f(x_new) trace2 = Scatter(x=x_new, y=y_new, mode='lines', marker=Marker(color='rgb(100, 100, 100)'), name='Fit') data = [trace1, trace2] layout = dict( title='correct %', xaxis=dict(title='K value'), yaxis=dict(title='Accuracy %'), ) fig = dict(data=data, layout=layout) py.sign_in('a9595', 'JiSGkDYi671JmrA2oy41') py.plot(fig, filename='kNN correct % versus K')
def _addWindows(self, start=None, end=None): """Return plotly trace for anomaly windows.""" if start is None: start = self.rawData["timestamp"][0] if end is None: end = self.rawData["timestamp"].iloc[-1] mask = ((self.rawData["timestamp"] >= start) & (self.rawData["timestamp"] <= end)) windows = getJSONData( os.path.join(self.labelsDir, "combined_windows.json"))[self.dataFile] x = [] delta = (pd.to_datetime(self.rawData["timestamp"].iloc[1]) - pd.to_datetime(self.rawData["timestamp"].iloc[0])) minutes = int(delta.total_seconds() / 60) for window in windows: windowStart = max(pd.to_datetime(window[0]), pd.to_datetime(start)) windowEnd = min(pd.to_datetime(window[1]), pd.to_datetime(end)) x.extend( pd.date_range(windowStart, windowEnd, freq=str(minutes) + "Min").tolist()) maxVal = self.rawData.value.max() y = [maxVal for _ in x] return Bar(x=x, y=y, name="Anomaly Window", marker=Marker(color="rgb(220, 100, 100)"), opacity=0.3)
def plot_precision_recall_fscore(precision, recall, fscore, filename='new_result.html'): avg_data = np.array([np.mean(precision), np.mean(recall), np.mean(fscore)]) panda_avg = pd.DataFrame(avg_data).round(3) data = np.array(panda_avg.values).T[0] print(avg_data) print(panda_avg) print(data) trace = [ plotly.graph_objs.Bar(x=['precision', 'recall', 'fscore'], y=data, marker=Marker(color='#04b486'), text=data, textposition='auto', textfont=dict(color='brack', size='20')) ] layout = Layout(bargap=0.6, plot_bgcolor='#E6E6E6') plot_data = Figure(data=trace, layout=layout) plotly.offline.plot(plot_data, filename=filename)
def _addLabels(data, labels, target="value", start=None, end=None): """return plotly trace for anomaly labels.""" if start is None: start = data["timestamp"][0] if end is None: end = data["timestamp"].iloc[-1] x = [] y = [] for label in labels: row = data[data.timestamp == label] if ((row["timestamp"] >= start).values[0] and (row["timestamp"] <= end).values[0]): x.append(row["timestamp"]) y.append(row[target]) if x: x = pd.concat(x) y = pd.concat(y) return Scatter(x=x, y=y, mode="markers", name="Ground Truth Anomaly", text=["Anomalous Instance"], marker=Marker(color="rgb(200, 20, 20)", size=10, symbol=MARKERS[0]))
def plot_axis_lines(self, ax, X, color=Tango.colorsHex['mediumBlue'], label=None, marker_kwargs=None, **kwargs): if X.shape[1] == 1: annotations = Annotations() for i, row in enumerate(X): annotations.append( Annotation( text='', x=row[0], y=0, yref='paper', ax=0, ay=20, arrowhead=2, arrowsize=1, arrowwidth=2, arrowcolor=color, showarrow=True, #showlegend=i==0, #label=label, )) return annotations elif X.shape[1] == 2: marker_kwargs.setdefault('symbol', 'diamond') opacity = kwargs.pop('opacity', .8) return Scatter3d(x=X[:, 0], y=X[:, 1], z=np.zeros(X.shape[0]), mode='markers', projection=dict(z=dict(show=True, opacity=opacity)), marker=Marker(color=color, **marker_kwargs or {}), opacity=0, name=label, showlegend=label is not None, **kwargs)
def PlotGeom(GRS, ID): edge_trace = Scatter3d( x=[], y=[], z=[], # hoverinfo='none', mode='lines') for i in range(GRS.nbElAll): sID = GRS.lsAll.sID[i] eID = GRS.lsAll.eID[i] x0 = GRS.nsAll.x[sID] y0 = GRS.nsAll.y[sID] z0 = GRS.nsAll.z[sID] x1 = GRS.nsAll.x[eID] y1 = GRS.nsAll.y[eID] z1 = GRS.nsAll.z[eID] edge_trace['x'] += [x0, x1, None] edge_trace['y'] += [y0, y1, None] edge_trace['z'] += [z0, z1, None] node_trace = Scatter3d( x=[], y=[], z=[], text=[], mode='markers', hoverinfo='text', marker=Marker( color=['red'], size=5, ), line=dict(width=2)) node_trace['x'].append(GRS.nsAll.x[ID]) node_trace['y'].append(GRS.nsAll.y[ID]) node_trace['z'].append(GRS.nsAll.z[ID]) fig = Figure(data=Data([edge_trace, node_trace]), layout=Layout( showlegend=False, hovermode='closest', margin=dict(b=20, l=5, r=5, t=40), height=500, width=1000, scene=dict( aspectmode='data', xaxis=dict( showgrid=False, zeroline=False), yaxis=dict( showgrid=False, zeroline=False), zaxis=dict( showgrid=False, zeroline=False), ), )) return fig
def make_Scatter(sbplt_in, x_in, y_in, color_in, opacity_in): return Scatter(x=x_in, y=y_in, mode='markers', marker=Marker(color=color_in, opacity=opacity_in), name='', xaxis='x{}'.format(sbplt_in), yaxis='y{}'.format(sbplt_in))
def get_anomaly_scatter(df, detections, value_key): return Scatter(x=detections.index, y=[df.loc[index, value_key] for index in detections.index], mode="markers", name="Detected Anomaly", text=["anomalous data"], marker=Marker(color="rgb(200, 20, 20)", size=15.0, symbol='circle', line=Line(color="rgb(200, 20, 20)", width=2)))
def scatter(self, ax, X, Y, Z=None, color=Tango.colorsHex['mediumBlue'], cmap=None, label=None, marker='o', marker_kwargs=None, **kwargs): try: marker = SYMBOL_MAP[marker] except: #not matplotlib marker pass marker_kwargs = marker_kwargs or {} if 'symbol' not in marker_kwargs: marker_kwargs['symbol'] = marker X, Y = np.squeeze(X), np.squeeze(Y) if Z is not None: Z = np.squeeze(Z) return Scatter3d(x=X, y=Y, z=Z, mode='markers', showlegend=label is not None, marker=Marker(color=color, colorscale=cmap, **marker_kwargs), name=label, **kwargs) return Scatter(x=X, y=Y, mode='markers', showlegend=label is not None, marker=Marker(color=color, colorscale=cmap, **marker_kwargs), name=label, **kwargs)
def scatter_df_plotly(df, x, y, z, text_fnct=hover_all, streaming=True, filename=None): """ a wrapper function for `plotlyi.graph_objs.Scatter` on `pandas.Dataframe` usage: ===== d """ layout = Layout( title='colour map: %s' % z, hovermode='closest', # (!) hover -> closest data pt showlegend=False, # remove legend (info in hover) autosize=False, # turn off autosize width=650, # plot width height=500, # plot height xaxis=XAxis(title=x, titlefont=Font(family='Courier New, monospace', size=14, color='#7f7f7f')), yaxis=YAxis(title=y, titlefont=Font(family='Courier New, monospace', size=14, color='#7f7f7f'))) # print('marker sizes:') # print(rescale_marker(df[z], square = True)) SC = Scatter(x=df[x], y=df[y], mode='markers', marker=Marker(size=rescale_marker(df[z], square=True), color=df[z], colorscale='Jet', sizeref=1, sizemode='area')) FIG = Figure(data=Data([SC]), layout=layout) #FIG['layout'].update( ) if text_fnct is not None: FIG['data'][0].update(text = \ df.apply(lambda ds: text_fnct(ds, x=x, y=y,z=z), axis = 1).tolist() ) if not streaming: if filename is not None: return py.plot(FIG, filename=filename) else: return py.plot(FIG) else: return py.iplot(FIG)
def _addProbation(self): # Probationary period trace. length = min(int(0.15 * len(self.rawData)), 750) x = self.rawData["timestamp"].iloc[:length] y = [self.rawData.value.max() for _ in x] return Bar(x=x, y=y, name="Probationary Period", marker=Marker(color="rgb(0, 0, 200)"), opacity=0.2)
def barplot(self, canvas, x, height, width=0.8, bottom=0, color=Tango.colorsHex['mediumBlue'], label=None, **kwargs): figure, _, _ = canvas if 'barmode' in kwargs: figure.layout['barmode'] = kwargs.pop('barmode') return Bar(x=x, y=height, marker=Marker(color=color), name=label)
def getArgsForDataset(self, dataset): kwargs = {} kwargs['mode'] = 'lines' if 'name' in dataset and dataset['name'] is not None: kwargs['name'] = dataset['name'] else: kwargs['showlegend'] = False if 'showlegend' in dataset and dataset['showlegend'] is not None: # override with user-specified legend setting kwargs['showlegend'] = dataset['showlegend'] if 'alpha' in dataset and dataset['alpha'] is not None: kwargs['opacity'] = dataset['alpha'] if 'text' in dataset and dataset['text'] is not None: kwargs['text'] = dataset['text'] kwargs['textposition'] = 'bottom center' kwargs['mode'] = 'markers+text' kwargs['marker'] = Marker(color='black') if 'color' in dataset and dataset['color'] is not None: kwargs['marker'] = Marker(color=dataset['color']) # lines/markers (lines by default) if 'mode' in dataset and dataset['mode'] is not None: kwargs['mode'] = dataset['mode'] if 'dash' in dataset and dataset['dash'] is not None: kwargs['line'] = {'dash': dataset['dash']} # override mode via scatter if 'scatter' in dataset and dataset['scatter'] == True: kwargs['mode'] = 'markers' if 'error_y_pos' in dataset and dataset[ 'error_y_pos'] is not None and 'error_y_neg' in dataset and dataset[ 'error_y_neg'] is not None: kwargs['error_y'] = dict( type='data', symmetric=False, array=dataset['error_y_pos'], arrayminus=dataset['error_y_neg'], visible=True, ) return kwargs
def _plotly_3d_scatter(coords, partition=None): """ _plotly_3d_scatter(coords, partition=None) Make a scatterplot of treeCl.CoordinateMatrix using the Plotly plotting engine """ from plotly.graph_objs import Scatter3d, Data, Figure, Layout, Line, Margin, Marker # auto sign-in with credentials or use py.sign_in() colourmap = { 'A': '#1f77b4', 'B': '#ff7f0e', 'C': '#2ca02c', 'D': '#d62728', 'E': '#9467bd', 1: '#1f77b4', 2: '#ff7f0e', 3: '#2ca02c', 4: '#d62728', 5: '#9467bd' } df = coords.df if partition: assert len(partition.partition_vector) == df.shape[0] labels = [x + 1 for x in partition.partition_vector] else: labels = [1 for _ in range(df.shape[0])] x, y, z = df.columns[:3] df['Label'] = labels colours = [colourmap[lab] for lab in df['Label']] trace = Scatter3d(x=df[x], y=df[y], z=df[z], mode='markers', marker=Marker(size=9, color=colours, line=Line(color=colours, width=0.5), opacity=0.8), text=[str(ix) for ix in df.index]) data = Data([trace]) layout = Layout( margin=Margin(l=0, r=0, b=0, t=0), hovermode='x', ) fig = Figure(data=data, layout=layout) return fig
def scatter_nodes(pos, labels=None, size=8, opacity=1, title="Centrality", data=None, nodes=None, colorscale='Hot'): ''' Function to create a trace of scatter points to represent a node on the plot. Args: pos (dict): node positions labels (list): labels of len(pos), to be displayed when hovering the mouse over the nodes size (int): size of the dots representing the nodes opacity (float): value between [0,1] defining the node color opacity title (str): Title to be put on top of the colorbar data (dict): Measure to be plotted nodes (list): List with nodes id colorscale (str): colorscale for the data measure ColorScale options 'Greys' | 'Greens' | 'Bluered' | 'Hot' | 'Picnic' | 'Portland' | Jet' | 'RdBu' | 'Blackbody' | 'Earth' | 'Electric' | 'YIOrRd' | 'YIGnBu' Return: A trace object to be used on a plotly plot ''' trace = Scatter(x=[], y=[], mode='markers', marker=Marker(showscale=True, colorscale=colorscale, reversescale=True, color=[], size=10, colorbar=dict(thickness=15, title=title, xanchor='left', titleside='right'), line=dict(width=2))) for node in nodes: trace['x'].append(pos[node][0]) trace['y'].append(pos[node][1]) trace['marker']['color'].append(data[node]) attrib = dict(name='', text=labels, hoverinfo='text', opacity=opacity) trace = dict(trace, **attrib) trace['marker']['size'] = size return trace
def get_labels_scatter(data_df, labels_df, value_key): anomaly_indices = labels_df[labels_df[value_key] > 0].index return Scatter(x=anomaly_indices, y=[ data_df.loc[index, value_key] if index in data_df.index else 0 for index in anomaly_indices ], mode="markers", name="Anomaly", text=["Anomalous Instance"], marker=Marker(color="rgb(20, 200, 20)", size=15.0, symbol='diamond', line=Line(color="rgb(20, 200, 20)", width=2)))
def make_trace(X, continent, sizes, color): return Scatter( x=X['GNP'], # GDP on the x-xaxis y=X['LifeExpectancy'], # life Exp on th y-axis name=continent, # label continent names on hover mode='markers', # (!) point markers only on this plot text=X.apply(make_text, axis=1).tolist(), marker=Marker( color=color, # marker color size=sizes, # (!) marker sizes (sizes is a list) sizeref=sizeref, # link sizeref sizemode=sizemode, # link sizemode opacity=0.6, # (!) partly transparent markers line=Line(width=3, color="white") # marker borders ) )
def diff1(self): point_data = {} # Keys: distances, Values: list of extension IDs baseline_row = None baseline_id = None # Iterate through the rows for row in self.db_conn.execute(select([self.extension])): # Get the centroid centroid = () for field in self.all_fields: col = getattr(self.extension.c, USED_TO_DB[field]) centroid += (row[col],) if baseline_row is None: baseline_row = centroid baseline_id = row[self.extension.c.ext_id] continue diff = centroid_difference(baseline_row, centroid, self.norm_tup) try: point_data[diff].append(row[self.extension.c.ext_id]) except KeyError: point_data[diff] = [row[self.extension.c.ext_id]] diffs = list(point_data.keys()) diffs.sort() y = [] text = [] for r in diffs: for p in point_data[r]: y.append(r) text.append(p) trace = Scatter( y=y[:40000], text=text[:40000], name='Diff against %s' % baseline_id, mode='markers', marker=Marker(size=3) ) data = Data([trace]) if OFFLINE: pyoff.plot(data) else: plot_url = py.plot(data, filename="centroid-distances-normalized") print("Plot ready at: %s" % plot_url)
def scatter_nodes(pos, labels=None, color=None, size=10, opacity=1): """function from https://plot.ly/ipython-notebooks/networks/""" # pos is the dict of node positions # labels is a list of labels of len(pos), to be displayed when hovering the mouse over the nodes # color is the color for nodes. When it is set as None the Plotly default color is used # size is the size of the dots representing the nodes # opacity is a value between [0,1] defining the node color opacity L = len(pos) trace = Scatter(x=[], y=[], mode='markers', marker=Marker(size=[])) for k in range(L): trace['x'].append(pos[k][0]) trace['y'].append(pos[k][1]) attrib = dict(name='', text=labels, hoverinfo='text', opacity=opacity) # a dict of Plotly node attributes trace = dict(trace, **attrib) # concatenate the dict trace and attrib trace['marker']['size'] = size return trace
def _addProbation(self, start=None, end=None): if start is None: start = self.rawData["timestamp"][0] if end is None: end = self.rawData["timestamp"].iloc[-1] mask = ((self.rawData["timestamp"] >= start) & (self.rawData["timestamp"] <= end)) length = min(int(0.15 * len(self.rawData)), 750) x = self.rawData["timestamp"].iloc[:length][mask] y = [self.rawData.value.max() for _ in x] return Bar(x=x, y=y, name="Probationary Period", marker=Marker(color="rgb(0, 0, 200)"), opacity=0.2)
def iscatter(x, y, cols=None, xlog=False, ylog=False, nb=True, return_fig=False, ly_dict={}, **kwargs): from plotly.graph_objs import Scatter, Marker mkr = Marker({"color": cols, "opacity": 0.9, "colorscale": "Portland", "showscale": cols is not None}) traces = [Scatter({"x": x, "y": y, "mode": "markers", "marker": mkr})] layout = {"width": 700, "height": 700, "showlegend": False, "xaxis": {"showline": True, "mirror": "ticks", "ticks": "inside", "type": "log" if xlog else "linear"}, "yaxis": {"showline": True, "mirror": "ticks", "ticks": "inside", "type": "log" if ylog else "linear"}, **ly_dict} fig = {"data": traces, "layout": layout} if return_fig: return fig ishow(fig, nb=nb, **kwargs)
def _addLabels(self): """Return plotly trace for anomaly labels.""" labels = getJSONData(os.path.join(self.labelsDir, "yahoo_labels.json"))[self.dataFile] x = [] y = [] for label in labels: row = self.rawData[self.rawData.timestamp == label] x.append(row["timestamp"]) y.append(row["value"]) return Scatter(x=x, y=y, mode="markers", name="Ground Truth Anomaly", text=["anomalous instance"], marker=Marker(color="rgb(200, 20, 20)", size=10.0, symbol=self.markers[0]))
def _addWindows(self): """Return plotly trace for anomaly windows.""" windows = getJSONData( os.path.join(self.labelsDir, "yahoo_windows.json"))[self.dataFile] x = [] delta = (pd.to_datetime(self.rawData["timestamp"].iloc[1]) - pd.to_datetime(self.rawData["timestamp"].iloc[0])) minutes = int(delta.total_seconds() / 60) for window in windows: start = pd.to_datetime(window[0]) end = pd.to_datetime(window[1]) x.append( pd.date_range(start, end, freq=str(minutes) + "Min").tolist()) x = list(itertools.chain.from_iterable(x)) y = [self.rawData.value.max() for _ in x] return Bar(x=x, y=y, name="Anomaly Window", marker=Marker(color="rgb(220, 100, 100)"), opacity=0.3)
def plot_cluster(days, param="End", peak="AM", marker_size_scale=30): config_plotly() color_scale = colorlover.scales['5']['qual']['Set1'] data = list() top_size = days['7'].max() for cluster in days.cluster_id.unique(): data.append( Scattermapbox( lat=days[days.cluster_id == cluster][param + "_Lat_mean" + peak], lon=days[days.cluster_id == cluster][param + "_Lon_mean" + peak], mode='markers', marker=Marker(size=days[days.cluster_id == cluster]['7'] / top_size * marker_size_scale, color=color_scale[cluster]), text="CL: " + str(cluster), hoverinfo='text')) data = Data(data) layout = Layout( title='Clusters centres of gravity:' + param + peak, autosize=True, hovermode='closest', showlegend=False, mapbox=dict(accesstoken=PLOTLY_API_KEY, bearing=0, center=dict(lat=40, lon=-73), pitch=0, zoom=7, style='light'), ) fig = dict(data=data, layout=layout) py.plot(fig, filename='Clusters:' + param + peak)
nticks=5, showgrid=False, zeroline=False, tickfont=Font(size=12.0), anchor='x1', side='left', mirror='ticks'))) COMPLICATED_LINE = Figure(data=Data([ Scatter(x=[0.0, 1.0, 2.0, 3.0, 4.0, 5.0], y=[10.0, 20.0, 50.0, 80.0, 100.0, 200.0], name='one', mode='markers', marker=Marker(symbol='dot', line=Line(color='#000000', width=0.5), size=10, color='#FF0000', opacity=0.5), xaxis='x1', yaxis='y1'), Scatter(x=[0.0, 1.0, 2.0, 3.0, 4.0, 5.0], y=[10.0, 20.0, 50.0, 80.0, 100.0, 200.0], name='two', mode='lines', line=Line(dash='solid', color='rgba (0, 0, 255, 0.7)', width=2), xaxis='x1', yaxis='y1'), Scatter(x=[0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0], y=[1.0, 4.0, 8.0, 16.0, 32.0, 64.0, 128.0], name='three', mode='markers',