2014-01-17 3 views
2

나는 해결책이 아주 쉽다고 생각한다. 그러나 나는 mayavi 렌더러의 창 크기를 변경하는 방법에 대한 예제를 찾을 수 없습니다.크기 조정 mayavi 창

샘플 코드 : 나는 다음과 같은 노력했습니다

import numpy as np 
from tvtk.api import tvtk 
from mayavi import mlab 

points = np.random.normal(0, 1, (1000, 3)) 
ug = tvtk.UnstructuredGrid(points=points) 
ug.point_data.scalars = np.sqrt(np.sum(points**2, axis=1)) 
ug.point_data.scalars.name = "value" 
ds = mlab.pipeline.add_dataset(ug) 
delaunay = mlab.pipeline.delaunay3d(ds) 
iso = mlab.pipeline.iso_surface(delaunay) 
iso.actor.property.opacity = 0.1 
iso.contour.number_of_contours = 10 
mlab.show() 

:

scene=mlab.gcf().scene 
scene.set_size((600,600)) 

아무것도 변경되지 않습니다. 사전에

안부 감사 ...

답변

3
fig = mlab.figure(size=(600,600)) 
#then the rest of your code 
+2

질문은 기존 렌더러의 크기를 변경하는 방법을 묻습니다. 그 목적을 위해,이 방법은 적어도 내 경우에는 작동하지 않습니다. –

0

Mayavi 자바 스크립트와 DOM 트리를 수정하여 그 수 x3dom 사용하여 플롯을 렌더링하기 때문에. 내 jupyter 노트북에이 js-cell을 썼지 만 jupyter가 제공하는 custom.js 파일 내에서 작동한다고 믿습니다. js 자체가 나를 위해 새롭기 때문에 솔직하게 성능에 대해 확신하지 못합니다.

%%javascript 

MutationObserver = window.MutationObserver || window.WebKitMutationObserver; 
var width = 600; 
var height = 600; 

var observer = new MutationObserver(function(mutations, observer) { 
    mutations.forEach(function(mutation){ 
     if (mutation.target.className === 'x3dom-canvas') 
     { 
      var target = mutation.target; 
      if (target.getAttribute('width') < width) 
       target.setAttribute('width', width); 

      if (target.getAttribute('height') < height) 
       target.setAttribute('height', height); 
     } 
    }); 
}); 

observer.observe(document.body, { 
    subtree: true, 
    attributes: true 
}); 

코드 (분명히 속성) DOM 트리의 수정을 관찰하고 Mayavi에 의해 만들어 특정 노드의 속성을 변경합니다.