本文整理汇总了Python中plotly.graph_objects.Scatter方法的典型用法代码示例。如果您正苦于以下问题:Python graph_objects.Scatter方法的具体用法?Python graph_objects.Scatter怎么用?Python graph_objects.Scatter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类plotly.graph_objects
的用法示例。
在下文中一共展示了graph_objects.Scatter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _draw_substation_circle
# 需要导入模块: from plotly import graph_objects [as 别名]
# 或者: from plotly.graph_objects import Scatter [as 别名]
def _draw_substation_circle(self, name, pos_x, pos_y):
marker_dict = dict(
size = self._sub_radius,
color=self._sub_fill_color,
showscale = False,
line=dict(
width=self._sub_line_width,
color=self._sub_line_color
)
)
return go.Scatter(x=[pos_x], y=[pos_y],
mode="markers",
text=[name],
name=self._sub_prefix + name,
marker=marker_dict,
showlegend=False)
示例2: _draw_load_circle
# 需要导入模块: from plotly import graph_objects [as 别名]
# 或者: from plotly.graph_objects import Scatter [as 别名]
def _draw_load_circle(self, pos_x, pos_y, name, text):
marker_dict = dict(
size = self._load_radius,
color=self._load_fill_color,
showscale = False,
line=dict(
width=self._load_line_width,
color=self._load_line_color
)
)
return go.Scatter(x=[pos_x], y=[pos_y],
mode="markers",
text=[text],
name=self._load_prefix + name,
marker=marker_dict,
showlegend=False)
示例3: _draw_gen_circle
# 需要导入模块: from plotly import graph_objects [as 别名]
# 或者: from plotly.graph_objects import Scatter [as 别名]
def _draw_gen_circle(self, pos_x, pos_y, name, text):
marker_dict = dict(
size = self._gen_radius,
color=self._gen_fill_color,
showscale = False,
line=dict(
width=self._gen_line_width,
color=self._gen_line_color
)
)
return go.Scatter(x=[pos_x], y=[pos_y],
mode="markers",
text=[text],
name=self._gen_prefix + name,
marker=marker_dict,
showlegend=False)
示例4: _draw_powerline_txt
# 需要导入模块: from plotly import graph_objects [as 别名]
# 或者: from plotly.graph_objects import Scatter [as 别名]
def _draw_powerline_txt(self, name,
pos_or_x, pos_or_y,
pos_ex_x, pos_ex_y,
text):
mid_x = (pos_or_x + pos_ex_x) / 2
mid_y = (pos_or_y + pos_ex_y) / 2
dir_x = pos_ex_x - pos_or_x
dir_y = pos_ex_y - pos_or_y
orth_x = -dir_y
orth_y = dir_x
orth_norm = np.linalg.norm([orth_x, orth_y])
txt_x = mid_x + (orth_x / orth_norm) * 2
txt_y = mid_y + (orth_y / orth_norm) * 2
text_pos = self._textpos_from_dir(orth_x, orth_y)
txt_trace = go.Scatter(x=[txt_x], y=[txt_y],
text=[text],
name=name,
mode="text",
textposition=text_pos,
showlegend=False)
return txt_trace
示例5: _draw_loads_one_load
# 需要导入模块: from plotly import graph_objects [as 别名]
# 或者: from plotly.graph_objects import Scatter [as 别名]
def _draw_loads_one_load(self, fig, l_id, pos_load, txt_, pos_end_line, pos_load_sub, how_center, this_col):
# add the MW load
trace = go.Scatter(x=[pos_load.real],
y=[pos_load.imag],
text=[txt_],
mode="text",
showlegend=False,
textfont=dict(
color=this_col
))
# add the line between the MW display and the substation
# TODO later one, add something that looks like a load, a house for example
res = go.layout.Shape(
type="line",
xref="x",
yref="y",
x0=pos_end_line.real,
y0=pos_end_line.imag,
x1=pos_load_sub[0],
y1=pos_load_sub[1],
layer="below",
line=dict(color=this_col
)
)
return res, trace
示例6: plot
# 需要导入模块: from plotly import graph_objects [as 别名]
# 或者: from plotly.graph_objects import Scatter [as 别名]
def plot(self, trace_kwargs={}, fig=None, **layout_kwargs):
"""Plot each column in DataFrame as a line.
Args:
trace_kwargs (dict or list of dict): Keyword arguments passed to each `plotly.graph_objects.Scatter`.
fig (plotly.graph_objects.Figure): Figure to add traces to.
**layout_kwargs: Keyword arguments for layout.
Example:
```py
df[['a', 'b']].vbt.tseries.plot()
```
![](/vectorbt/docs/img/tseries_df_plot.png)"""
for col in range(self._obj.shape[1]):
fig = self._obj.iloc[:, col].vbt.tseries.plot(
trace_kwargs=trace_kwargs,
fig=fig,
**layout_kwargs
)
return fig
示例7: plot
# 需要导入模块: from plotly import graph_objects [as 别名]
# 或者: from plotly.graph_objects import Scatter [as 别名]
def plot(self, trace_kwargs={}, fig=None, **layout_kwargs):
"""Plot each column in DataFrame as a line.
Args:
trace_kwargs (dict or list of dict): Keyword arguments passed to each `plotly.graph_objects.Scatter`.
fig (plotly.graph_objects.Figure): Figure to add traces to.
**layout_kwargs: Keyword arguments for layout.
Example:
```py
signals[['a', 'c']].vbt.signals.plot().show_png()
```
![](/vectorbt/docs/img/signals_signals_plot.png)"""
for col in range(self._obj.shape[1]):
fig = self._obj.iloc[:, col].vbt.signals.plot(
trace_kwargs=trace_kwargs,
fig=fig,
**layout_kwargs
)
return fig
示例8: make_chart
# 需要导入模块: from plotly import graph_objects [as 别名]
# 或者: from plotly.graph_objects import Scatter [as 别名]
def make_chart(title):
import json
import plotly.graph_objects as go
import plotly
layout = go.Layout(title=title)
data = go.Scatter(
x=[1, 2, 3, 4],
y=[10, 11, 12, 13],
mode="markers",
marker=dict(size=[40, 60, 80, 100], color=[0, 1, 2, 3]),
)
fig = go.Figure(data=data)
fig = json.dumps(fig, cls=plotly.utils.PlotlyJSONEncoder)
layout = json.dumps(layout, cls=plotly.utils.PlotlyJSONEncoder)
return fig, layout
示例9: _create_figure
# 需要导入模块: from plotly import graph_objects [as 别名]
# 或者: from plotly.graph_objects import Scatter [as 别名]
def _create_figure(self, performance_keys):
fig = make_subplots(
rows=4, cols=1, shared_xaxes=True, vertical_spacing=0.03,
row_heights=[0.55, 0.15, 0.15, 0.15],
)
fig.add_trace(go.Candlestick(name='Price', xaxis='x1', yaxis='y1',
showlegend=False), row=1, col=1)
fig.update_layout(xaxis_rangeslider_visible=False)
fig.add_trace(go.Bar(name='Volume', showlegend=False,
marker={'color': 'DodgerBlue'}),
row=2, col=1)
for k in performance_keys:
fig.add_trace(go.Scatter(mode='lines', name=k), row=3, col=1)
fig.add_trace(go.Scatter(mode='lines', name='Net Worth', marker={ 'color': 'DarkGreen' }),
row=4, col=1)
fig.update_xaxes(linecolor='Grey', gridcolor='Gainsboro')
fig.update_yaxes(linecolor='Grey', gridcolor='Gainsboro')
fig.update_xaxes(title_text='Price', row=1)
fig.update_xaxes(title_text='Volume', row=2)
fig.update_xaxes(title_text='Performance', row=3)
fig.update_xaxes(title_text='Net Worth', row=4)
fig.update_xaxes(title_standoff=7, title_font=dict(size=12))
self.fig = go.FigureWidget(fig)
self._price_chart = self.fig.data[0]
self._volume_chart = self.fig.data[1]
self._performance_chart = self.fig.data[2]
self._net_worth_chart = self.fig.data[-1]
self.fig.update_annotations({'font': {'size': 12}})
self.fig.update_layout(template='plotly_white', height=self._height, margin=dict(t=50))
self._base_annotations = self.fig.layout.annotations
示例10: _draw_substation_txt
# 需要导入模块: from plotly import graph_objects [as 别名]
# 或者: from plotly.graph_objects import Scatter [as 别名]
def _draw_substation_txt(self, name, pos_x, pos_y, text):
return go.Scatter(x=[pos_x], y=[pos_y],
text=[text], mode="text",
name=name,
textposition="middle center",
hoverinfo='skip',
showlegend=False)
示例11: _draw_load_txt
# 需要导入模块: from plotly import graph_objects [as 别名]
# 或者: from plotly.graph_objects import Scatter [as 别名]
def _draw_load_txt(self, name, pos_x, pos_y, text, textpos):
return go.Scatter(x=[pos_x], y=[pos_y],
text=[text], mode="text",
name=name,
hoverinfo='skip',
textposition=textpos,
showlegend=False)
示例12: _draw_load_line
# 需要导入模块: from plotly import graph_objects [as 别名]
# 或者: from plotly.graph_objects import Scatter [as 别名]
def _draw_load_line(self, pos_x, pos_y, sub_x, sub_y):
style_line=dict(
color="black",
width=self._load_line_width)
line_trace = go.Scatter(x=[pos_x, sub_x],
y=[pos_y, sub_y],
hoverinfo='skip',
line=style_line,
showlegend=False)
return line_trace
示例13: _draw_gen_txt
# 需要导入模块: from plotly import graph_objects [as 别名]
# 或者: from plotly.graph_objects import Scatter [as 别名]
def _draw_gen_txt(self, name, pos_x, pos_y, text, text_pos):
return go.Scatter(x=[pos_x], y=[pos_y],
text=[text], name=name,
mode="text",
hoverinfo='skip',
textposition=text_pos,
showlegend=False)
示例14: _draw_gen_line
# 需要导入模块: from plotly import graph_objects [as 别名]
# 或者: from plotly.graph_objects import Scatter [as 别名]
def _draw_gen_line(self, pos_x, pos_y, sub_x, sub_y):
style_line=dict(
color="black",
width=self._gen_line_width
)
line_trace = go.Scatter(x=[pos_x, sub_x],
y=[pos_y, sub_y],
hoverinfo='skip',
line=style_line,
showlegend=False)
return line_trace
示例15: _draw_gen_bus
# 需要导入模块: from plotly import graph_objects [as 别名]
# 或者: from plotly.graph_objects import Scatter [as 别名]
def _draw_gen_bus(self, pos_x, pos_y, dir_x, dir_y, bus, gen_name):
bus = bus if bus > 0 else 0
marker_dict = dict(
size = self._line_bus_radius,
color = self._line_bus_colors[bus],
showscale = False
)
center_x = pos_x + dir_x * (self._sub_radius - self._line_bus_radius)
center_y = pos_y + dir_y * (self._sub_radius - self._line_bus_radius)
trace_name = self._gen_prefix + self._bus_prefix + gen_name
return go.Scatter(x=[center_x], y=[center_y],
marker=marker_dict,
name=trace_name,
hoverinfo='skip',
showlegend=False)