Max*_*Max 14 python plot matplotlib
Matplotlib有一个函数,用于在图形坐标中写入文本(.figtext())
有没有办法做同样的但绘制线条?
特别是我的目标是画线以将y轴上的一些刻度组合在一起.
Pau*_*aul 16
这样做:
from matplotlib import pyplot, lines
import numpy
x = numpy.linspace(0,10,100)
y = numpy.sin(x)*(1+x)
fig = pyplot.figure()
ax = pyplot.subplot(111)
ax.plot(x,y,label='a')
# new clear axis overlay with 0-1 limits
ax2 = pyplot.axes([0,0,1,1], axisbg=(1,1,1,0))
x,y = numpy.array([[0.05, 0.1, 0.9], [0.05, 0.5, 0.9]])
line = lines.Line2D(x, y, lw=5., color='r', alpha=0.4)
ax2.add_line(line)
pyplot.show()
Run Code Online (Sandbox Code Playgroud)
但是如果你想与刻度线对齐,那么为什么不使用绘图坐标呢?
| 归档时间: |
|
| 查看次数: |
10138 次 |
| 最近记录: |