2017-10-16 3 views
1

하나 이상의 선이있는 축이 3 개 있습니다. 내 커서가있는 선의 선택기를 가져 오기 때문에 선이 포함 된 도끼의 zorder를 변경하려고했습니다.Matplotlib zorder ax 다른 ax의 선을 가리십시오.

정밀도 : I는 FigureCanvasQTAgg 유래 오브제

def onmove(self, event): 
    """Methode appelée à chaque mouvement de souris dans le canvas.""" 
    for curr_axe in self.fig.get_axes(): 
     curr_axe.set_zorder(0) 
     if curr_axe.in_axes(event): 
      axe_x, axe_y = self.axe_dict[curr_axe.name].get_grid_coord(
       event.x, event.y) 

     for line in curr_axe.get_lines(): 
      contain, _ = line.contains(event) 
      if contain and line.get_label()[0] != '_': 
       curr_axe.set_zorder(0.1) 
       self.draw() 
       self.current_line = line.get_label() 

제 AX 단순히 add_axes()으로도 추가 추가하기 matplotlib 축() 클래스를 이용하여 생성된다에서 오전

axe = Axes(figure, rect) 
figure.add_axes(axe) 

다른 축은 twinx()를 통해 생성되고 add_axes()를 사용하여 그림에 추가됩니다.

axe_2 = axe.twinx() 
figure.add_axes(axe_2) 
axe_3 = axe.twinx() 
figure.add_axes(axe_3) 

onmove 메서드는 작동합니다 (원하는 각 줄을 선택할 수 있음). 그러나 첫 번째 드로잉 축의 zorder가 축의 선을 어떻게 숨길 때 어떻게됩니다.

예 : 내 마우스가 도끼 ax라는 줄 위에 있으면 axe_2 및 axe_3의 줄을 숨 깁니다. 나는이 문제를 추측하고있어

enter image description here

답변

0

는 마스크 기본 축 라인을 최상위 도끼, 배경 색상입니다.

모든 축에서 배경을 제거하고 문제가 해결되는지 확인하십시오.

axe.patch.set_visible(False) 
axe_2.patch.set_visible(False) 
axe_3.patch.set_visible(False) 
+0

정말 감사합니다. – reynum

관련 문제