# Custom plots

**URL:** <https://discourse.julialang.org/t/custom-plots/37259>\
**Category:** General Usage\
**Tags:** plotting, plots\
**Created:** [April 9, 2020, 12:27am UTC](https://discourse.julialang.org/t/custom-plots/37259 "2020-04-09T00:27:36Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![JohnZ](https://avatars.discourse-cdn.com/v4/letter/j/ba8739/32.png) [@JohnZ](https://discourse.julialang.org/u/JohnZ)\
**Post date:** [April 9, 2020, 12:27am UTC](https://discourse.julialang.org/t/custom-plots/37259/1 "2020-04-09T00:27:36Z")

</div>

Hello, I would like to understand how I can mark highest and lowest value on the y-axis in a plot. Assume a simple plot

```julia
using Plots
x = 1:10; y = rand(10)
plot(x, y) 

```

I will appreciate your guidance on, how  
a. I can mark (dot or circle) and label the lowest and highest y-axis value  
b. Give a custom name to the legend.

---

<div class="post-metadata">

**Author:** ![tomerarnon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomerarnon/32/3170_2.png) [@tomerarnon](https://discourse.julialang.org/u/tomerarnon)\
**Post date:** [April 9, 2020, 2:28am UTC](https://discourse.julialang.org/t/custom-plots/37259/2 "2020-04-09T02:28:53Z")

</div>

```julia
x = 1:10; y = rand(10)
maxpt = reverse(findmax(y)) # reversing so it's (x,y) rather than (y, x)
minpt = reverse(findmin(y))
plot(x, y)
scatter!([maxpt, minpt], label = "extrema")

```

More generally, `findmax/findmin` return (extremum, index). So if `x` didn’t conveniently go from 1-10, you would index into it with the appropriate index to make `minpt`/`maxpt`

---

<div class="post-metadata">

**Author:** ![JohnZ](https://avatars.discourse-cdn.com/v4/letter/j/ba8739/32.png) [@JohnZ](https://discourse.julialang.org/u/JohnZ)\
**Post date:** [April 9, 2020, 9:14am UTC](https://discourse.julialang.org/t/custom-plots/37259/3 "2020-04-09T09:14:23Z")

</div>

Thank you! May I check a minor point with you? The label/legend sometimes overlap with the plot. Is there a way to align its position? I can’t see anything in the documentation.

---

<div class="post-metadata">

**Author:** ![tomerarnon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomerarnon/32/3170_2.png) [@tomerarnon](https://discourse.julialang.org/u/tomerarnon)\
**Post date:** [April 9, 2020, 9:24am UTC](https://discourse.julialang.org/t/custom-plots/37259/4 "2020-04-09T09:24:49Z")

</div>

You’re probably looking for `legend = :bottomright/:bottomleft/etc`

There are other legend related stuff in the docs, e.g. as relates to subplots (most of this stuff also applies to non-sub-plots)  
[https://docs.juliaplots.org/latest/generated/attributes\_subplot/](https://docs.juliaplots.org/latest/generated/attributes_subplot/)

---

<div class="post-metadata">

**Author:** ![JohnZ](https://avatars.discourse-cdn.com/v4/letter/j/ba8739/32.png) [@JohnZ](https://discourse.julialang.org/u/JohnZ)\
**Post date:** [April 9, 2020, 11:04am UTC](https://discourse.julialang.org/t/custom-plots/37259/5 "2020-04-09T11:04:02Z")

</div>

Thank you again!

---

<div class="post-metadata">

**Author:** ![JohnZ](https://avatars.discourse-cdn.com/v4/letter/j/ba8739/32.png) [@JohnZ](https://discourse.julialang.org/u/JohnZ)\
**Post date:** [April 9, 2020, 5:20pm UTC](https://discourse.julialang.org/t/custom-plots/37259/6 "2020-04-09T17:20:00Z")

</div>

Apologies, I have hit another problem. How can I add an external data point to the plot? For example, assume the plot is made using this code and I want to plot the data point (1.2,3) where x=1.2 and y =3

````nohighlight
plot(x, y, linestyle = :dot, label = "Random", xlim = (-0.5,10),ylim = (0,5))```

````

I cannot use `scatter!([1.2,3],label = "External")` as it will plot it as two y-axis values rather than as one data point.

---

<div class="post-metadata">

**Author:** ![BeastyBlacksmith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/beastyblacksmith/32/4741_2.png) [@BeastyBlacksmith](https://discourse.julialang.org/u/BeastyBlacksmith)\
**Post date:** [April 9, 2020, 6:18pm UTC](https://discourse.julialang.org/t/custom-plots/37259/7 "2020-04-09T18:18:10Z")

</div>

> [@JohnZ](#):
>
> `scatter!([1.2,3],label = "External")`

Either `scatter!([1.2],[3],label = "External")` or `scatter!([(1.2,3)],label = "External")`

---

<div class="post-metadata">

**Author:** ![JohnZ](https://avatars.discourse-cdn.com/v4/letter/j/ba8739/32.png) [@JohnZ](https://discourse.julialang.org/u/JohnZ)\
**Post date:** [April 9, 2020, 6:22pm UTC](https://discourse.julialang.org/t/custom-plots/37259/8 "2020-04-09T18:22:04Z")

</div>

Thanks! I was getting cannot convert float64 to series error when I tried to do it without
