python - How to plot points on a clock -
i have times in seconds since start of unix epoch. plot them on 24 hour clock. effort far is
from __future__ import division import matplotlib.pyplot plt import numpy np angles = 2*np.pi*np.random.randint(0,864000,100)/86400 ax = plt.subplot(111, polar=true) ax.scatter(angles, np.ones(100)*1) plt.show() this gives following

however, it's not like.
- how can put points on circumference not in interior (or @ least move them further out center)?
- how can change labels angles times?
- how can rid of
0.2, 0.4, ...? - basically, how can make more points marked on clock?
from __future__ import division import matplotlib.pyplot plt import numpy np numpy import pi angles = 2*pi*np.random.randint(0,864000,100)/86400 ax = plt.subplot(111, polar=true) ax.scatter(angles, np.ones(100)*1) # suppress radial labels plt.setp(ax.get_yticklabels(), visible=false) # set circumference labels ax.set_xticks(np.linspace(0, 2*pi, 24, endpoint=false)) ax.set_xticklabels(range(24)) # make labels go clockwise ax.set_theta_direction(-1) # place 0 @ top ax.set_theta_offset(pi/2.0) # plt.grid('off') # put points on circumference plt.ylim(0,1) plt.show() 
or, make better use of face of clock, replace scatter plot bar plot (inspiration came this codegolf answer):
# ax.scatter(angles, np.ones(100)*1, marker='_', s=20) ax.bar(angles, np.full(100, 0.9), width=0.1, bottom=0.0, color='r', linewidth=0) 
or, make bars more ticks, set bottom=0.89:
ax.bar(angles, np.full(100, 0.9), width=0.05, bottom=0.89, color='r', linewidth=0) 
Comments
Post a Comment