|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
从MySQL获取数据绘图代码如下,怎样设置所绘制图形的背景是透明的,以突出显示途中的箭头?
from pylab import *
import numpy as np
import matplotlib.pyplot as plt
import time
import matplotlib
matplotlib.use('Agg')
from matplotlib.pyplot import savefig
import MySQLdb
db=MySQLdb.connect("localhost","root","123456789","data")
cursor=db.cursor()
cursor.execute("select * from bydata order by id desc limit 1")
cds=cursor.fetchall()
bo_gao=cds[0][6]
liu_su=cds[0][8]
liu_xiang=cds[0][9]
a=float(bo_gao)
b=float(liu_su)
th=int(liu_xiang)
b
th
plt.xlim(-20,20)
plt.ylim(-20,20)
r=b*np.sin(th*np.pi/180)
r
t=b*np.cos(th*np.pi/180)
t
w=0.9*b*np.sin(th*np.pi/180)
w
q=-1.1*b*np.cos(th*np.pi/180)
q
ax=gca()
ax.spines['right'].set_color('none')
ax.spines['top'].set_color('none')
ax.xaxis.set_ticks_position('bottom')
ax.set_xticks([])
ax.set_yticks([])
ax.spines['bottom'].set_color('none')
ax.yaxis.set_ticks_position('left')
ax.spines['left'].set_color('none')
plt.annotate('',xy=(w,q),xytext=(0,0),arrowprops=dict(facecolor='yellow',shrink=0.05))
plt.annotate('',xy=(r,t),xytext=(2,6),arrowprops=dict(facecolor='red',shrink=0.05))
savefig('D:/wamp/www/www/refresh0826.png')
plt.show()
|
-
|