Plots

The following documentation describes arguments and helpful tips for plotting ENA models.

Once you're familiar with them, continue to learn more about additional helpful functions.

RecipesBase.plotMethod
plot(
    model::AbstractLinearENAModel,
    x::Int=1,
    y::Int=2,
    margin::PlotMeasures.AbsoluteLength=10mm,
    size::Real=600,
    meanCenter::Bool=model.config.sphereNormalize,
    origin::Array{<:Real}=(meanCenter ?  [mean(model.points[x, :]), mean(model.points[y, :])] : [0,0]),
    zoom::Real=1,
    lims::Real=1/zoom,
    flipX::Bool=false,
    flipY::Bool=false,
    xticks::Array{<:Real}=(
        round.([origin[1]-lims, origin[1], origin[1]+lims], digits=4) |>
        (xticks) -> (flipX ? -reverse(xticks) : xticks)
    ),
    yticks::Array{<:Real}=(
        round.([origin[2]-lims, origin[2], origin[2]+lims], digits=4) |>
        (yticks) -> (flipY ? -reverse(yticks) : yticks)
    ),
    xlims::Array{<:Real}=xticks[[1, end]],
    ylims::Array{<:Real}=yticks[[1, end]],
    titles::Array{<:AbstractString}=String[],
    xlabel::AbstractString=model.embedding[x, :label],
    ylabel::AbstractString=model.embedding[y, :label],
    unitLabel::AbstractString="Unit",
    leg::Union{Symbol,Bool}=:topleft,
    negColor::Colorant=DEFAULT_NEG_COLOR,
    posColor::Colorant=DEFAULT_POS_COLOR,
    groupColors::Array{<:Colorant,1}=DEFAULT_GROUP_COLORS,
    alphabet::String=DEFAULT_ALPHABET,
    groupBy::Union{Symbol,Nothing}=nothing,
    innerGroupBy::Union{Symbol,Nothing}=nothing,
    spectralColorBy::Union{Symbol,Nothing}=nothing,
    trajectoryBy::Union{Symbol,Nothing}=nothing,
    trajectoryBins::Int=5,
    showExtras::Bool=true,
    showNetworks::Bool=true,
    showUnits::Bool=true,
    showMeans::Bool=true,
    showWarps::Bool=false,
    confidenceShape::Symbol=:rect,
    fitNodesToCircle::Bool=false,
    showWeakEdges::Bool=true,
    colorbar::Bool=false
)

Plot an ENA model using the GR backend

See also savefig

Arguments

At minimum, the only required argument is the ENA model itself.

Several optional arguments are available:

  • x and y control which dimension to show on the x- and y-axis respectively
  • margin, size, meanCenter, origin, zoom, lims, flipX, flipY, xticks, yticks, xlims, and ylims together control aspects of the plot size and axes
  • titles, xlabel, ylabel, unitLabel, leg, and alphabet together control the text that labels the plot
  • negColor, posColor, and groupColors together control the colors used in the plot
  • groupBy and innerGroupBy define which metadata columns to use as grouping variables for the sake of color coding and confidence intervals
  • spectralColorBy defines which metadata column to use to color-code units as a spectrum
  • trajectoryBy and trajectoryBins together define and control how a trajectory path should be overlaid on the plot
  • showExtras, showNetworks, showUnits, and showMeans control which plot elements to show or hide. Additionally, confidenceShape can be set to :rect (default) or :ellipse to choose which shape to use when plotting confidence intervals around the means
  • showWarps controls if edges should be drawn straight (false) or "warped" to show their true location in the space (true)
  • fitNodesToCircle controls if nodes should be shown in their optimized positions for goodness of fit, or at a circular position around the origin
  • showWeakEdges controls if edges with weak correlations to trends should be shown
  • colorbar controls if subplots that use gradient color-coding for their edges should have an explicit colorbar added

Example

model = ENAModel(data, codes, conversations, units)
p = plot(model)

# Move the legends to an outer position
p = plot(model, leg=:outertopright)

# Grab one subplot
sp = plot(p.subplots[1], size=(700,700))

# Save
savefig(p, "example.png")

Interpretation

plot(model) produces a plot with the following subplots:

  • (a) an overall mean, which tells us the baseline everything compares against
  • (b) and (c) rates of change for each connection across the x- and y-axes, which helps identify what is being modeled by each axis
  • Subsequent subplots show each subgroup on its own. It's good to compare these to the overall mean
  • And the last subplots show how each pair of subgroups compare. Similar to the trend plots, these show you what is being modeled by the difference of the two groups

Some differences from WebENA and rENA:

  • Saturation shows correlation strength. In WebENA and rENA saturation and line thickness both show magnitude of an effect
  • Plots are mean centered by moving the origin of the plot, not by changing the underlying data. This preserves information that may or may not be useful for downstream analyses
  • Plots are opinionated. Based on the model config, the plot's default settings to change to what I believed was the best way to plot that kind of model. This gives you the "right" plot without having to specify what "right" means each time
  • A known issue is that the y-axis label can get cutoff when there are a lot of subplots
source