python画箭头(用内置的函数)怎么画?

Python012

python画箭头(用内置的函数)怎么画?,第1张

你用的graphics模块?这不是内置的,虽然它是调用内置的Tkinter画图。

option可以是"first","last","both"或"none"。见graphics.py:

def setArrow(self, option):

if not option in ["first","last","both","none"]:

raise GraphicsError(BAD_OPTION)

self._reconfig("arrow", option)

细节要查Tk文档:

6.6. The canvas line object

In general, a line can consist of any number of segments connected end to end, and each segment can be straight or curved. To create a canvas line object on a canvas C, use:

id = C.create_line ( x0, y0, x1, y1, ..., xn, yn, option, ... )

The line goes through the series of points

(x0,

y0),

(x1,

y1),

(xn,

yn).

Options include:

arrow The default is for the line to have no arrowheads. Use

arrow=FIRST to get an arrowhead at the(x0,y0)end of the line. Use

arrow=LAST to get an arrowhead at the far end. Use

arrow=BOTH for arrowheads at both ends.

#绘制箭头例子

def arrow():

plt.rcParams['font.sans-serif'] = ['SimHei']

plt.style.use('seaborn-deep')

fig = plt.figure(figsize=(16, 9),dpi=75)

ax = fig.add_subplot(121)

x=np.array([1,2,3,4])

y=np.array([2,4,6,8])

ax.plot(x,y,color = 'b')

ax.annotate("",

              xy=(4.5, 9),

              xytext=(4, 8),

              arrowprops=dict(arrowstyle="->", color="r"))

# 设置X轴、Y轴最大坐标          

ax.set_xlim(0, 10)

ax.set_ylim(0, 10)

ax.grid()

ax.set_aspect('equal')

plt.title("趋势展示图")

plt.show()

arrow()

1、首先,我们打开我们的电脑,然后我们打开我们电脑上面的一个excel文档。

2、之后我们选中图示中的区域。

3、然后我们点击工具栏中的插入。

4、之后我们点击散点图下方的下拉箭头。

5、弹出的界面,我们点击带平滑线的散点图。

6、之后我们就会在文档中看到一个带平滑线的散点图了,我们点击空白处。

7、最终结果如图所示,这样我们就制作好一个带平滑线的散点图了。