Python plotly.graph_objs.Box() Examples
The following are 6
code examples of plotly.graph_objs.Box().
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: box.py From DataPlotly with GNU General Public License v2.0 | 6 votes |
def create_trace(settings): # flip the variables according to the box orientation if settings.properties['box_orientation'] == 'h': y = settings.x x = settings.y else: x = settings.x y = settings.y return [graph_objs.Box( x=x or None, y=y, name=settings.data_defined_legend_title if settings.data_defined_legend_title != '' else settings.properties['name'], customdata=settings.properties['custom'], boxmean=settings.properties['box_stat'], orientation=settings.properties['box_orientation'], boxpoints=settings.properties['box_outliers'], fillcolor=settings.data_defined_colors[0] if settings.data_defined_colors else settings.properties['in_color'], line={'color': settings.data_defined_stroke_colors[0] if settings.data_defined_stroke_colors else settings.properties['out_color'], 'width': settings.data_defined_stroke_widths[0] if settings.data_defined_stroke_widths else settings.properties['marker_width']}, opacity=settings.properties['opacity'] )]
Example #2
Source File: g_grid_ramping_capacity.py From CityEnergyAnalyst with MIT License | 5 votes |
def calc_graph(self): # main data about technologies data = self.process_individual_ramping_capacity() hours = data.index.hour graph = [] for field in self.analysis_fields: y = data[field].values / 1E6 # into MW trace = go.Box(x=hours, y=y, name=NAMING[field], marker=dict(color=COLOR[field])) graph.append(trace) return graph
Example #3
Source File: box.py From DataPlotly with GNU General Public License v2.0 | 5 votes |
def name(): return PlotType.tr('Box Plot')
Example #4
Source File: generate_qc_plots.py From panaroo with MIT License | 4 votes |
def plot_ngenes(input_gffs, outdir): # get simplified file names file_names = [ os.path.splitext(os.path.basename(gff))[0] for gff in input_gffs ] # count genes ngenes = np.zeros(len(input_gffs)) for i, gff_file in enumerate(input_gffs): with open(gff_file, 'r') as gff: for line in gff: if "##FASTA" in line: break if "##" == line[:2]: continue if "CDS" not in line: continue ngenes[i] += 1 with open(outdir + "ngenes.txt", "w") as genes_out: genes_out.write("sample\tno_genes\n") for i, j in zip(file_names, ngenes): genes_out.write("%s\t%s\n" % (i, j)) # generate static plot plt.style.use('ggplot') fig = plt.figure() plt.barh(np.arange(len(ngenes)), ngenes) plt.yticks(np.arange(len(ngenes)), file_names) plt.grid(True) plt.ylabel("File Name") plt.xlabel("Number of Genes") plt.tight_layout() fig.savefig(outdir + "ngenes_barplot.png") # generate interactive boxplot data = [ go.Box(y=ngenes, text=file_names, hoverinfo="text", boxpoints='all', jitter=0.3, pointpos=-1.8) ] layout = go.Layout(autosize=True, xaxis=dict(title='', titlefont=dict(size=18, color='black'), showticklabels=False, automargin=True), yaxis=dict(title="Number of Genes", titlefont=dict(size=18, color='black'), showticklabels=True, tickfont=dict(size=10, color='black'))) fig = go.Figure(data=data, layout=layout) offline.plot(fig, filename=outdir + "ngenes_boxplot.html", auto_open=False) return
Example #5
Source File: generate_qc_plots.py From panaroo with MIT License | 4 votes |
def plot_ncontigs(input_gffs, outdir): # get simplified file names file_names = [ os.path.splitext(os.path.basename(gff))[0] for gff in input_gffs ] # count genes ncontigs = np.zeros(len(input_gffs)) for i, gff_file in enumerate(input_gffs): with open(gff_file, 'r') as gff: in_fasta = False for line in gff: if in_fasta and (line[0] == ">"): ncontigs[i] += 1 if "##FASTA" in line: in_fasta = True # generate static plot with open(outdir + "ncontigs.txt", "w") as contig_out: contig_out.write("sample\tno_contigs\n") for i, j in zip(file_names, ncontigs): contig_out.write("%s\t%s\n" % (i, j)) plt.style.use('ggplot') fig = plt.figure() plt.barh(np.arange(len(ncontigs)), ncontigs) plt.yticks(np.arange(len(ncontigs)), file_names) plt.grid(True) plt.ylabel("File Name") plt.xlabel("Number of Contigs") plt.tight_layout() fig.savefig(outdir + "ncontigs_barplot.png") # generate interactive boxplot data = [ go.Box(y=ncontigs, text=file_names, hoverinfo="text", boxpoints='all', jitter=0.3, pointpos=-1.8) ] layout = go.Layout(autosize=True, xaxis=dict(title='', titlefont=dict(size=18, color='black'), showticklabels=False, automargin=True), yaxis=dict(title="Number of Contigs", titlefont=dict(size=18, color='black'), showticklabels=True, tickfont=dict(size=10, color='black'))) fig = go.Figure(data=data, layout=layout) offline.plot(fig, filename=outdir + "ncontigs_boxplot.html", auto_open=False) return
Example #6
Source File: boxplot.py From whatstk with GNU General Public License v3.0 | 4 votes |
def fig_boxplot_msglen(df, username_to_color=None, title="", xlabel=None): """Visualize boxplot. Args: df (pandas.DataFrame): Chat data. username_to_color (dict, optional). Dictionary mapping username to color. Defaults to None. title (str, optional): Title for plot. Defaults to "". xlabel (str, optional): x-axis label title. Defaults to None. Returns: plotly.graph_objs.Figure """ df = df.copy() # Get message lengths df[COLNAMES_DF.MESSAGE_LENGTH] = df[COLNAMES_DF.MESSAGE].apply(lambda x: len(x)) # Sort users by median user_stats = df.groupby(COLNAMES_DF.USERNAME)\ .aggregate({COLNAMES_DF.MESSAGE_LENGTH: 'median'})[COLNAMES_DF.MESSAGE_LENGTH].sort_values(ascending=False) # Create a list of traces data = [] for username in user_stats.index: x = df[df[COLNAMES_DF.USERNAME] == username][COLNAMES_DF.MESSAGE_LENGTH] trace = go.Box( y=x.values, showlegend=True, name=username, boxpoints='outliers', marker_color=username_to_color[username] if username_to_color else None ) data.append(trace) layout = dict( title=title, xaxis=dict(title=xlabel) ) fig = go.Figure(data=data, layout=layout) return fig