Making image white space transparent, overlay onto imshow()

前端 未结 2 1730
遥遥无期
遥遥无期 2021-02-06 18:27

I have a plot of spatial data that I display with imshow().

I need to be able to overlay the crystal lattice that produced the data. I have a png file of the lattice th

2条回答
  •  死守一世寂寞
    2021-02-06 19:23

    The easy way is to simply use your image as a background rather than an overlay. Other than that you will need to use PIL or Python Image Magic bindings to convert the selected colour to transparent.

    Don't forget you will probably also need to resize either your plot or your image so that they match in size.

    Update:

    If you follow the tutorial here with your image and then plot your data over it you should get what you need, note that the tutorial uses PIL so you will need that installed as well.

提交回复
热议问题