2014-09-17 3 views
3

유닉스 시대가 시작된 이래로 몇 초가 걸렸습니다. 나는 24 시간 시계에 그들을 음모하고 싶습니다. 내 노력은 지금까지 내가 좋아하는 것이 무엇인지 정확하게 아니다, 이것은 그러나 다음클록상의 점을 그리는 방법

Attempt to plot on a clock

을 제공

from __future__ import division 
import matplotlib.pyplot as plt 
import numpy as 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() 

입니다.

  • 포인트를 내부가 아닌 (또는 최소한 센터에서 더 멀리 움직여) 원주에 어떻게 배치 할 수 있습니까?
  • 라벨을 각도에서 시간대로 변경하려면 어떻게해야합니까?
  • 0.2, 0.4, ...을 제거하려면 어떻게해야합니까?
  • 기본적으로 시계에 표시된 점처럼 보이게하려면 어떻게해야합니까?

답변

4
from __future__ import division 
import matplotlib.pyplot as plt 
import numpy as np 
from 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 the radial labels 
plt.setp(ax.get_yticklabels(), visible=False) 

# set the circumference labels 
ax.set_xticks(np.linspace(0, 2*pi, 24, endpoint=False)) 
ax.set_xticklabels(range(24)) 

# make the labels go clockwise 
ax.set_theta_direction(-1) 

# place 0 at the top 
ax.set_theta_offset(pi/2.0)  

# plt.grid('off') 

# put the points on the circumference 
plt.ylim(0,1) 

plt.show() 

enter image description here

가 또는 시계의 얼굴을보다 효율적으로 사용할 수 있도록, 당신이 bar 음모와 scatter 플롯을 대체 할 수있다 (이에 대한 영감 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) 

enter image description here

또는 막대 모양을 m 당신이 진드기를 원하는 경우에,

ax.bar(angles, np.full(100, 0.9), width=0.05, bottom=0.89, color='r', linewidth=0) 

enter image description here

+1

어쩌면 작은 선분을 그릴 : 진드기 같은 광석, 당신은 bottom=0.89을 설정할 수 있습니다. –

관련 문제