# How to draw a directed graph of transition matrix

**URL:** <https://discourse.julialang.org/t/how-to-draw-a-directed-graph-of-transition-matrix/87399>\
**Category:** Graphs\
**Tags:** question, plotting, graphs\
**Created:** [September 17, 2022, 10:41am UTC](https://discourse.julialang.org/t/how-to-draw-a-directed-graph-of-transition-matrix/87399 "2022-09-17T10:41:46Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![nsajko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nsajko/32/221187_2.png) [@nsajko](https://discourse.julialang.org/u/nsajko)\
**Post date:** [September 17, 2022, 9:42pm UTC](https://discourse.julialang.org/t/how-to-draw-a-directed-graph-of-transition-matrix/87399/2 "2022-09-17T21:42:32Z")

</div>

Creating a weighted digraph from the stochastic matrix is easy:

```julia
julia> using Graphs, SimpleWeightedGraphs

julia> m = [0.8 0.2; 0.1 0.9]
2×2 Matrix{Float64}:
 0.8 0.2
 0.1 0.9

julia> map(weight, edges(SimpleWeightedDiGraph(m)))
4-element Vector{Float64}:
 0.8
 0.2
 0.1
 0.9

```

For how to draw the graph, see here:

[https://juliagraphs.org/Graphs.jl/dev/first\_steps/plotting/](https://juliagraphs.org/Graphs.jl/dev/first_steps/plotting/)

> [@Drawing a large network using Julia](https://discourse.julialang.org/t/drawing-a-large-network-using-julia/85793/2):
>
> [Graphs.jl](https://github.com/JuliaGraphs/Graphs.jl) is a good package for constructing graphs. You can build them in various ways, by adding vertices and edges, from matrices, etc. For drawing graphs, there are a number of packages that display graphs made with Graphs.jl: [TikzGraphs.jl](https://github.com/sisl/TikzGraphs.jl): backend: Tikz/Latex [GraphPlot.jl](https://juliagraphs.org/GraphPlot.jl/): backend: Compose.jl [SGtSNEpi.jl](https://github.com/fcdimitr/SGtSNEpi.jl): backend: Makie.jl [GraphRecipes.jl](https://github.com/JuliaPlots/GraphRecipes.jl): backend: Plots.jl [GraphMakie.jl](https://github.com/JuliaPlots/GraphMakie.jl): backend: Makie.jl [Karnak.jl](https://github.com/cormullion/Karnak.jl): backend: Luxor.jl

---

_[View the full topic](https://discourse.julialang.org/t/how-to-draw-a-directed-graph-of-transition-matrix/87399)._
