我们从Python开源项目中,提取了以下7个代码示例,用于说明如何使用plotly.graph_objs.XAxis()。
def scatter_line_chart(df, y_title): """Generate a reproducible plotly scatter and line plot.""" if len(df.columns) == 3: x_axis, y_axis, factor = df.columns data = go.Data([ go.Scatter(x=sub[x_axis], y=sub[y_axis], name=key) for key, sub in df.groupby(factor, as_index=False, sort=False)]) else: x_axis, y_axis = df.columns data = go.Data([ go.Scatter(x=df[x_axis], y=df[y_axis])]) layout = go.Layout( width=650, height=500, xaxis=go.XAxis( title="Commit Hash" if x_axis == "commit_hash" else "Timestamp", tickangle=-45 if x_axis == "commit_hash" else 0 ), yaxis=go.YAxis( title=y_title ) ) return Markup(py.plot(go.Figure(data=data, layout=layout), **_DEFAULT_ARGS))
def setup_layout(self) : "Setup the axis properties." axis = dict( showbackground=True, backgroundcolor='rgb(230, 230, 230)', gridcolor='rgb(255, 255, 255)', zerolinecolor='rgb(255, 255, 255)' ) xaxis = axis.copy() xaxis['range'] = [-1.1,1.1] yaxis = axis.copy() yaxis['range'] = [-1.1,1.1] zaxis = axis.copy() zaxis['range'] = [-1.1,1.1] aspectratio=dict(x=1, y=1, z=1) self.layout = go.Layout( title='Kendall Triangles', width='100%', height= 800, scene=go.Scene( xaxis=go.XAxis(xaxis), yaxis=go.YAxis(yaxis), zaxis=go.ZAxis(zaxis), aspectratio=dict( x=aspectratio['x'], y=aspectratio['y'], z=aspectratio['z']), ) )
def kamervragen_reply_time_per_party(parties, kamervraag_durations): fig = ff.create_distplot( kamervraag_durations, parties, # colors=colors, bin_size=1, show_curve=True, show_hist=False, show_rug=False ) xaxis = XAxis( range=[0, 60], ) fig['layout'].update(xaxis=xaxis) # fig['layout'].update(title="Kamervraag Antwoordtijd per Partij (probability distributie)") fig['layout'].update(xaxis=dict(title='Antwoordtijd [dagen]')) # fig['layout'].update(yaxis=dict(title='Kamervraag Ingediend [tijd]')) fig['layout'].update(height=700) legend = dict( # x=0.01, # y=1, bordercolor='#E2E2E2', bgcolor='#FFFFFF', borderwidth=2 ) fig['layout'].update(legend=legend) fig['layout'].update(margin=Margin(t=20)) return Plot.create_plot_html_default(figure_or_data=fig)
def kamervragen_reply_time_per_ministry(ministries, kamervraag_durations): fig = ff.create_distplot( kamervraag_durations, ministries, # colors=colors, bin_size=1, show_curve=True, show_hist=False, show_rug=False ) xaxis = XAxis(range=[0, 70]) fig['layout'].update(xaxis=xaxis) # fig['layout'].update(title="Kamervraag Antwoordtijd per Ministerie tijdens Rutte-II (KDE probability distributie)") fig['layout'].update(xaxis=dict(title='Antwoordtijd [dagen]')) # fig['layout'].update(yaxis=dict(title='')) fig['layout'].update(height=700) fig['layout'].update(margin=Margin(t=20)) legend = dict( # x=0.01, # y=1, bordercolor='#E2E2E2', bgcolor='#FFFFFF', borderwidth=2 ) fig['layout'].update(legend=legend) return Plot.create_plot_html_default(figure_or_data=fig)
def kamervragen_reply_time_per_year(years, kamervraag_durations): fig = ff.create_distplot( kamervraag_durations, years, # colors=colors, bin_size=1, show_curve=True, show_hist=False, show_rug=False ) xaxis = XAxis(range=[0, 60]) fig['layout'].update(xaxis=xaxis) # fig['layout'].update(title="Kamervraag Antwoordtijd per Ministerie tijdens Rutte-II (KDE probability distributie)") fig['layout'].update(xaxis=dict(title='Antwoordtijd [dagen]')) # fig['layout'].update(yaxis=dict(title='')) fig['layout'].update(height=700) fig['layout'].update(margin=Margin(t=20)) legend = dict( # x=0.01, # y=1, bordercolor='#E2E2E2', bgcolor='#FFFFFF', borderwidth=2 ) fig['layout'].update(legend=legend) return Plot.create_plot_html_default(figure_or_data=fig)
def boolean_chart(df, y_title): """Generate a reproducible plotly scatter and line plot.""" if len(df.columns) == 3: x_axis, y_axis, factor = df.columns data = go.Data([ go.Scatter(x=sub[x_axis], y=sub[y_axis].astype(int), name=key) for key, sub in df.groupby(factor, as_index=False, sort=False)]) else: x_axis, y_axis = df.columns data = go.Data([ go.Scatter(x=df[x_axis], y=df[y_axis].astype(int))]) layout = go.Layout( width=650, height=500, xaxis=go.XAxis( title="Commit Hash" if x_axis == "commit_hash" else "Timestamp", tickangle=-45 if x_axis == "commit_hash" else 0 ), yaxis=go.YAxis( title=y_title, zeroline=False, tickmode="array", tickvals=[0, 1], ticktext=["No", "Yes"] ) ) return Markup(py.plot(go.Figure(data=data, layout=layout), **_DEFAULT_ARGS))
def show(self, title): figs = [] for ind_f in range(len(self.frames)) : (points, triangles, signals) = self.frames[ind_f] points = array(points) triangles = array(triangles) signals = array(signals) signals_per_triangle = list( (signals[triangles[i,0]] + signals[triangles[i,1]] + signals[triangles[i,2]]) / 3 for i in range(triangles.shape[0]) ) signals_per_triangle[0] += 0.001 # Validate colormap my_colormap = FF._validate_colors("Portland", 'tuple') newdata = FF._trisurf(x=points[:,2], y=points[:,0], z=points[:,1], colormap=my_colormap, simplices=triangles, color_func = signals_per_triangle, plot_edges=False, edges_color = 'rgb(50, 50, 50)', show_colorbar = False, data_list = True) figs += newdata axis = dict( showbackground=True, backgroundcolor='rgb(230, 230, 230)', gridcolor='rgb(255, 255, 255)', zerolinecolor='rgb(255, 255, 255)' ) xaxis = axis.copy() xaxis['range'] = [-0.08,0.09] yaxis = axis.copy() yaxis['range'] = [-0.11,0.05] zaxis = axis.copy() zaxis['range'] = [0.02,0.18] aspectratio=dict(x=1, y=1, z=1) layout = graph_objs.Layout( title=title, width='100%', height= 800, scene=graph_objs.Scene( xaxis=graph_objs.XAxis(xaxis), yaxis=graph_objs.YAxis(yaxis), zaxis=graph_objs.ZAxis(zaxis), aspectratio=dict( x=aspectratio['x'], y=aspectratio['y'], z=aspectratio['z']), ) ) return my_iplot(graph_objs.Figure( data = figs, layout=layout))