Updating marker style in scatter plot with matplotlib

后端 未结 2 1203
借酒劲吻你
借酒劲吻你 2020-12-17 01:51

I am working on an interactive plotting application which requires users to select data points from a matplotlib scatter plot. For clarity, I would like to be able to alter

2条回答
  •  不知归路
    2020-12-17 02:22

    Pretty sure there is no way to do this. scatter has turned your data into a collection of paths and no longer has the meta-data you would need to do this (ie, it knows nothing about the semantics of why it is drawing a shape, it just has a list of shapes to draw).

    You can also update the colors with set_array (as PathCollection is a sub-class of ScalerMappable).

    If you want to do this (and have a reasonably small number of points) you can manage the paths by hand.

    The other (simpler) option is to use two (or several, one for each shape/color combination you want) Line2D objects (as you are not in this example scaling the size of the markers) with linestyle='none'. The picker event on Line2D objects will give you back which point you were nearest.

    Sorry this is rambley.

提交回复
热议问题