Graphic Frame

A graphic frame is a shape that contains a graphical object such as a table, chart, or SmartArt object. While often referred to as a shape in common parlance, a table or chart is not a shape. The graphic frame container is the shape and the table, chart, or SmartArt object is a DrawingML (DML) object within it.

A chart, for example, is a shared DML object. It can appear in a Word, Excel, or PowerPoint file, virtually unchanged except for the container in which it appears.

The graphical content is contained in the p:graphicFrame/a:graphic/a:graphicData grandchild element. The type of graphical object contained is specified by an XML namespace contained in the uri attribute of the <a:graphicData> element. The graphical content may appear directly in the <p:graphicFrame> element or may be in a separate part related by an rId. XML for a table is embedded inline. Chart XML is stored in a related Chart part.

Protocol

>>> shape = shapes.add_chart(style, type, x, y, cx, cy)
>>> type(shape)
<class 'pptx.shapes.graphfrm.GraphicFrame'>
>>> shape.has_chart
True
>>> shape.has_table
False
>>> shape.chart
<pptx.parts.chart.ChartPart object at 0x108c0e290>

>>> shape = shapes.add_table(rows=2, cols=2, x, y, cx, cy)
>>> type(shape)
<class 'pptx.shapes.graphfrm.GraphicFrame'>
>>> shape.has_chart
False
>>> shape.has_table
True
>>> shape.table
<pptx.shapes.table.Table object at 0x108c0e310>

Specimen XML

Table in a graphic frame:

<p:graphicFrame>
  <p:nvGraphicFramePr>
    <p:cNvPr id="2" name="Table 1"/>
    <p:cNvGraphicFramePr>
      <a:graphicFrameLocks noGrp="1"/>
    </p:cNvGraphicFramePr>
    <p:nvPr/>
  </p:nvGraphicFramePr>
  <p:xfrm>
    <a:off x="1524000" y="1397000"/>
    <a:ext cx="6096000" cy="741680"/>
  </p:xfrm>
  <a:graphic>
    <a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/table">
      <a:tbl>
        ... remaining table XML ...
      </a:tbl>
    </a:graphicData>
  </a:graphic>
</p:graphicFrame>

Chart in a graphic frame:

<p:graphicFrame>
  <p:nvGraphicFramePr>
    <p:cNvPr id="2" name="Chart 1"/>
    <p:cNvGraphicFramePr/>
    <p:nvPr>
      <p:extLst>
        <p:ext uri="{D42A27DB-BD31-4B8C-83A1-F6EECF244321}">
          <p14:modId xmlns:p14="http://schemas.microsoft.com/office/powerpoint/2010/main"
                     val="11227583"/>
        </p:ext>
      </p:extLst>
    </p:nvPr>
  </p:nvGraphicFramePr>
  <p:xfrm>
    <a:off x="1524000" y="1397000"/>
    <a:ext cx="6096000" cy="4064000"/>
  </p:xfrm>
  <a:graphic>
    <a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/chart">
      <c:chart xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart"
               xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
               r:id="rId2"/>
    </a:graphicData>
  </a:graphic>
</p:graphicFrame>