2016-03-21 62 views
1

我生成的3D繪圖繪製中等成功,但有些參數對我的標記沒有反應,例如軸範圍,標籤和對數刻度,但有些事情會做如總體標題和寬高比。我無法理解問題,任何人都可以看到我做錯了什麼?離線繪圖忽略plotly python API中的佈局參數

感謝

def make3dPlot(surfaceMatrix, regionStart, regionEnd): 
     data = [go.Surface(z=surfaceMatrix)] 
     #data = [go.Surface(z=[[1, 2, 3, 4, 9],[4, 1, 3, 7, 9],[5, 4, 7, 2, 9]])] 
     layout = go.Layout(
      title=args.i, 
      autosize=True, 
      width=1600, 
      height=1000, 
      yaxis=dict(
       title='Particle Size', 
       titlefont=dict(
        family='Arial, sans-serif', 
        size=18, 
        color='lightgrey' 
       ), 
       type='log', 
       autorange=True, 
       #range=[regionStart, RegionEnd] 
      ), 
      xaxis=dict(
       title="Genomic Co-ordinates", 
       titlefont=dict(
        family='Arial, sans-serif', 
        size=18, 
        color='lightgrey' 
       ), 
       #type='log', 
       #autorange=False, 
       range=[10, 15]#regionStart, regionEnd] 
      ), 
      scene=dict(
       aspectratio=dict(x=3, y=1, z=1), 
       aspectmode = 'manual' 
      ) 
     ) 
     fig = go.Figure(data=data, layout=layout) 


     plotly.offline.plot(fig) 

有了它看起來像這樣,用不變的軸的模擬數據,並沒有標籤:

plotly example

回答

3

docsxaxisyaxiszaxis在3D繪圖積極地是Scene的一部分,而不是Layout

實施例:

from plotly.offline import iplot, init_notebook_mode 
import numpy as np 
from plotly.graph_objs import Surface, Layout, Scene 
init_notebook_mode() 

x, y = np.mgrid[-2*np.pi:2*np.pi:300j, -2:2:300j] 
surface = Surface(
    x=x, y=y, z=-np.cos(x)+y**2/2 
) 

iplot([surface]) 

layout = Layout(scene=Scene(xaxis=dict(range=[-1,1]))) 
iplot(dict(data=[surface], layout=layout)) 

Screenshot

this question見。

+1

哇,我現在感到愚蠢!我不相信我有這個錯誤。那個文檔頁面雖然很長,但我發現很難弄清楚什麼是父類。上下一百次。謝謝 – Daniel