python - 如何搜索绘图图形的特定属性的选项?
问题描述
问题
在下图中,线的锯齿形状被设置为线属性的'hvh'
参数。shape
作为更一般情况的具体示例,假设我忘记了将哪个属性(或属性)'hvh'
作为参数。如何搜索整个情节图以找到它?
阴谋:
代码:
#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
,它将返回一个字典,你可以在其中看到参数应用于图形的位置:
{'data': [Scatter({
'hoverinfo': 'all',
'line': {'color': 'rgb(1255, 0, 0)', 'shape': 'hvh'},
'mode': 'lines',
'name': 'X',
'x': array([35.36954648,
[...]
假设我想知道可以将 iplot 图形'hvh'
或任何其他字符串作为参数的其他属性,我该如何搜索?我碰巧知道这'hvh'
显示在输出中help(trace1['line'])
shape
| Determines the line shape. With "spline" the lines are drawn
| using spline interpolation. The other available values
| correspond to step-wise line shapes.
|
| The 'shape' property is an enumeration that may be specified as:
| - One of the following enumeration values:
| ['linear', 'spline', 'hv', 'vh', 'hvh', 'vhv']
但是,如果'hvh'
要针对多个形状发生,则很难查看help()
每个可能属性的输出。如果我正在寻找'shape'
自己,我可以在plot.ly/python/reference/上运行搜索并获得:
但这不是'hvh'
or的情况hvh
:
感谢您的任何建议!
解决方案
如果搜索框没有为您提供所需的内容,您始终可以使用浏览器内的 ctl-F 在页面中搜索https://plot.ly/python/reference/ 。
也就是说,我刚刚更新了我们的搜索索引以包含枚举属性中的接受值列表,因此截至 2 分钟前,搜索“hvh”给出:
推荐阅读
- r - 将哈希表/字典/数组格式数据转换为基于常规列的 data.frame
- node.js - 如何使用云功能对 Firestore 数据进行分页?
- javascript - 我的 switch 语句有什么问题?
- c# - C# 使用 Google Classroom API 读取学生列表并写入 SQL Server
- c# - 删除表后实体框架更新模型
- python - 如何重塑 numpy 数组?我无法将大小为 87880 的数组重塑为形状 (130,20,26,1) 错误
- c++ - 关于 c++ 对象构造和范围的问题
- pyspark - 不确定如何在 pyspark 数据帧上应用逐行规范化
- php - 我在尝试 *EXACTLY* 确定两个(可能非常遥远的)日期之间的十进制年数时做错了什么?
- asynchronous - 如何在 Rust 中对 Futures 的集合进行竞赛?