Graph (arcpy)

Récapitulatif

The Graph class helps you in creating graphs of different types. Also, you can specify general graph properties such as the title, graph axes, and legend information.

Discussion

Graphs assist you in presenting information about map features and the relationship between them in a visual, easy-to-understand manner. Graphs may also be created for nonspatial tabular data and can show both additional information about the features on the map or the same information in a different way. Graphs are complementary to maps in that they simply and visually convey information that would generally be summarized numerically or explored from tables. With a graph, it is easy to quickly compare features to gain insight into the functional relationship between the features and thereby visualize the distribution, trends, and patterns in the data that would otherwise be difficult to see.

Propriétés

PropriétéExplicationType de données
graphAxis
(Lecture/écriture)

Sets the title of the axes (Left, Right, Bottom, and Top) of the graph.

graphAxis property

Description

aType

The type of graph property, which is applied to the graph irrespective of the number or type of series in the graph. The graphAxis property is a general graph property.

Left

Title of the left axis of the graph. For example, you can specify the title of the left axis by setting graphAxis[0] to "Left Axis".

Right

Title of the right axis of the graph. For example, you can specify the title of the right axis by setting graphAxis[1] to "Right Axis".

Bottom

Title of the bottom axis of the graph. For example, you can specify the title of the bottom axis by setting graphAxis[2] to "Bottom Axis".

Top

Title of the top axis of the graph. For example, you can specify the title of the top axis by setting graphAxis[3] to "Top Axis".

Object
graphPropsGeneral
(Lecture/écriture)

Sets the general properties, such as the title, subtitle, and footer, of the graph.

graphPropsGeneral property

Description

aType

The type of graph property, which is applied to the graph irrespective of the number or type of series in the graph. The graphPropsGeneral property is a general graph property.

footer

Specify the text that appears in the footer of the graph.

subtitle

Specify the text that appears in the subtitle of the graph.

title

Specify the text that appears in the title of the graph.

Object
graphPropsLegend
(Lecture/écriture)

Set the title of the legend in the graph.

graphPropsLegend property

Description

aType

The type of graph property, which is applied to the graph irrespective of the number or type of series in the graph. The graphPropsLegend property is a general graph property.

title

Specify the text that appears in the title of the legend in the graph.

Object
graphSeries
(Lecture/écriture)

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

Vue d'ensemble des méthodes

MéthodeExplication
addSeriesAreaHorizontal (dataSrc, fieldX, {fieldY}, {fieldLabel}, {sortType})

Creates a new Horizontal Area series that can be added to the graph.

Learn more about Horizontal Area graphs

addSeriesAreaVertical (dataSrc, fieldY, {fieldX}, {fieldLabel}, {sortType})

Creates a new Vertical Area series that can be added to the graph.

Learn more about Vertical Area graphs

addSeriesBarHorizontal (dataSrc, fieldX, {fieldY}, {fieldLabel}, {sortType})

Creates a new Horizontal Bar series that can be added to the graph.

Learn more about Horizontal Bar graphs

addSeriesBarMinMax (dataSrc, fieldYMax, fieldYMin, {fieldX}, {fieldLabel}, {sortType})

Creates a new Bar Min and Max series that can be added to the graph.

Learn more about Bar Min and Max graphs

addSeriesBarVertical (dataSrc, fieldY, {fieldX}, {fieldLabel}, {sortType})

Creates a new Vertical Bar series that can be added to the graph.

Learn more about Vertical Bar graphs

addSeriesBoxPlot (dataSrc, fieldValue)

Creates a new Box Plot series that can be added to the graph.

Learn more about Box Plot graphs

addSeriesBubble (dataSrc, fieldRadius, fieldY, {fieldX}, {fieldLabel})

Creates a new Bubble series that can be added to the graph.

Learn more about Bubble graphs

addSeriesHistogram (dataSrc, fieldValue, countBin)

Creates a new Histogram series that can be added to the graph.

Learn more about Histogram graphs

addSeriesLineHorizontal (dataSrc, fieldX, {fieldY}, {fieldLabel}, {sortType})

Creates a new Horizontal Line series that can be added to the graph.

Learn more about Horizontal Line graphs

addSeriesLineVertical (dataSrc, fieldY, {fieldX}, {fieldLabel}, {sortType})

Creates a new Vertical Line series that can be added to the graph.

Learn more about Vertical Line graphs

addSeriesPie (dataSrc, fieldValue, fieldSort, {fieldLabel}, {sortType})

Creates a new Pie series that can be added to the graph.

Learn more about Pie graphs

addSeriesPolar (dataSrc, fieldRadius, {fieldAngle}, {fieldLabel})

Creates a new Polar series that can be added to the graph.

Learn more about Polar graphs

addSeriesScatterPlot (dataSrc, fieldY, {fieldX}, {fieldLabel})

Creates a new Scatterplot series that can be added to the graph.

Learn more about Scatterplot graphs

Méthodes

addSeriesAreaHorizontal (dataSrc, fieldX, {fieldY}, {fieldLabel}, {sortType})
ParamètreExplicationType de données
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.

  • VALUESort the data values based on the order of values in the input layer or table. This is the default.
  • ASCSort the data values in ascending order (lowest to highest).
  • DESCSort the data values in descending order (highest to lowest).

String
addSeriesAreaVertical (dataSrc, fieldY, {fieldX}, {fieldLabel}, {sortType})
ParamètreExplicationType de données
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.

  • VALUESort the data values based on the order of values in the input layer or table. This is the default.
  • ASCSort the data values in ascending order (lowest to highest).
  • DESCSort the data values in descending order (highest to lowest).
String
addSeriesBarHorizontal (dataSrc, fieldX, {fieldY}, {fieldLabel}, {sortType})
ParamètreExplicationType de données
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.

  • VALUESort the data values based on the order of values in the input layer or table. This is the default.
  • ASCSort the data values in ascending order (lowest to highest).
  • DESCSort the data values in descending order (highest to lowest).
String
addSeriesBarMinMax (dataSrc, fieldYMax, fieldYMin, {fieldX}, {fieldLabel}, {sortType})
ParamètreExplicationType de données
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.

  • VALUESort the data values based on the order of values in the input layer or table. This is the default.
  • ASCSort the data values in ascending order (lowest to highest).
  • DESCSort the data values in descending order (highest to lowest).
String
addSeriesBarVertical (dataSrc, fieldY, {fieldX}, {fieldLabel}, {sortType})
ParamètreExplicationType de données
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.

  • VALUESort the data values based on the order of values in the input layer or table. This is the default.
  • ASCSort the data values in ascending order (lowest to highest).
  • DESCSort the data values in descending order (highest to lowest).
String
addSeriesBoxPlot (dataSrc, fieldValue)
ParamètreExplicationType de données
dataSrc

The layer or table containing the data values that will be used to create the graph.

Layer
fieldValue

The attribute field used for plotting the values in the Box Plot graph.

Field
addSeriesBubble (dataSrc, fieldRadius, fieldY, {fieldX}, {fieldLabel})
ParamètreExplicationType de données
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
addSeriesHistogram (dataSrc, fieldValue, countBin)
ParamètreExplicationType de données
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
addSeriesLineHorizontal (dataSrc, fieldX, {fieldY}, {fieldLabel}, {sortType})
ParamètreExplicationType de données
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.

  • VALUESort the data values based on the order of values in the input layer or table. This is the default.
  • ASCSort the data values in ascending order (lowest to highest).
  • DESCSort the data values in descending order (highest to lowest).
String
addSeriesLineVertical (dataSrc, fieldY, {fieldX}, {fieldLabel}, {sortType})
ParamètreExplicationType de données
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.

  • VALUESort the data values based on the order of values in the input layer or table. This is the default.
  • ASCSort the data values in ascending order (lowest to highest).
  • DESCSort the data values in descending order (highest to lowest).
String
addSeriesPie (dataSrc, fieldValue, fieldSort, {fieldLabel}, {sortType})
ParamètreExplicationType de données
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.

  • ASCSort the data values in ascending order (lowest to highest). This is the default.
  • DESCSort the data values in descending order (highest to lowest).
String
addSeriesPolar (dataSrc, fieldRadius, {fieldAngle}, {fieldLabel})
ParamètreExplicationType de données
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
addSeriesScatterPlot (dataSrc, fieldY, {fieldX}, {fieldLabel})
ParamètreExplicationType de données
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

Exemple de code

Graph example

The following script creates a Vertical Bar graph and saves it as an image.

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)

Thèmes connexes

4/26/2014