# How to plot a graph with labels for vertices?

**URL:** <https://discourse.julialang.org/t/how-to-plot-a-graph-with-labels-for-vertices/62106>\
**Category:** Graphs\
**Tags:** lightgraphs, graphs\
**Created:** [May 31, 2021, 4:06am UTC](https://discourse.julialang.org/t/how-to-plot-a-graph-with-labels-for-vertices/62106 "2021-05-31T04:06:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![xiaodai](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xiaodai/32/15937_2.png) [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Post date:** [May 31, 2021, 4:06am UTC](https://discourse.julialang.org/t/how-to-plot-a-graph-with-labels-for-vertices/62106/1 "2021-05-31T04:06:56Z")

</div>

I am trying to do use LightGraphs.jl to plot some graphs which is ok but I want t label the vertices and edges too.

I have used MetaGraphs to add metadata to each edge but I can’t seem to find a way to plot the graph with the labels.

Does anyone have tips on what to do?

```julia
using LightGraphs, MetaGraphs

mg = MetaGraph(SimpleDiGraph{Int}(1))
add_vertex!(mg.graph)
add_edge!(mg.graph, 2, 1)

using GraphPlot

gplot(mg) # thisoly plots this

```

![image](https://global.discourse-cdn.com/julialang/original/3X/7/1/71eb980ab2554193883a696a06cb67e80589c239.png)

---

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [May 31, 2021, 4:26am UTC](https://discourse.julialang.org/t/how-to-plot-a-graph-with-labels-for-vertices/62106/2 "2021-05-31T04:26:02Z")

</div>

Check the GraphPlot.jl docs for how to add labels.

---

<div class="post-metadata">

**Author:** ![xiaodai](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xiaodai/32/15937_2.png) [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Post date:** [May 31, 2021, 4:33am UTC](https://discourse.julialang.org/t/how-to-plot-a-graph-with-labels-for-vertices/62106/3 "2021-05-31T04:33:00Z")

</div>

ah, why didn’t i think of that. Thought it’d be controlled by Meta but actually you can just specify it

> **[GitHub - JuliaGraphs/GraphPlot.jl: Graph visualization for Julia.](https://github.com/JuliaGraphs/GraphPlot.jl#add-node-label)**
>
> Graph visualization for Julia. Contribute to JuliaGraphs/GraphPlot.jl development by creating an account on GitHub.

 ![image](https://global.discourse-cdn.com/julialang/original/3X/a/7/a7491e0096bae92a15b8c185b2655e3b96be3a6e.png)

 ![image](https://global.discourse-cdn.com/julialang/original/3X/8/b/8b3a77f4d7bf7893bb0babacdf1e5fa0c5e1bc7a.png)
