Python plotly.graph_objs.Pie() Examples
The following are 13
code examples of plotly.graph_objs.Pie().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
plotly.graph_objs
, or try the search function
.
Example #1
Source File: visuals.py From python-esppy with Apache License 2.0 | 5 votes |
def createContent(self): value = self.getValues("value") self._data = [] if len(value) == 1: self._data.append(go.Pie(labels=[""],values=[0],name=value[0]))
Example #2
Source File: advanced_demo.py From dash-ui with MIT License | 5 votes |
def create_total_exports_pie(state): trace = go.Pie( labels=df['state'], values=df['total exports'], textinfo='none', marker=dict( colors=['red' if x == state else 'grey' for x in df['state']] )) return go.Figure(data=[trace], layout={ 'showlegend': False, 'title': "{:s}'s proportion of total US agriculture exports".format(state) })
Example #3
Source File: advanced_demo.py From dash-ui with MIT License | 5 votes |
def create_produce_pie(state): produce_vars = ["total fruits", "total veggies", "corn", "wheat"] row = df[df["state"] == state].iloc[0] trace = go.Pie( labels=produce_vars, textinfo="label+percent", values=[row[v] for v in produce_vars]) return go.Figure(data=[trace], layout={ 'showlegend': False, 'title': "{:s}'s produce distribution".format(state) })
Example #4
Source File: advanced_demo.py From dash-ui with MIT License | 5 votes |
def create_animal_pie(state): animal_vars = ["beef", "pork", "poultry", "dairy"] row = df[df["state"] == state].iloc[0] trace = go.Pie( labels=animal_vars, textinfo="label+percent", values=[row[v] for v in animal_vars]) return go.Figure(data=[trace], layout={ 'showlegend': False, 'title': "{:s}'s animal product distribution".format(state), })
Example #5
Source File: advanced_demo.py From dash-ui with MIT License | 5 votes |
def create_all_pie(state): vs = list(set(df.columns) - {"Unnamed: 0", "total exports", "state"}) row = df[df["state"] == state].iloc[0] trace = go.Pie( labels=vs, textinfo="label+percent", values=[row[v] for v in vs]) return go.Figure(data=[trace], layout={ 'showlegend': False, 'title': "{:s}'s agriculture distribution".format(state) })
Example #6
Source File: dash_mess.py From socialsentiment with MIT License | 5 votes |
def update_pie_chart(sentiment_term): # get data from cache for i in range(100): sentiment_pie_dict = cache.get('sentiment_shares', sentiment_term) if sentiment_pie_dict: break time.sleep(0.1) if not sentiment_pie_dict: return None labels = ['Positive','Negative'] try: pos = sentiment_pie_dict[1] except: pos = 0 try: neg = sentiment_pie_dict[-1] except: neg = 0 values = [pos,neg] colors = ['#007F25', '#800000'] trace = go.Pie(labels=labels, values=values, hoverinfo='label+percent', textinfo='value', textfont=dict(size=20, color=app_colors['text']), marker=dict(colors=colors, line=dict(color=app_colors['background'], width=2))) return {"data":[trace],'layout' : go.Layout( title='Positive vs Negative sentiment for "{}" (longer-term)'.format(sentiment_term), font={'color':app_colors['text']}, plot_bgcolor = app_colors['background'], paper_bgcolor = app_colors['background'], showlegend=True)}
Example #7
Source File: pycoQC_plot.py From pycoQC with GNU General Public License v3.0 | 5 votes |
def alignment_reads_status (self, colors:list=["#f44f39","#fc8161","#fcaf94","#828282"], width:int= None, height:int=500, plot_title:str="Summary of reads alignment status"): """ Plot a basic alignment summary * colors List of colors (hex, rgb, rgba, hsl, hsv or any CSS named colors https://www.w3.org/TR/css-color-3/#svg-color * width With of the plotting area in pixel * height height of the plotting area in pixel * plot_title Title to display on top of the plot """ # Verify that alignemnt information are available if not self.has_alignment: raise pycoQCError ("No Alignment information available") self.logger.info ("\t\tComputing plot") df = self.alignments_df # Create empty multiplot figure fig = make_subplots(rows=1, cols=2, column_widths=[0.4, 0.6], specs=[[{"type": "table"},{"type": "pie"}]]) # plot Table data = go.Table( columnwidth = [3,2,2], header = {"values":list(df.columns), "align":"center", "fill_color":"grey", "font_size":14, "font_color":"white", "height":40}, cells = {"values":df.values.T , "align":"center", "fill_color":"whitesmoke", "font_size":12, "height":30}) fig.add_trace (data, row=1, col=1) # plot Pie plot data = go.Pie ( labels=df["Alignments"], values=df["Counts"], sort=False, marker={"colors":colors}, name="Pie plot", textinfo='label+percent') fig.add_trace (data, row=1, col=2) # Change the layout fig.update_layout( width = width, height = height, title = {"text":plot_title, "xref":"paper" ,"x":0.5, "xanchor":"center"}) return fig #~~~~~~~ALIGNMENT RATE METHOD AND HELPER~~~~~~~#
Example #8
Source File: pie.py From DataPlotly with GNU General Public License v2.0 | 5 votes |
def name(): return PlotType.tr('Pie Chart')
Example #9
Source File: pie.py From DataPlotly with GNU General Public License v2.0 | 5 votes |
def create_trace(settings): return [graph_objs.Pie( labels=settings.x, values=settings.y, marker=dict( colors=settings.data_defined_colors if settings.data_defined_colors else [settings.properties['in_color']] ), name=settings.properties['custom'][0], )]
Example #10
Source File: visuals.py From python-esppy with Apache License 2.0 | 4 votes |
def create(self): size = self._gauge.getOpt("size",300) self._layout = go.Layout(width=size,height=size) self._data = [] self._tics = go.Pie(values=self._gauge._ticValues,labels=self._gauge._ticLabels, marker=dict(colors=["rgba(0,0,0,0)"] * (self._gauge._segments + 10),line_width = 0), direction="clockwise", rotation=int((((self._gauge._shape + 10) / 100) * 360) / 2), hole=self._gauge.getOpt("center_size",.40), sort=False, showlegend=False, hoverinfo="none", textposition="outside", textinfo="label") self._data.append(self._tics) self._intervals = go.Pie(values=self._gauge._intervalValues, labels=self._gauge._intervalLabels, text=self._gauge._segmentLabels, marker=dict(line_width=self._gauge.getOpt("line_width",4)), marker_colors=self._gauge._intervalColors, hole=self._gauge.getOpt("center_size",.40), sort=False, direction="clockwise", rotation=int(((self._gauge._shape / 100) * 360) / 2), showlegend=False, hoverinfo="none", textposition="inside", textinfo="text") self._data.append(self._intervals) margin = self._gauge.getOpt("margin",30) self._layout["margin"] = dict(l=margin,r=margin,b=margin,t=margin) #self._layout["paper_bgcolor"] = "#e8e8e8" #self._layout["plot_bgcolor"] = "blue" #self._layout["paper_bgcolor"] = "rgba(0,0,0,0)" self._layout["plot_bgcolor"] = "rgba(0,0,0,0)" self._figure = go.FigureWidget(data=self._data,layout=self._layout) height = size height += 30 #self.children = [self._title,self._figure],layout=widgets.Layout(border="1px solid #d8d8d8",width=str(size) + "px",height=str(height) + "px") self.children = [self._title,self._figure]
Example #11
Source File: pycoQC_plot.py From pycoQC with GNU General Public License v3.0 | 4 votes |
def barcode_counts (self, colors:list=["#f8bc9c", "#f6e9a1", "#f5f8f2", "#92d9f5", "#4f97ba"], width:int= None, height:int=500, plot_title:str="Percentage of reads per barcode"): """ Plot a mean quality over time * colors List of colors (hex, rgb, rgba, hsl, hsv or any CSS named colors https://www.w3.org/TR/css-color-3/#svg-color * width With of the plotting area in pixel * height height of the plotting area in pixel * plot_title Title to display on top of the plot """ # Verify that barcode information are available if not self.has_barcodes: raise pycoQCError ("No barcode information available") self.logger.info ("\t\tComputing plot") # Prepare all data lab1, dd1 = self.__barcode_counts_data (df_level="all") lab2, dd2 = self.__barcode_counts_data (df_level="pass") # Plot initial data data= [go.Pie (labels=dd1["labels"][0] , values=dd1["values"][0] , sort=False, marker=dict(colors=colors))] # Create update buttons updatemenus = [ dict (type="buttons", active=0, x=-0.2, y=0, xanchor='left', yanchor='bottom', buttons = [ dict (label=lab1, method='restyle', args=[dd1]), dict (label=lab2, method='restyle', args=[dd2])])] # tweak plot layout layout = go.Layout ( plot_bgcolor="whitesmoke", legend = {"x":-0.2, "y":1,"xanchor":'left',"yanchor":'top'}, updatemenus = updatemenus, width = width, height = height, title = {"text":plot_title, "xref":"paper" ,"x":0.5, "xanchor":"center"}) return go.Figure (data=data, layout=layout)
Example #12
Source File: figures.py From dash-svm with MIT License | 4 votes |
def serve_pie_confusion_matrix(model, X_test, y_test, Z, threshold): # Compute threshold scaled_threshold = threshold * (Z.max() - Z.min()) + Z.min() y_pred_test = (model.decision_function(X_test) > scaled_threshold).astype(int) matrix = metrics.confusion_matrix(y_true=y_test, y_pred=y_pred_test) tn, fp, fn, tp = matrix.ravel() values = [tp, fn, fp, tn] label_text = ["True Positive", "False Negative", "False Positive", "True Negative"] labels = ["TP", "FN", "FP", "TN"] blue = cl.flipper()['seq']['9']['Blues'] red = cl.flipper()['seq']['9']['Reds'] colors = [blue[4], blue[1], red[1], red[4]] trace0 = go.Pie( labels=label_text, values=values, hoverinfo='label+value+percent', textinfo='text+value', text=labels, sort=False, marker=dict( colors=colors ) ) layout = go.Layout( title=f'Confusion Matrix', margin=dict(l=10, r=10, t=60, b=10), legend=dict( bgcolor='rgba(255,255,255,0)', orientation='h' ) ) data = [trace0] figure = go.Figure(data=data, layout=layout) return figure
Example #13
Source File: BS440plot.py From BS440 with MIT License | 4 votes |
def gaugeDiv(baseLabels, meterLabels, colors, value, suffix): meterValues = [] meterValues.append(0) meterSum = 0 # Calculate steps. Then first value is the sum of all the others. for i in range(1, len(baseLabels)-1): meterValues.append(float(baseLabels[i+1]) - float(baseLabels[i])) meterSum += meterValues[i] meterValues[0] = meterSum # Dial path. Apply angle from full left position. rangeValue = float(meterValues[0]) minValue=float(baseLabels[1]) chartCenter=0.5 dialTip=chartCenter-0.12 dialAngle=(value-minValue)*180/rangeValue dialPath = 'M ' + rotatePoint((chartCenter,0.5),(chartCenter,0.485),dialAngle, 'dialPath') + ' L ' + rotatePoint((chartCenter,0.5),(dialTip,0.5),dialAngle, 'dialPath') + ' L ' + rotatePoint((chartCenter,0.5),(chartCenter,0.515),dialAngle, 'dialPath') + ' Z' infoText=(str(value) + str(suffix)) # Gauge meterChart = go.Pie( values=meterValues, labels=meterLabels, marker=dict(colors=colors, line=dict(width=0) # Switch line width to 0 in production ), name="Gauge", hole=.3, direction="clockwise", rotation=90, showlegend=False, textinfo="label", textposition="inside", hoverinfo="none", sort=False ) # Layout layout = go.Layout( xaxis=dict(showticklabels=False, autotick=False, showgrid=False, zeroline=False,), yaxis=dict(showticklabels=False, autotick=False, showgrid=False, zeroline=False,), shapes=[dict( type='path', path=dialPath, fillcolor='rgba(44, 160, 101, 1)', line=dict(width=0.5), xref='paper', yref='paper'), ], annotations=[ dict(xref='paper', yref='paper', x=(chartCenter-0.015), y=0.2, text=infoText, font=dict(size='20', color='#ffffff'), showarrow=False), ], height=260, width=300, margin=dict(l=0, r=0, t=20, b=0, autoexpand=False), plot_bgcolor="rgba(0,0,0,0)", paper_bgcolor="rgba(0,0,0,0)" ) # Write static values as annotations for value in baseLabels: if value is not '-': annotationDict=dict( xref='paper', yref='paper', xanchor='center', yanchor='middle', x=rotatePoint((chartCenter,0.5),((chartCenter-0.45),0.5), ((float(value)-minValue)*180/rangeValue), 'x'), y=rotatePoint((chartCenter,0.5),((chartCenter-0.45),0.5), ((float(value)-minValue)*180/rangeValue), 'y'), font=dict(size='12', color='#ffffff'), showarrow=False, text=value, ) layout['annotations'].append(annotationDict) # Build HTML div div = plotly.plot(dict(data=[meterChart], layout=layout), include_plotlyjs=False, show_link=False, output_type='div') return div