Graph (arcpy)
摘要
图表类有助于您创建不同类型的图表。而且,您可指定常规图表属性,例如标题、图表轴和图例信息。
讨论
可借助图表以直观易懂的方式呈现地图要素的相关信息以及它们之间的关系。也可以为非空间表格数据创建图表,并且可以通过图表显示地图中要素的附加信息或以另一种不同的方式显示这些信息。图表与地图是相辅相成的,因为图表简单、直观地传达了通常以数字形式汇总或从表格中发掘的信息。通过图表可以快速轻松地比较各要素,从而深入了解各要素之间的函数关系,由此以可视化方法显示其他方式难以呈现的数据分布、趋势和模式。
属性
属性 | 说明 | 数据类型 | ||||||||||||
graphAxis (读写) |
Sets the title of the axes (Left, Right, Bottom, and Top) of the graph.
| Object | ||||||||||||
graphPropsGeneral (读写) |
Sets the general properties, such as the title, subtitle, and footer, of the graph.
| Object | ||||||||||||
graphPropsLegend (读写) |
Set the title of the legend in the graph.
| Object | ||||||||||||
graphSeries (读写) |
Get the graph series associated with the graph. When you have multiple series in a graph, you can get information about the individual series. | Object |
方法概述
方法 | 说明 |
addSeriesAreaHorizontal (dataSrc, fieldX, {fieldY}, {fieldLabel}, {sortType}) |
Creates a new Horizontal Area series that can be added to the graph. |
addSeriesAreaVertical (dataSrc, fieldY, {fieldX}, {fieldLabel}, {sortType}) |
Creates a new Vertical Area series that can be added to the graph. |
addSeriesBarHorizontal (dataSrc, fieldX, {fieldY}, {fieldLabel}, {sortType}) |
Creates a new Horizontal Bar series that can be added to the graph. |
addSeriesBarMinMax (dataSrc, fieldYMax, fieldYMin, {fieldX}, {fieldLabel}, {sortType}) |
Creates a new Bar Min and Max series that can be added to the graph. |
addSeriesBarVertical (dataSrc, fieldY, {fieldX}, {fieldLabel}, {sortType}) |
Creates a new Vertical Bar series that can be added to the graph. |
addSeriesBoxPlot (dataSrc, fieldValue) |
Creates a new Box Plot series that can be added to the graph. |
addSeriesBubble (dataSrc, fieldRadius, fieldY, {fieldX}, {fieldLabel}) |
Creates a new Bubble series that can be added to the graph. |
addSeriesHistogram (dataSrc, fieldValue, countBin) |
Creates a new Histogram series that can be added to the graph. |
addSeriesLineHorizontal (dataSrc, fieldX, {fieldY}, {fieldLabel}, {sortType}) |
Creates a new Horizontal Line series that can be added to the graph. |
addSeriesLineVertical (dataSrc, fieldY, {fieldX}, {fieldLabel}, {sortType}) |
Creates a new Vertical Line series that can be added to the graph. |
addSeriesPie (dataSrc, fieldValue, fieldSort, {fieldLabel}, {sortType}) |
Creates a new Pie series that can be added to the graph. |
addSeriesPolar (dataSrc, fieldRadius, {fieldAngle}, {fieldLabel}) |
Creates a new Polar series that can be added to the graph. |
addSeriesScatterPlot (dataSrc, fieldY, {fieldX}, {fieldLabel}) |
Creates a new Scatterplot series that can be added to the graph. |
方法
参数 | 说明 | 数据类型 |
dataSrc |
The layer or table containing the data values that will be used to create the graph. | Layer |
fieldX | The attribute field that will be used to plot value along the X-axis of the Horizontal Area graph. | Field |
fieldY | The attribute field that will be used to plot value along the Y-axis of the Horizontal Area graph. | Field |
fieldLabel | The attribute field that will be used to plot labels for data points along the horizontal area in the graph. | Field |
sortType | Specify how the data values in the attribute field used for defining the Y-axis will be sorted.
| String |
参数 | 说明 | 数据类型 |
dataSrc |
The layer or table containing the data values that will be used to create the graph. | Layer |
fieldY | The attribute field that will be used to plot value along the Y-axis of the Vertical Area graph. | Field |
fieldX | The attribute field that will be used to plot value along the X-axis of the Vertical Area graph. | Field |
fieldLabel | The attribute field that will be used to plot labels for data points along the vertical area in the graph. | Field |
sortType | Specify how the data values in the attribute field used for defining the X-axis will be sorted.
| String |
参数 | 说明 | 数据类型 |
dataSrc |
The layer or table containing the data values that will be used to create the graph. | Layer |
fieldX | The attribute field that will be used to plot value along the X-axis of the Horizontal Bar graph. | Field |
fieldY | The attribute field that will be used to plot value along the Y-axis of the Horizontal Bar graph. | Field |
fieldLabel | The attribute field that will be used to plot labels for data points along the horizontal bars in the graph. | Field |
sortType | Specify how the data values in the attribute field used for defining the Y-axis will be sorted.
| String |
参数 | 说明 | 数据类型 |
dataSrc |
The layer or table containing the data values that will be used to create the graph. | Layer |
fieldYMax | The attribute field that will be used to plot the maximum value along the Y-axis of the Bar Min and Max graph. | Field |
fieldYMin | The attribute field that will be used to plot the minimum value along the Y-axis of the Bar Min and Max graph. | Field |
fieldX | The attribute field that will be used to plot value along the X-axis of the Bar Min and Max graph. | Field |
fieldLabel | The attribute field that will be used to plot labels for data points along the bars in the graph. | Field |
sortType | Specify how the data values in the attribute field used for defining the X-axis will be sorted.
| String |
参数 | 说明 | 数据类型 |
dataSrc |
The layer or table containing the data values that will be used to create the graph. | Layer |
fieldY | The attribute field that will be used to plot values along the Y-axis of the Vertical Bar graph. | Field |
fieldX | The attribute field that will be used to plot values along the X-axis of the Vertical Bar graph. | Field |
fieldLabel | The attribute field that will be used to plot labels for data points along the vertical bars in the graph. | Field |
sortType | Specify how the data values in the attribute field used for defining the X-axis will be sorted.
| String |
参数 | 说明 | 数据类型 |
dataSrc |
The layer or table containing the data values that will be used to create the graph. | Layer |
fieldRadius | The attribute field that defines the radius of the bubbles in the Bubble graph. | Field |
fieldY | The attribute field that will be used to plot values along the Y-axis of the Bubble graph. | Field |
fieldX | The attribute field that will be used to plot values along the X-axis of the Bubble graph. | Field |
fieldLabel | The attribute field that will be used to plot labels for data points in the graph. | Field |
参数 | 说明 | 数据类型 |
dataSrc |
The layer or table containing the data values that will be used to create the graph. | Layer |
fieldValue | The attribute field used for displaying the frequency distribution in the bins of the histogram. The height of the bars in a Histogram represent a frequency count of the number of items falling into each bin. | Field |
countBin | The number of bins in the histogram. | Integer |
参数 | 说明 | 数据类型 |
dataSrc |
The layer or table containing the data values that will be used to create the graph. | Layer |
fieldX | The attribute field that will be used to plot value along the X-axis of the Horizontal Line graph. | Field |
fieldY | The attribute field that will be used to plot value along the Y-axis of the Horizontal Line graph. | Field |
fieldLabel | The attribute field that will be used to plot labels for data points along the horizontal line in the graph. | Field |
sortType | Specify how the data values in the attribute field used for defining the Y-axis will be sorted.
| String |
参数 | 说明 | 数据类型 |
dataSrc |
The layer or table containing the data values that will be used to create the graph. | Layer |
fieldY | The attribute field that will be used to plot value along the Y-axis of the Vertical Line graph. | Field |
fieldX | The attribute field that will be used to plot value along the X-axis of the Vertical Line graph. | Field |
fieldLabel | The attribute field that will be used to plot labels for data points along the vertical line in the graph. | Field |
sortType | Specify how the data values in the attribute field used for defining the X-axis will be sorted.
| String |
参数 | 说明 | 数据类型 |
dataSrc |
The layer or table containing the data values that will be used to create the graph. | Layer |
fieldValue | The attribute field that will be used to plot values or wedges in the Pie graph. | Field |
fieldSort | The attribute field that will be used to sort the wedges in an ascending or descending order. | Field |
fieldLabel | The attribute field that will be used to plot labels in the Pie graph. | Field |
sortType | Specify how the data values will be sorted in the attribute field used for sorting.
| String |
参数 | 说明 | 数据类型 |
dataSrc |
The layer or table containing the data values that will be used to create the graph. | Layer |
fieldRadius | The attribute field whose values are graphed on the radial axis of the Polar graph. | Field |
fieldAngle | The attribute field that supplies the angular position for each data point in the Polar graph. | Field |
fieldLabel | The attribute field that will be used to plot labels representing data values on the graph. | Field |
参数 | 说明 | 数据类型 |
dataSrc |
The layer or table containing the data values that will be used to create the graph. | Layer |
fieldY | The attribute field that will be used to plot values along the Y-axis of the Scatterplot graph. | Field |
fieldX | The attribute field that will be used to plot values along the X-axis of the Scatterplot graph. | Field |
fieldLabel | The attribute field that will be used to plot labels for data points in the graph. | Field |
代码实例
以下脚本创建了垂直条形图并将其保存为影像。
import arcpy
out_graph_name = "VerticalBarGraph"
out_graph_bmp = "c:/temp/VerticalBarGraph.bmp"
input_template = "c:/data/makegraph/VerticalBar.tee"
input_data = "c:/data/makegraph/Rainfall.gdb/Rainfall"
# Create the graph
graph = arcpy.Graph()
# Add a vertical bar series to the graph
graph.addSeriesBarVertical(input_data, "Rainfall_Stations_OBJECTID")
# Specify the title of the left axis
graph.graphAxis[0].title = "Rainfall"
# Specify the title of the bottom axis
graph.graphAxis[2].title = "Days"
# Specify the title of the Graph
graph.graphPropsGeneral.title = "Amount of Rainfall"
# Output a graph, which is created in-memory
arcpy.MakeGraph_management(input_template, graph, out_graph_name)
# Save the graph as an image
arcpy.SaveGraph_management(out_graph_name, out_graph_bmp,
"MAINTAIN_ASPECT_RATIO", 600, 375)