
## Legend class

Encapsulates the object that represents the chart legend.



**Inheritance:** [`Legend`](/cells/python-net/aspose.cells.charts/legend) → 
[`ChartTextFrame`](/cells/python-net/aspose.cells.charts/charttextframe) → 
[`ChartFrame`](/cells/python-net/aspose.cells.charts/chartframe)



The Legend type exposes the following members:

### Properties
| Property | Description |
| :- | :- |
| [is_inner_mode](/cells/python-net/aspose.cells.charts/legend/is_inner_mode) | Indicates whether the size of the plot area size includes the tick marks, and the axis labels.<br/>False specifies that the size shall determine the size of the plot area, the tick marks, and the axis labels. |
| [border](/cells/python-net/aspose.cells.charts/legend/border) | Gets the [`Line`](/cells/python-net/aspose.cells.drawing/line). |
| [area](/cells/python-net/aspose.cells.charts/legend/area) | Gets the [`ChartFrame.area`](/cells/python-net/aspose.cells.charts/chartframe#area). |
| [text_font](/cells/python-net/aspose.cells.charts/legend/text_font) | Gets a [`ChartFrame.font`](/cells/python-net/aspose.cells.charts/chartframe#font) object of the specified ChartFrame object. |
| [text_options](/cells/python-net/aspose.cells.charts/legend/text_options) | Gets and sets the options of the text. |
| [font](/cells/python-net/aspose.cells.charts/legend/font) | Gets a [`ChartFrame.font`](/cells/python-net/aspose.cells.charts/chartframe#font) object of the specified ChartFrame object. |
| [auto_scale_font](/cells/python-net/aspose.cells.charts/legend/auto_scale_font) | True if the text in the object changes font size when the object size changes. The default value is True. |
| [background_mode](/cells/python-net/aspose.cells.charts/legend/background_mode) | Gets and sets the display mode of the background |
| [background](/cells/python-net/aspose.cells.charts/legend/background) | Gets and sets the display mode of the background |
| [is_automatic_size](/cells/python-net/aspose.cells.charts/legend/is_automatic_size) | Indicates whether the chart frame is automatic sized. |
| [x](/cells/python-net/aspose.cells.charts/legend/x) | Gets or sets the x coordinate of the upper left corner in units of 1/4000 of the chart area. |
| [y](/cells/python-net/aspose.cells.charts/legend/y) | Gets or sets the y coordinate of the upper left corner in units of 1/4000 of the chart area. |
| [height](/cells/python-net/aspose.cells.charts/legend/height) | Gets or sets the height of frame in units of 1/4000 of the chart area. |
| [width](/cells/python-net/aspose.cells.charts/legend/width) | Gets or sets the width of frame in units of 1/4000 of the chart area. |
| [shadow](/cells/python-net/aspose.cells.charts/legend/shadow) | True if the frame has a shadow. |
| [shape_properties](/cells/python-net/aspose.cells.charts/legend/shape_properties) | Gets the [`ChartFrame.shape_properties`](/cells/python-net/aspose.cells.charts/chartframe#shape_properties) object. |
| [is_default_pos_be_set](/cells/python-net/aspose.cells.charts/legend/is_default_pos_be_set) | Indicates whether default position(DefaultX, DefaultY, DefaultWidth and DefaultHeight) are set. |
| [default_x](/cells/python-net/aspose.cells.charts/legend/default_x) | Represents x of default position in units of 1/4000 of the chart area. |
| [default_y](/cells/python-net/aspose.cells.charts/legend/default_y) | Represents y of default position in units of 1/4000 of the chart area. |
| [default_width](/cells/python-net/aspose.cells.charts/legend/default_width) | Represents width of default position in units of 1/4000 of the chart area. |
| [default_height](/cells/python-net/aspose.cells.charts/legend/default_height) | Represents height of default position in units of 1/4000 of the chart area. |
| [default_x_ratio_to_chart](/cells/python-net/aspose.cells.charts/legend/default_x_ratio_to_chart) | Represents x of default position in units of Fraction of the chart area. |
| [default_y_ratio_to_chart](/cells/python-net/aspose.cells.charts/legend/default_y_ratio_to_chart) | Represents y of default position in units of Fraction of the chart area. |
| [default_width_ratio_to_chart](/cells/python-net/aspose.cells.charts/legend/default_width_ratio_to_chart) | Represents width of default position in units of Fraction of the chart area. |
| [default_height_ratio_to_chart](/cells/python-net/aspose.cells.charts/legend/default_height_ratio_to_chart) | Represents height of default position in units of Fraction of the chart area. |
| [x_ratio_to_chart](/cells/python-net/aspose.cells.charts/legend/x_ratio_to_chart) | Gets or sets the x coordinate of the upper left corner in units of ratio of the chart area. |
| [y_ratio_to_chart](/cells/python-net/aspose.cells.charts/legend/y_ratio_to_chart) | Gets or sets the y coordinate of the upper left corner in units of ratio of the chart area. |
| [width_ratio_to_chart](/cells/python-net/aspose.cells.charts/legend/width_ratio_to_chart) | Gets or sets the width of frame in units of ratio of the chart area. |
| [height_ratio_to_chart](/cells/python-net/aspose.cells.charts/legend/height_ratio_to_chart) | Gets or sets the height of frame in units of ratio of the chart area. |
| [x_pixel](/cells/python-net/aspose.cells.charts/legend/x_pixel) | Gets or sets the x coordinate of the upper left corner in units of Pixel. |
| [y_pixel](/cells/python-net/aspose.cells.charts/legend/y_pixel) | Gets or sets the y coordinate of the upper left corner in units of Pixel. |
| [width_pixel](/cells/python-net/aspose.cells.charts/legend/width_pixel) | Gets or sets the width of frame in units of Pixel. |
| [height_pixel](/cells/python-net/aspose.cells.charts/legend/height_pixel) | Gets or sets the height of frame in units of Pixel. |
| [is_auto_text](/cells/python-net/aspose.cells.charts/legend/is_auto_text) | Indicates the text is auto generated. |
| [is_deleted](/cells/python-net/aspose.cells.charts/legend/is_deleted) | Indicates whether this data labels is deleted. |
| [text_horizontal_alignment](/cells/python-net/aspose.cells.charts/legend/text_horizontal_alignment) | Gets and sets the text horizontal alignment. |
| [text_vertical_alignment](/cells/python-net/aspose.cells.charts/legend/text_vertical_alignment) | Gets or sets the text vertical alignment of text. |
| [rotation_angle](/cells/python-net/aspose.cells.charts/legend/rotation_angle) | Represents text rotation angle. |
| [is_automatic_rotation](/cells/python-net/aspose.cells.charts/legend/is_automatic_rotation) | Indicates whether the text of the chart is automatically rotated. |
| [text](/cells/python-net/aspose.cells.charts/legend/text) | Gets or sets the text of a frame's title. |
| [linked_source](/cells/python-net/aspose.cells.charts/legend/linked_source) | Gets and sets a reference to the worksheet. |
| [text_direction](/cells/python-net/aspose.cells.charts/legend/text_direction) | Represents text reading order. |
| [reading_order](/cells/python-net/aspose.cells.charts/legend/reading_order) | Represents text reading order. |
| [direction_type](/cells/python-net/aspose.cells.charts/legend/direction_type) | Gets and sets the direction of text. |
| [is_text_wrapped](/cells/python-net/aspose.cells.charts/legend/is_text_wrapped) | Gets or sets a value indicating whether the text is wrapped. |
| [is_resize_shape_to_fit_text](/cells/python-net/aspose.cells.charts/legend/is_resize_shape_to_fit_text) | Gets or sets whether a shape should be auto-fit to fully contain the text described within it. Auto-fitting is<br/>when text within a shape is scaled in order to contain all the text inside. |
| [position](/cells/python-net/aspose.cells.charts/legend/position) | Gets or sets the legend position type. |
| [legend_entries](/cells/python-net/aspose.cells.charts/legend/legend_entries) | Gets a collection of all the LegendEntry objects in the specified chart legend.<br/>Setting the legend entries of the surface chart is not supported.<br/>So it will return null if the chart type is surface chart type. |
| [legend_entries_labels](/cells/python-net/aspose.cells.charts/legend/legend_entries_labels) | Gets the labels of the legend entries after call Chart.Calculate() method. |
| [is_over_lay](/cells/python-net/aspose.cells.charts/legend/is_over_lay) | Gets or sets whether showing the legend without overlapping the chart. |


### Methods
| Method | Description |
| :- | :- |
| [`set_position_auto(self)`](/cells/python-net/aspose.cells.charts/legend/set_position_auto/#) | Set position of the frame to automatic |
| [`characters(self, start_index, length)`](/cells/python-net/aspose.cells.charts/legend/characters/#int-int) | Returns a Characters object that represents a range of characters within the text. |
| [`get_legend_labels(self)`](/cells/python-net/aspose.cells.charts/legend/get_legend_labels/#) | Gets the labels of the legend entries after call Chart.Calculate() method. |



### Example 


```python
from aspose.cells import Workbook
from aspose.cells.charts import ChartType, LegendPositionType

workbook = Workbook()
sheet = workbook.worksheets[0]
cells = sheet.cells
cells.get(0, 1).put_value("Income")
cells.get(1, 0).put_value("Company A")
cells.get(2, 0).put_value("Company B")
cells.get(3, 0).put_value("Company C")
cells.get(1, 1).put_value(10000)
cells.get(2, 1).put_value(20000)
cells.get(3, 1).put_value(30000)
chartIndex = sheet.charts.add(ChartType.COLUMN, 9, 9, 21, 15)
chart = sheet.charts[chartIndex]
chart.set_chart_data_range("A1:B4", True)
# Set Legend's width and height
legend = chart.legend
# Legend is at right side of chart by default.
# If the legend is at left or right side of the chart, setting Legend.X property will not take effect.
# If the legend is at top or bottom side of the chart, setting Legend.Y property will not take effect.
legend.y = 1500
legend.width = 50
legend.height = 50
# Set legend's position
legend.position = LegendPositionType.LEFT

```

### See Also
* module [`aspose.cells.charts`](..)
* class [`ChartFrame`](/cells/python-net/aspose.cells.charts/chartframe)
* class [`ChartTextFrame`](/cells/python-net/aspose.cells.charts/charttextframe)
* class [`Legend`](/cells/python-net/aspose.cells.charts/legend)
* class [`Line`](/cells/python-net/aspose.cells.drawing/line)
