2011-02-10 2 views
3

다음은 작은 조각으로 matplotlib의 Axes3D 인스턴스에 사용 된 큐브의 크기와 축 레이블의 절단과 관련된 문제를 보여줍니다. 그림 캔버스의 배경색을 아주 쉽게 바꿀 수는 있지만, 여전히 레이블에있는 텍스트가 왜곡됩니다. 누구든지 데이터 플롯에 사용되는 3D 상자의 실제 크기를 변경하는 것이 가장 좋은 방법이 있습니까? 서브 플롯 차원을 변경하는 것만으로는 도움이되지 않습니다. 이 동작은 코드를 실행하여 가장 잘 설명됩니다. 플롯되면 날짜 서식이 지정된 텍스트가 한쪽 끝이 약간 어둡게 변하면서 색이 바뀝니다. 어떤 도움을 주셔서 감사합니다.Axes3D 데이터 레이블 및 플롯 제한

from mpl_toolkits.mplot3d import Axes3D 
import matplotlib.pyplot as plt 
import numpy as np 
import matplotlib.dates as dates 
import datetime, random 
import matplotlib.ticker as ticker 

def random_date(): 
     date = datetime.date(2008, 12,01) 
     while 1: 
     date += datetime.timedelta(days=30) 
     yield (date) 

def format_date(x, pos=None): 
    return dates.num2date(x).strftime('%Y-%m-%d') #use FuncFormatter to format dates 

r_d = random_date() 
some_dates = [dates.date2num(r_d.next()) for i in range(0,20)] 


fig = plt.figure(facecolor = 'k') 
ax = fig.add_subplot(111, projection='3d') 
fig.subplots_adjust(left=0.1, bottom=0.1, right=0.9, top=0.9) 


for c, z in zip(['r', 'g', 'b', 'y'], [30, 20, 10, 0]): 
    xs = np.array(some_dates) 
    ys = np.random.rand(20) 
    ax.bar(xs, ys, zs=z, zdir='y', color=c, alpha=0.8,width=8) 

ax.w_xaxis.set_major_locator(ticker.FixedLocator(some_dates)) # I want all the dates on my xaxis 
ax.w_xaxis.set_major_formatter(ticker.FuncFormatter(format_date)) 
for tl in ax.w_xaxis.get_ticklabels(): # re-create what autofmt_xdate but with w_xaxis 
     tl.set_ha('right') 
     tl.set_rotation(30)  

ax.set_ylabel('Series') 
ax.set_zlabel('Amount') 

plt.show() 

답변

3

변화의 거리 - ax.dist -이 같은 :

ax.dist = 15