Guide

摘要

Guide 类包含用于配置图表参考线的属性。

语法

 Guide (guideType, {name}, {label}, {valueFrom}, {valueTo}, {polyline}, {lineColor}, {lineWidth}, {lineDashStyle}, {fillColor})
参数说明数据类型
guideType

Specifies the type of guide that will be created.

  • lineA line guide will be created. Use this value in conjunction with the valueFrom property.
  • rangeA range guide will be created. Use this value in conjunction with the valueFrom and valueTo properties.
  • polylineA polyline guide will be created. Use this value in conjunction with the polyline property.
String
name

The unique name for the guide that will appear in the Chart Properties pane.

String
label

The guide label that will be displayed in the chart.

String
valueFrom

The location of the guide when creating a line guide, or the start location of the range when creating a range guide.

Double
valueTo

The location of the guide when creating a line guide, or the start location of the range when creating a range guide.

Double
polyline
[polyline,...]

A list of coordinates when creating a polyline guide. Coordinates are expected to be in row-major order.

Create a polyline guide.


# Coordinates will be: (0, 2), (10, 12), (20, 15)
coordinates = [ 0, 2, 10, 12, 20, 15 ] 
guide = arcpy.charts.Guide(guideType="polyline", polyline=coordinates)
List
lineColor

The color of a line guide in hexadecimal format.

String
lineWidth

The width of a line guide.

Double
lineDashStyle

Specifies the dash style that will be used for a line guide.

  • solidA solid dash style will be used.
  • dotA dot dash style will be used.
  • dashA dash style will be used.
  • dashDotA dash-dot style will be used.
  • longDashA long-dash style will be used.
  • longDashDotA long-dash-dot style will be used.
String
fillColor

The fill color of a range guide in hexadecimal format.

String

属性

属性说明数据类型
fillColor
(可读写)

十六进制格式的范围参考线的填充颜色。

String
guideType
(可读写)

指定要创建的参考线类型。

  • line将创建线参考线。 将此值与 valueFrom 属性配合使用。
  • range将创建范围参考线。 将此值与 valueFromvalueTo 属性配合使用。
  • polyline将创建折线参考线。 将此值与 polyline 属性配合使用。
String
label
(可读写)

将显示在图表中的参考线标注。

String
lineColor
(可读写)

十六进制格式的线参考线的颜色。

String
lineDashStyle
(可读写)

指定用于线参考线的划线样式。

  • solid将使用实线样式。
  • dot将使用点虚线样式。
  • dash将使用虚线样式。
  • dashDot将使用点划线样式。
  • longDash将使用长划线样式。
  • longDashDot将使用长点划线样式。
String
lineWidth
(可读写)

线参考线的宽度。

Double
name
(可读写)

将显示在图表属性窗格中的参考线的唯一名称。

String
polyline
(可读写)

创建折线参考线时将使用的坐标列表。 坐标应按以行为主的顺序排列。

创建折线参考线。


# Coordinates will be: (0, 2), (10, 12), (20, 15)
coordinates = [0, 2, 10, 12, 20, 15] 
guide = arcpy.charts.Guide(guideType="polyline", polyline=coordinates)
List
valueFrom
(可读写)

创建线参考线时参考线的起始位置,或创建范围参考线时范围的起始位置。

Double
valueTo
(可读写)

创建范围参考线时范围的结束位置。

Double

代码示例

参考线示例

向散点图添加两条显示每个轴平均值的参考线。

import arcpy

chart = arcpy.charts.Scatter(x="voter_turnout", y="per_capita_income", dataSource="VoterTurnout2020")

# Create and configure guides
guideX = arcpy.charts.Guide(guideType="line", valueFrom=65.6, label="Avg. Voter Turnout")
guideY = arcpy.charts.Guide(guideType="line", valueFrom=26823.8, label="Avg. Per Capita Income")

# Add guides to appropriate axis
chart.xAxis.addGuide(guideX)
chart.yAxis.addGuide(guideY)

chart.exportToSVG("chart_with_guides.svg")