MCPcopy Create free account
hub / github.com/scanny/python-pptx / Legend

Class Legend

src/pptx/chart/legend.py:10–79  ·  view source on GitHub ↗

Represents the legend in a chart. A chart can have at most one legend.

Source from the content-addressed store, hash-verified

8
9
10class Legend(object):
11 """
12 Represents the legend in a chart. A chart can have at most one legend.
13 """
14
15 def __init__(self, legend_elm):
16 super(Legend, self).__init__()
17 self._element = legend_elm
18
19 @lazyproperty
20 def font(self):
21 """
22 The |Font| object that provides access to the text properties for
23 this legend, such as bold, italic, etc.
24 """
25 defRPr = self._element.defRPr
26 font = Font(defRPr)
27 return font
28
29 @property
30 def horz_offset(self):
31 """
32 Adjustment of the x position of the legend from its default.
33 Expressed as a float between -1.0 and 1.0 representing a fraction of
34 the chart width. Negative values move the legend left, positive
35 values move it to the right. |None| if no setting is specified.
36 """
37 return self._element.horz_offset
38
39 @horz_offset.setter
40 def horz_offset(self, value):
41 self._element.horz_offset = value
42
43 @property
44 def include_in_layout(self):
45 """|True| if legend should be located inside plot area.
46
47 Read/write boolean specifying whether legend should be placed inside
48 the plot area. In many cases this will cause it to be superimposed on
49 the chart itself. Assigning |None| to this property causes any
50 `c:overlay` element to be removed, which is interpreted the same as
51 |True|. This use case should rarely be required and assigning
52 a boolean value is recommended.
53 """
54 overlay = self._element.overlay
55 if overlay is None:
56 return True
57 return overlay.val
58
59 @include_in_layout.setter
60 def include_in_layout(self, value):
61 if value is None:
62 self._element._remove_overlay()
63 return
64 self._element.get_or_add_overlay().val = bool(value)
65
66 @property
67 def position(self):

Callers 8

legendMethod · 0.90
font_fixtureMethod · 0.90
position_get_fixtureMethod · 0.90
position_set_fixtureMethod · 0.90

Calls

no outgoing calls

Tested by 7

font_fixtureMethod · 0.72
position_get_fixtureMethod · 0.72
position_set_fixtureMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…