2017-10-16 9 views
1

私は1つ以上の線で3つの軸を持っています。 私のカーソルがある行のピッカーを取得するため、その行を含むaxのzorderを変更しようとしました。Matplotlib zorder ax hide他のaxの線

精度:私は派生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() 

に最初の斧は単にmatplotlibの軸()クラスを使用して作成されていますが(add_axesを図に追加ADD)

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

関連する問題