Python 如何搜索plotly地物的特定特性的选项?
问题 在下图中,线的锯齿形状是使用Python 如何搜索plotly地物的特定特性的选项?,python,plotly,Python,Plotly,问题 在下图中,线的锯齿形状是使用'hvh'作为线的形状属性的参数设置的。作为更一般情况的一个具体示例,假设我已经忘记了哪个porperty(或properties)将'hvh'作为参数。如何搜索整个plotly图形以找到它 绘图: #imports import plotly.plotly as py import plotly.graph_objs as go from plotly.offline import download_plotlyjs, init_notebook_mode,
'hvh'
作为线的形状
属性的参数设置的。作为更一般情况的一个具体示例,假设我已经忘记了哪个porperty(或properties)将'hvh'
作为参数。如何搜索整个plotly图形以找到它
绘图:
#imports
import plotly.plotly as py
import plotly.graph_objs as go
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
import numpy as np
import pandas as pd
# Notebook settings
init_notebook_mode(connected=True)
# Some sample data
x = np.random.normal(50, 5, 500)
binned = np.histogram(x, bins=25, density=True)
plot_y = np.cumsum(binned[0])
# Line
trace1 = go.Scatter(
x=binned[1],
y=plot_y,
mode='lines',
name="X",
hoverinfo='all',
line=dict(color = 'rgb(1255, 0, 0)', shape='hvh'
)
)
data = [trace1]
# Layout
layout = dict(title = 'Where is hvh?',
legend=dict(
y=0.5,
traceorder='reversed',
font=dict(
size=16
)
)
)
# Make figure
fig = dict(data=data, layout=layout)
# Plot
iplot(fig, filename='line-shapes')
代码:
#imports
import plotly.plotly as py
import plotly.graph_objs as go
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
import numpy as np
import pandas as pd
# Notebook settings
init_notebook_mode(connected=True)
# Some sample data
x = np.random.normal(50, 5, 500)
binned = np.histogram(x, bins=25, density=True)
plot_y = np.cumsum(binned[0])
# Line
trace1 = go.Scatter(
x=binned[1],
y=plot_y,
mode='lines',
name="X",
hoverinfo='all',
line=dict(color = 'rgb(1255, 0, 0)', shape='hvh'
)
)
data = [trace1]
# Layout
layout = dict(title = 'Where is hvh?',
legend=dict(
y=0.5,
traceorder='reversed',
font=dict(
size=16
)
)
)
# Make figure
fig = dict(data=data, layout=layout)
# Plot
iplot(fig, filename='line-shapes')
详细信息:
#imports
import plotly.plotly as py
import plotly.graph_objs as go
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
import numpy as np
import pandas as pd
# Notebook settings
init_notebook_mode(connected=True)
# Some sample data
x = np.random.normal(50, 5, 500)
binned = np.histogram(x, bins=25, density=True)
plot_y = np.cumsum(binned[0])
# Line
trace1 = go.Scatter(
x=binned[1],
y=plot_y,
mode='lines',
name="X",
hoverinfo='all',
line=dict(color = 'rgb(1255, 0, 0)', shape='hvh'
)
)
data = [trace1]
# Layout
layout = dict(title = 'Where is hvh?',
legend=dict(
y=0.5,
traceorder='reversed',
font=dict(
size=16
)
)
)
# Make figure
fig = dict(data=data, layout=layout)
# Plot
iplot(fig, filename='line-shapes')
使用line=dict(color='rgb(1255,0,0)”,shape='hvh'
获得形状。如果您只需运行fig
,它将返回一个dict,您可以看到参数应用于图形的位置:
{'data': [Scatter({
'hoverinfo': 'all',
'line': {'color': 'rgb(1255, 0, 0)', 'shape': 'hvh'},
'mode': 'lines',
'name': 'X',
'x': array([35.36954648,
[...]
假设我想知道一个iplot图形的哪些其他属性可以将'hvh'
或任何其他字符串作为参数,我如何搜索它?我碰巧知道'hvh'
显示在帮助(trace1['line'])
的输出中
但是,如果对多个形状执行'hvh'
,则很难从help()
的输出中查找每个可能的属性。如果我正在查找'shape'
本身,我可以在其上运行搜索并获得:
但对于'hvh'
或hvh
,情况并非如此:
感谢您的建议!如果搜索框没有提供您所需的内容,您可以随时使用浏览器中的ctl-F在页面中进行搜索 这就是说,我刚刚更新了我们的搜索索引,以包括枚举属性中可接受值的列表,因此从2分钟前开始,搜索“hvh”将给出: