This function represents graphical the flows of a spatial interaction model, in different direct or aggregated forms.
Arguments
- object
a spatial interaction model object
- flows
"full"
(default),"destination"
or"attractiveness"
, see details.- with_names
specifies whether the graphical representation includes location names (
FALSE
by default)- with_positions
specifies whether the graphical representation is based on location positions (
FALSE
by default)- cut_off
cut off limit for inclusion of a segment in the full flow matrix representation with
with_positions = TRUE
- ...
additional parameters, see details
Details
The graphical representation depends on the values of flows
and
with_positions
. If with_position
is FALSE
(default value), the
graphical representations are "abstract". De pending on flows
we have the
following representations:
"full"
: this is the default case for which the full flow matrix is represented. It is extracted from the spatial interaction model withflows()
and displayed using a matrix representation with origin locations in rows and destination locations in columns. The colour of a cell corresponds to the intensity of a flow between the corresponding locations. To mimic the standard top to bottom reading order of a flow matrix, the top row of the graphical representation corresponds to the first origin location."destination"
: the function computes the incoming flows for destination locations (usingdestination_flow()
) and represents them with a bar plot (each bar is proportional to the incoming flow);"attractiveness"
: the function uses a bar plot to represent the attractivenesses of the destination locations (as given byattractiveness()
). This is interesting for dynamic models where those values are updated during the iterations (seeblvim()
for details). When the calculation has converged (seesim_converged()
), both"destination"
and"attractiveness"
graphics should be almost identical.
When the with_names
parameter is TRUE
, the location names
(location_names()
) are used to label the axis of the graphical
representation. If names are not specified, they are replaced by indexes.
When the with_positions
parameter is TRUE
, the location positions
(location_positions()
) are used to produce more "geographically informed"
representations. Notice that if no positions are known for the locations, the
use of with_positions = TRUE
is an error. Depending on flows
we have the
following representations:
"full"
: this is the default case for which the full flow matrix is represented. Positions for both origin and destination locations are needed. The representation uses arrows from origin location positions to destination location positions. The thickness of the lines (linewidth
aesthetics) is proportional to the flows. Only segments that carry a flow above thecut_off
value are included. Additional parameters in...
are submitted toggplot2::geom_segment()
. This can be used to override defaults parameters used for the arrow shapes, for instance."destination"
: the function draws a disk at each destination location using for thesize
aesthetics the incoming flow at this destination location (usingdestination_flow()
)."attractiveness"
: the function draws a disk at each destination location using for thesize
aesthetics the attractiveness of the destination. When the calculation has converged (seesim_converged()
), both"destination"
and"attractiveness"
graphics should be almost identical.
Examples
positions <- matrix(rnorm(10 * 2), ncol = 2)
distances <- as.matrix(dist(positions))
production <- rep(1, 10)
attractiveness <- c(2, rep(1, 9))
flows <- blvim(distances, production, 1.5, 4, attractiveness,
origin_data = list(names = LETTERS[1:10], positions = positions),
destination_data = list(names = LETTERS[1:10], positions = positions)
)
ggplot2::autoplot(flows)
## bar plots should be almost identical if convergence occurred
sim_converged(flows)
#> [1] TRUE
ggplot2::autoplot(flows, "destination")
ggplot2::autoplot(flows, "attractiveness")
## names inclusion
ggplot2::autoplot(flows, "destination", with_names = TRUE)
ggplot2::autoplot(flows, with_names = TRUE)
## positions
ggplot2::autoplot(flows, "attractiveness", with_positions = TRUE) +
ggplot2::scale_size_continuous(range = c(0, 6))
ggplot2::autoplot(flows, with_positions = TRUE) +
ggplot2::scale_linewidth_continuous(range = c(0, 2))