1

Is it possible to use a SVG image as tick label in Matplotlib?

I am trying to do something similar to this but my images are SVG.

Do I have to convert all images to PNG for the above answer to work or can I use SVG directly?

Synergix
  • 145
  • 1
  • 10
  • 4
    Matplotlib cannot read svg images. So in case you want to use matplotlib, and apply the linked solution you need to convert to png first (or in fact any other format that matplotlib can read). – ImportanceOfBeingErnest Dec 13 '19 at 17:41
  • Don't forget to mark the answer as [accepted](https://stackoverflow.com/help/someone-answers) if it answered your question – William Miller Dec 28 '19 at 00:06

1 Answers1

1

Short answer yes, you do need to convert them first.


Long answer

From the matplotlib.image page,

Notes

Matplotlib can only read PNGs natively. Further image formats are supported via the optional dependency on Pillow.

A list of supported file formats for Pillow's current stable release can be found here (including read only and write only supported), at the time of writing this, the list of fully supported formats is

  1. BMP
  2. DIB
  3. EPS
  4. GIF
  5. ICNS
  6. ICO
  7. IM
  8. JPEG
  9. JPEG 2000
  10. MSP
  11. PCX
  12. PNG
  13. PPM
  14. SGI
  15. SPIDER
  16. TGA
  17. TIFF
  18. WEBP
  19. XBM

If you want to use your SVG images they will need to first be converted to PNG if your matplotlib installation is not using Pillow and any of the above if it is.

William Miller
  • 9,839
  • 3
  • 25
  • 46