PlasmoDataPlots.jl is a package for Julia designed for visualizing graphs from the PlasmoData.jl package.
This package is functional and can be installed as is. It is still under development, and significant changes will continue to come. If you encounter any issues or bugs, please submit them through the Github issue tracker.
To install this package, you can use
using Pkg
Pkg.add(url="https://github.com/zavalab/PlasmoDataPlots.jl")
or
pkg> add https://github.com/zavalab/PlasmoDataPlots.jl
PlasmoDataPlots.jl is designed for plotting the DataGraph
object. Node positions are saved under the NodeData of the DataGraph
object. For these positions to be recognized, they must be called "x_positions" and "y_positions". If the user does not define these, the node positions are determined by NetworkLayout.jl's sfdp
function (stands for Scalable Force Directed Placement). Alternatively, when the DataGraph
was constructed from a matrix or a tensor, the user can set the node positions using set_matrix_node_positions!
or set_tensor_node_positions!
functions which take the argument of the DataGraph
and the original matrix or tensor.
The primary function in PlasmoDataPlots.jl is plot_graph
, which takes the following, optional keyword arguments:
get_new_positions::Bool
: If true, calculates new positions using NetworkLayout.jl'ssfdp
function.plot_edges::Bool
: If false, only the nodes of theDataGraph
will be plotted. The edges take the longest time to plot, so this can reduce the plotting time for graphs with many nodes where the edges are less important to visualize (e.g., large matrices formed as graphs)C
,K
,iterations
,tol
: These are arguments used by NetworkLayout.jl'ssfdp
function for determining node positions.xdim
,ydim
: Determing the dimensions of the final plot (default is 800 for both)linewidth
: Determines the width of the edgeslinealpha
: Determines the alpha value (how transparent the edge is).linecolor
: The color used for the edges. Whenline_z
is defined, this should be a color gradient.line_z
: The set of data corresponding to edge weights. This should be a vector of length equal to the number of edges. Can be used if the edges should be color coded by weightnodecolor
: Color of the node markers. Whennode_z
is defined, this should be a color gradient.nodesize
: size of the node markersnodestrokewidth
: Width of the border on the node markersnodestrokecolor
: Color of the border on the node markersnodestrokealpha
: alpha (transparency) of the border on the node markersnode_z
: Set of data corresponding to node weights. This should be a vector of length equal to the number of nodes. Can be used if the nodes should be color coded by weightframestyle
: framestyle of plotrev
: Boolean indicating, if node_z or line_z is defined, that the color gradient from node or line color will be reversedlegend
: Boolean determining whether there should be a colorbar whennode_z
is definedsave_fig
: Boolean to determine if the figure should be saved or notfig_name
: Name of the file name that the saved figure should have.
Any DataGraph
can be plotted simple by calling
plot_graph(datagraph)
However, it may be useful to use keyword arguments depending on the visualization you desire. For example:
random_matrix = rand(15, 15)
matrix_graph = PlasmoData.matrix_to_graph(random_matrix)
set_matrix_node_positions!(matrix_graph, random_matrix)
plot_graph(
matrix_graph,
nodesize = 8,
linecolor = :grey,
linewidth = 4,
node_z = get_node_data(matrix_graph).data[:],
nodecolor = :algae
)