作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
有没有办法改变散点图上的轴?假设将轴从 (0,0) 即(零线)移动到 (3,3) 之类的位置并制作象限图
我尝试将“xaxis”和“yaxis”上的“zeroline”值设置为False,然后从“shapes”的两个轴上绘制两条恒定线。但我想知道是否有任何方法可以更改原点轴。
Here's the example in the image
import plotly.graph_objs as go
import plotly
import plotly.io as pio
trace0 = go.Scatter(
x=[7],
y=[7.5],
)
data = [trace0]
layout = {
'xaxis': {
'zeroline': False,
'dtick': 1,
},
'yaxis': {
'zeroline': False,
'dtick': 1,
},
'shapes': [
{
'type': 'line',
'x0': 5,
'y0': 0,
'x1': 5,
'y1': 10,
'line': {
'width': 1,
},
},
{
'type': 'line',
'x0': 0,
'y0': 5,
'x1': 10,
'y1': 5,
'line': {
'width': 1
},
},
]
}
fig = {
'data': data,
'layout': layout,
}
plotly.offline.plot(fig)
pio.write_image(fig, 'images/test.png')
最佳答案
如果您运行 help(fig['layout']['xaxis'])
您会看到 zeroline
的唯一选项是:
zeroline
Determines whether or not a line is drawn at along the
0 value of this axis. If True, the zero line is drawn
on top of the grid lines.
zerolinecolor
Sets the line color of the zero line.
zerolinewidth
Sets the width (in px) of the zero line.
所以如果你的方法是......
setting the "zeroline" value on both "xaxis" and "yaxis" to False and then drawing two constant lines across both the axes from 'shapes'.
...适合您,我真的认为这是您最好的选择。
关于python - 有没有办法改变散点图上的原点轴(零线)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55897305/
我是一名优秀的程序员,十分优秀!