Double event registered on mouse-click if legend is outside axes

后端 未结 3 1527
暗喜
暗喜 2021-01-20 03:21

I have to plot several data sets in one plot. It is useful to be able to highlight one or more of the plots in order to compare them. For this, I toggle the line style of th

3条回答
  •  花落未央
    2021-01-20 03:54

    My diving into the legend artist has found that a legend line is in the children tree of a legend twice when the legend has the bbox_to_anchor set.

    I asked about this here with my solution where I watched for a NEW mouseevent and kept track of the artists that had already been handled by my callback.

    I've asked for comments if anyone thinks there's a more elegant way to handle this "feature"

    I'm not sure this is a bug. But, it seems unique to legends where the children lines are held in the .lines attribute and deep in the packing boxes data structure - the get_children method finds both of these. Luckily they are the same object rather than a copy so I could check for a line already been handled.

提交回复
热议问题