2014-09-11 3 views
0

를 포맷하는 방법 :내가 슬라이더가 슬라이더

time_ax = fig.add_axes([0.1, 0.05, 0.8, 0.03]) 
var_time = Slider(time_ax, 'Time', 0, 100, valinit=10, valfmt='%0.0f') 
var_time.on_changed(update) 

을 나는이 슬라이더의 모양을 사용자 정의 할 : 내가하는 것, axisbg 매개 변수 add_axes 기능을 추가 할 수 있습니다

screenshot

을 기본 흰색 배경을 할당 된 색상으로 변경하지만 그게 지금 가능한 것입니다.

그래서, 다른 슬라이더 구성 요소를 변경하는 방법 :

  • silder 국경 (기본값 : 블랙)
  • 디폴트 값 표시 (기본값 : 레드)
  • 슬라이더 진행 (기본 : 블루)

답변

0

슬라이더 테두리는 Axes 인스턴스의 등뼈입니다. 진행 막대는 생성자의 기본 사용자 정의를 위해 직접 액세스 할 수 있으며 초기 상태 표시기는 슬라이더의 속성입니다. 나는 그 모든 것들을 변경할 수 있었다 :

import matplotlib.pyplot as plt 
from matplotlib.widgets import Slider 

fig = plt.figure() 
time_ax = fig.add_axes([0.1, 0.05, 0.8, 0.03]) 

# Facecolor and edgecolor control the slider itself 
var_time = Slider(time_ax, 'Time', 0, 100, valinit=10, valfmt='%0.0f', 
        facecolor='c', edgecolor='r') 

# The vline attribute controls the initial value line 
var_time.vline.set_color('blue') 

# The spines of the axis control the borders 
time_ax.spines['left'].set_color('magenta') 
time_ax.spines['right'].set_color('magenta') 
time_ax.spines['bottom'].set_color('magenta') 
time_ax.spines['top'].set_color('magenta') 
0

당신이 "도끼"상자의 축을 정의 할 때 변경할 수있는 상자의 색 :

fig, ax = plt.subplots() 
plt.subplots_adjust(left=0.25, bottom=0.25) 
t = np.arange(0.0, 1.0, 0.001) 
a0 = 5 
f0 = 3 
s = a0*np.sin(2*np.pi*f0*t) 
l, = plt.plot(t,s, lw=2, color='red') 
plt.axis([0, 1, -10, 10]) 

axcolor = 'lightgoldenrodyellow' 
axfreq = plt.axes([0.03, 0.25, 0.03, 0.65], axisbg=axcolor) 
axamp = plt.axes([0.08, 0.25, 0.03, 0.65], axisbg=axcolor) 
sfreq = Slider(axfreq, 'Freq', 0.1, 30.0, valinit=f0) 
samp = Slider(axamp, 'Amp', 0.1, 10.0, valinit=a0) 
# The vline attribute controls the initial value line 
samp.vline.set_color('green') 
관련 문제