SVG (.svg, .svgz)

Background & Context

    • MIME type: image/svg+xml
    • SVG vector graphics format.
    • Intended for two-dimensional vector graphics on the web.
    • Partially supported by several web browsers and browser plugins.
    • SVG is an acronym for Scalable Vector Graphics.
    • XML-based text format.
    • Can represent static and animated graphics.
    • Supports RGB color with an optional alpha channel.
    • Developed by the W3C SVG Working Group since 1998.

Import & Export

  • Import["file.svg"] imports an SVG file, returning a rasterized image.
  • Import["file.svg",elem] imports the specified element from an SVG file.
  • The import format can be specified with Import["file","SVG"] or Import["file",{"SVG",elem,}].
  • Export["file.svg",expr] exports text or vector graphics to SVG.
  • Export["file.svg",expr,elem] creates an SVG file by treating expr as specifying element elem.
  • The export format can be explicitly specified with the command Export["file",expr,"SVG"].
  • See the following reference pages for full general information:
  • Import, Exportimport from or export to a file
    CloudImport, CloudExportimport from or export to a cloud object
    ImportString, ExportStringimport from or export to a string
    ImportByteArray, ExportByteArrayimport from or export to a byte array

Import Elements

  • General Import elements:
  • "Elements" list of elements and options available in this file
    "Rules"list of rules for all available elements
    "Summary"summary of properties
  • Data representation elements:
  • "Image"Image object representing the SVG file
  • Metadata elements:
  • "Dimensions"default width and height
    "XMLMetaInformation"metadata given as an XMLElement

Export Elements

    Export Elements
  • Data representation element:
  • "Graphics"arbitrary 2D graphics
  • Export uses the "Graphics" element by default.


open allclose all

Basic Examples  (3)

Export vector graphics to SVG:

This converts formatted text to the SVG format:

Export a function plot to SVG:

Scope  (1)

Show SVG data created by the Wolfram Language: