本文整理匯總了Python中plotly.graph_objs.Data方法的典型用法代碼示例。如果您正苦於以下問題:Python graph_objs.Data方法的具體用法?Python graph_objs.Data怎麽用?Python graph_objs.Data使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類plotly.graph_objs
的用法示例。
在下文中一共展示了graph_objs.Data方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: render
# 需要導入模塊: from plotly import graph_objs [as 別名]
# 或者: from plotly.graph_objs import Data [as 別名]
def render(self):
""" Plot the figure. Call this last."""
traces = list(self.getScatterGOs())
data = Data(traces)
plotly.offline.iplot({
'data': data,
'layout': self.makeLayout()
})
示例2: plotMultipleDetectors
# 需要導入模塊: from plotly import graph_objs [as 別名]
# 或者: from plotly.graph_objs import Data [as 別名]
def plotMultipleDetectors(plot,
resultsPaths,
detectors,
scoreProfile):
traces = []
traces.append(plot._addValues(plot.rawData))
# Anomaly detections traces:
for i, d in enumerate(detectors):
threshold = plot.thresholds[d][scoreProfile]["threshold"]
resultsData = getCSVData(os.path.join(plot.resultsDir, resultsPaths[i]))
FP, TP = plot._parseDetections(resultsData, threshold)
fpTrace, tpTrace = plot._addDetections("Detection by " + d,
MARKERS[i], FP, TP)
traces.append(fpTrace)
traces.append(tpTrace)
traces.append(plot._addWindows())
traces.append(plot._addProbation())
# Create plotly Data and Layout objects:
data = Data(traces)
layout = plot._createLayout("Anomaly Detections for " + plot.dataName)
# Query plotly
fig = Figure(data=data, layout=layout)
plot_url = plot.py.plot(fig)
return plot_url
# Create the list of result filenames for each detector
示例3: setup_metric_streams
# 需要導入模塊: from plotly import graph_objs [as 別名]
# 或者: from plotly.graph_objs import Data [as 別名]
def setup_metric_streams(self, local_stream_ids, metric_name, num_channels):
for i in range(num_channels):
stream_id = local_stream_ids[i]
self.stream_ids.append(stream_id)
py_stream = py.Stream(stream_id)
py_stream.open()
self.py_streams.append(py_stream)
go_stream = go.Stream(token=stream_id, maxpoints=self.max_points)
self.go_streams.append(go_stream)
traces = []
for i in range(num_channels):
channel_name = "channel_%s" % i
go_stream = self.go_streams[i]
trace = go.Scatter(
x=[],
y=[],
mode='splines',
stream=go_stream,
name=channel_name
)
traces.append(trace)
data = go.Data(traces)
layout = go.Layout(title=metric_name)
fig = go.Figure(data=data, layout=layout)
py.iplot(fig, filename=metric_name)
示例4: _plot_plotly
# 需要導入模塊: from plotly import graph_objs [as 別名]
# 或者: from plotly.graph_objs import Data [as 別名]
def _plot_plotly(subset_sizes, data_list, mmr):
""" Plots learning curve using plotly backend.
Args:
subset_sizes: list of dataset sizes on which the evaluation was done
data_list: list of ROC AUC scores corresponding to subset_sizes
mmr: what MMR the data is taken from
"""
if mmr:
title = 'Learning curve plot for %d MMR' % mmr
else:
title = 'Learning curve plot'
trace0 = go.Scatter(
x=subset_sizes,
y=data_list[0],
name='Cross validation error'
)
trace1 = go.Scatter(
x=subset_sizes,
y=data_list[1],
name='Test error'
)
data = go.Data([trace0, trace1])
layout = go.Layout(
title=title,
xaxis=dict(
title='Dataset size (logspace)',
type='log',
autorange=True,
titlefont=dict(
family='Courier New, monospace',
size=15,
color='#7f7f7f'
)
),
yaxis=dict(
title='Error',
titlefont=dict(
family='Courier New, monospace',
size=15,
color='#7f7f7f'
)
)
)
fig = go.Figure(data=data, layout=layout)
py.iplot(fig, filename='learning_curve_%dMMR' % mmr)
示例5: _update_graph
# 需要導入模塊: from plotly import graph_objs [as 別名]
# 或者: from plotly.graph_objs import Data [as 別名]
def _update_graph(map_style, region):
dff = dataframe
radius_multiplier = {'inner': 1.5, 'outer': 3}
layout = go.Layout(
title=metadata['title'],
autosize=True,
hovermode='closest',
height=750,
font=dict(family=theme['font-family']),
margin=go.Margin(l=0, r=0, t=45, b=10),
mapbox=dict(
accesstoken=mapbox_access_token,
bearing=0,
center=dict(
lat=regions[region]['lat'],
lon=regions[region]['lon'],
),
pitch=0,
zoom=regions[region]['zoom'],
style=map_style,
),
)
data = go.Data([
# outer circles represent magnitude
go.Scattermapbox(
lat=dff['Latitude'],
lon=dff['Longitude'],
mode='markers',
marker=go.Marker(
size=dff['Magnitude'] * radius_multiplier['outer'],
colorscale=colorscale_magnitude,
color=dff['Magnitude'],
opacity=1,
),
text=dff['Text'],
# hoverinfo='text',
showlegend=False,
),
# inner circles represent depth
go.Scattermapbox(
lat=dff['Latitude'],
lon=dff['Longitude'],
mode='markers',
marker=go.Marker(
size=dff['Magnitude'] * radius_multiplier['inner'],
colorscale=colorscale_depth,
color=dff['Depth'],
opacity=1,
),
# hovering behavior is already handled by outer circles
hoverinfo='skip',
showlegend=False
),
])
figure = go.Figure(data=data, layout=layout)
return figure
示例6: plot
# 需要導入模塊: from plotly import graph_objs [as 別名]
# 或者: from plotly.graph_objs import Data [as 別名]
def plot(self, figure_or_data, validate=True):
"""Plot figure_or_data in the Plotly graph widget.
Args:
figure_or_data (dict, list, or plotly.graph_obj object):
The standard Plotly graph object that describes Plotly
graphs as used in `plotly.plotly.plot`. See examples
of the figure_or_data in https://plot.ly/python/
Returns: None
Example 1 - Graph a scatter plot:
```
from plotly.graph_objs import Scatter
g = GraphWidget()
g.plot([Scatter(x=[1, 2, 3], y=[10, 15, 13])])
```
Example 2 - Graph a scatter plot with a title:
```
from plotly.graph_objs import Scatter, Figure, Data
fig = Figure(
data = Data([
Scatter(x=[1, 2, 3], y=[20, 15, 13])
]),
layout = Layout(title='Experimental Data')
)
g = GraphWidget()
g.plot(fig)
```
Example 3 - Clear a graph widget
```
from plotly.graph_objs import Scatter, Figure
g = GraphWidget()
g.plot([Scatter(x=[1, 2, 3], y=[10, 15, 13])])
# Now clear it
g.plot({}) # alternatively, g.plot(Figure())
```
"""
if figure_or_data == {} or figure_or_data == Figure():
validate = False
figure = tools.return_figure_from_figure_or_data(figure_or_data,
validate)
message = {
'task': 'newPlot',
'data': figure.get('data', []),
'layout': figure.get('layout', {}),
'graphId': self._graphId
}
self._handle_outgoing_message(message)