# Arrows in plots

**URL:** <https://discourse.julialang.org/t/arrows-in-plots/110629>\
**Category:** Visualization\
**Tags:** plots\
**Created:** [February 23, 2024, 9:26am UTC](https://discourse.julialang.org/t/arrows-in-plots/110629 "2024-02-23T09:26:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![blob](https://avatars.discourse-cdn.com/v4/letter/b/ebca7d/32.png) [@blob](https://discourse.julialang.org/u/blob)\
**Post date:** [February 23, 2024, 9:26am UTC](https://discourse.julialang.org/t/arrows-in-plots/110629/1 "2024-02-23T09:26:38Z")

</div>

I want to plot lines with arrows at the end of the lines. Following [this thread](https://discourse.julialang.org/t/how-to-draw-a-line-with-an-arrow-in-plot-jl/55974/9), I got:  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/0/a/0a1d43bd2b8b7ce74f325be8df96bd0d51047996.png)  
obtained from:

```julia
Using Plots

plot([0.0 1.0]',[0.0 -0.71]',label="Correct, solid blue with arrow",palette=:imola100,lw=2,arrow=true)
plot!([0.0 1.0]',[0.0 2.0]',label="Correct, solid black with arrow",palette=:grayC100,lw=2,arrow=true)
plot!([0.0 -1.076]',[0.0 3.78]',ls=:dash,label="Correct, dashed black with arror",palette=:grayC100,lw=2,arrow=true)
plot!([0.0 -2.076]',[0.0 3.78]',ls=:dash,label="Incorrect, why not dashed?",palette=:grayC100,lw=2,arrow=true) ####Why isn't this dashed?
plot!([0.0 -1.4]',[0.0 0.53]',ls=:dash,label="Incorrect, why not dashed?",palette=:imola100,lw=2,arrow=true) ####Why isn't this dashed?
plot!([0.0 -2.4]',[0.0 0.53]',ls=:dash,label="Inorrect, dashed but no arrow",palette=:imola100,lw=2) ####But it can be dashed with no arrow?

```

The legend suggests that the dashed lines are there but they are indistinguishable visually from solid lines. This is the case, when I zoom in, I see the dashes:  
 ![image](https://global.discourse-cdn.com/julialang/original/3X/0/f/0f7ae36875fd7f0a9fe2f4debd3a3f1ec69471c0.png)

I thought it was just a visual issue and the dashes got merged together, so I removed the arrows

```julia
plot!([0.0 -1.4]',[0.0 0.53]',ls=:dash,palette=:imola100,lw=2) ####Why is this dashed?

```

and got dashes:  
 ![Screenshot 2024-02-23 101754](https://global.discourse-cdn.com/julialang/original/3X/6/c/6c8277bd69b119eb353b386910447495d25bb798.png)

How can I make a dashed line with arrows work?

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [February 23, 2024, 3:50pm UTC](https://discourse.julialang.org/t/arrows-in-plots/110629/2 "2024-02-23T15:50:29Z")

</div>

> [@blob](#):
>
> How can I make a dashed line with arrows work?

You may use the Plots.jl’s `pyplot()/pythonplot()` backend :

> **Code**
>
> ```julia
> using Plots; pyplot(dpi=100)
> 
> plot([0.0, 1.0], [0.0, -0.71], c="blue", lw=2, arrow=true)
> plot!([0.0, 1.0],[0.0, 2.0], c="red", lw=2, arrow=true)
> plot!([0.0, -1.076], [0.0, 3.78], ls=:dash, c="orange", lw=2,arrow=true)
> plot!([0.0, -2.076], [0.0, 3.78], ls=:dash, c="violet", lw=2,arrow=true)
> plot!([0.0, -1.4], [0.0, 0.53], ls=:dash, c="green", lw=2, arrow=true)
> plot!([0.0, -2.4], [0.0, 0.53], ls=:dash, c="grey", lw=2)
> 
> ```

 ![Plots_pyplot_arrows_dashed](https://global.discourse-cdn.com/julialang/original/3X/0/7/07a55c2db986171206cc9deb4e90128b97ff36f4.png)

and submit an issue in Plots.jl repo for the `gr()` backend.
