本文整理汇总了Python中plotly.express.scatter方法的典型用法代码示例。如果您正苦于以下问题:Python express.scatter方法的具体用法?Python express.scatter怎么用?Python express.scatter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类plotly.express
的用法示例。
在下文中一共展示了express.scatter方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_graph
# 需要导入模块: from plotly import express [as 别名]
# 或者: from plotly.express import scatter [as 别名]
def update_graph(xaxis_column_name, yaxis_column_name,
xaxis_type, yaxis_type,
year_value):
dff = df[df['Year'] == year_value]
fig = px.scatter(x=dff[dff['Indicator Name'] == xaxis_column_name]['Value'],
y=dff[dff['Indicator Name'] == yaxis_column_name]['Value'],
hover_name=dff[dff['Indicator Name'] == yaxis_column_name]['Country Name'])
fig.update_layout(margin={'l': 40, 'b': 40, 't': 10, 'r': 0}, hovermode='closest')
fig.update_xaxes(title=xaxis_column_name,
type='linear' if xaxis_type == 'Linear' else 'log')
fig.update_yaxes(title=yaxis_column_name,
type='linear' if yaxis_type == 'Linear' else 'log')
return fig
示例2: update_graph
# 需要导入模块: from plotly import express [as 别名]
# 或者: from plotly.express import scatter [as 别名]
def update_graph(xaxis_column_name, yaxis_column_name,
xaxis_type, yaxis_type,
year_value):
dff = df[df['Year'] == year_value]
fig = px.scatter(x=dff[dff['Indicator Name'] == xaxis_column_name]['Value'],
y=dff[dff['Indicator Name'] == yaxis_column_name]['Value'],
hover_name=dff[dff['Indicator Name'] == yaxis_column_name]['Country Name']
)
fig.update_traces(customdata=dff[dff['Indicator Name'] == yaxis_column_name]['Country Name'])
fig.update_xaxes(title=xaxis_column_name, type='linear' if xaxis_type == 'Linear' else 'log')
fig.update_yaxes(title=yaxis_column_name, type='linear' if yaxis_type == 'Linear' else 'log')
fig.update_layout(margin={'l': 40, 'b': 40, 't': 10, 'r': 0}, hovermode='closest')
return fig
示例3: create_time_series
# 需要导入模块: from plotly import express [as 别名]
# 或者: from plotly.express import scatter [as 别名]
def create_time_series(dff, axis_type, title):
fig = px.scatter(dff, x='Year', y='Value')
fig.update_traces(mode='lines+markers')
fig.update_xaxes(showgrid=False)
fig.update_yaxes(type='linear' if axis_type == 'Linear' else 'log')
fig.add_annotation(x=0, y=0.85, xanchor='left', yanchor='bottom',
xref='paper', yref='paper', showarrow=False, align='left',
bgcolor='rgba(255, 255, 255, 0.5)', text=title)
fig.update_layout(height=225, margin={'l': 20, 'b': 30, 'r': 10, 't': 10})
return fig
示例4: build_scatter_trendline
# 需要导入模块: from plotly import express [as 别名]
# 或者: from plotly.express import scatter [as 别名]
def build_scatter_trendline(x, y, trendline):
fig = px.scatter(x=x, y=y, trendline=trendline)
return fig.data[1]
示例5: update_figure
# 需要导入模块: from plotly import express [as 别名]
# 或者: from plotly.express import scatter [as 别名]
def update_figure(selected_year):
filtered_df = df[df.year == selected_year]
fig = px.scatter(filtered_df, x="gdpPercap", y="lifeExp",
size="pop", color="continent", hover_name="country",
log_x=True, size_max=55)
fig.update_layout(transition_duration=500)
return fig
示例6: update_store_data
# 需要导入模块: from plotly import express [as 别名]
# 或者: from plotly.express import scatter [as 别名]
def update_store_data(indicator, country):
dff = df[df['country'] == country]
return px.scatter(dff, x='year', y=str(indicator))
示例7: scatter
# 需要导入模块: from plotly import express [as 别名]
# 或者: from plotly.express import scatter [as 别名]
def scatter(self, x: str = None, y: str = None, color: str = None, **kwargs):
import plotly.express as px
if len(self.metric_names) < 2:
raise ValueError("You need at least 2 metrics to use this plot.")
df = self.get_wide_df()
return px.scatter(df, x=x, y=y, color=color, **kwargs)