In Matplotlib, is there a way to know the list of available output format

前端 未结 3 1423
逝去的感伤
逝去的感伤 2021-01-03 18:39

According to Matplotlib documentation, matplotlib.figure.save_figtakes an optional argument format (see matplotlib.figure documentation).

T

3条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-03 19:05

    The FigureCanvasBase class, located in each backends has a get_supported_filetypes method.

    For backend_agg:

    figure = matplotlib.figure.Figure()
    fcb = matplotlib.backends.backend_agg.FigureCanvasBase(figure)
    supported_file_types = fcb.get_supported_filetypes()
    

    supported_file_types contains:

    {'emf': 'Enhanced Metafile',
     'eps': 'Encapsulated Postscript',
     'pdf': 'Portable Document Format',
     'png': 'Portable Network Graphics',
     'ps': 'Postscript',
     'raw': 'Raw RGBA bitmap',
     'rgba': 'Raw RGBA bitmap',
     'svg': 'Scalable Vector Graphics',
     'svgz': 'Scalable Vector Graphics'}
    

    One remaining question .... matplotlib.get_backend() returns "agg". Is there an easier way to directly point to the correct backend module?

提交回复
热议问题