import os
import matplotlib.pyplot as plt
import numpy as np
os.chdir(r'D:\projects\wordpress\ex55')
os.getcwd()
fig = plt.figure()
ax = fig.add_subplot(111)
t = np.arange(0.0, 5.0, 0.01)
s = np.cos(2*np.pi*t)
line, = ax.plot(t, s, lw=2)
ax.annotate('local max', xy=(2, 1), xytext=(3, 1.5),
arrowprops=dict(facecolor='red', shrink=0.05),
)
ax.set_ylim(-2,2)
plt.savefig("example55.png", dpi=100)
plt.show()
fig = plt.figure()
ax = fig.add_subplot(111, polar=True)
r = np.arange(0,1,0.001)
theta = 2*2*np.pi*r
line, = ax.plot(theta, r, color='#ee8d18', lw=3)
ind = 800
thisr, thistheta = r[ind], theta[ind]
ax.plot([thistheta], [thisr], 'o')
ax.annotate('a polar annotation',
xy=(thistheta, thisr), # theta, radius
xytext=(0.05, 0.05), # fraction, fraction
textcoords='figure fraction',
arrowprops=dict(facecolor='red', shrink=0.05),
horizontalalignment='left',
verticalalignment='bottom',
)
plt.savefig("example55_1.png", dpi=100)
plt.show()
plt.close()
Like this:
Like Loading...
Related
Recent Comments