# Create Interval Notation in Julia?

**URL:** <https://discourse.julialang.org/t/create-interval-notation-in-julia/86375>\
**Category:** General Usage\
**Tags:** plotting\
**Created:** [August 26, 2022, 8:51am UTC](https://discourse.julialang.org/t/create-interval-notation-in-julia/86375 "2022-08-26T08:51:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Freya\_the\_Goddess](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/freya_the_goddess/32/36835_2.png) [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Post date:** [August 26, 2022, 8:51am UTC](https://discourse.julialang.org/t/create-interval-notation-in-julia/86375/1 "2022-08-26T08:51:48Z")

</div>

Hi all,

I wonder about creating interval notation using `Intervals` package, if there is any package that is able do tell me.

I try it this way:

```julia
using Plots, LaTeXStrings, Intervals

a = Interval{Closed, Closed}(1, 10)

plot(a)

```

But it returns unsuccessfully:  
**Cannot convert Interval{Int64, Closed, Closed} to series data for plotting**

The goal is to create a simple interval notation for open and closed set / interval like this:

![index](https://global.discourse-cdn.com/julialang/original/3X/2/c/2cb8d6fade2b2cdc38cee74638304da3d7302a1c.png)

---

<div class="post-metadata">

**Author:** ![SteffenPL](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/steffenpl/32/206270_2.png) [@SteffenPL](https://discourse.julialang.org/u/SteffenPL)\
**Post date:** [August 26, 2022, 9:33am UTC](https://discourse.julialang.org/t/create-interval-notation-in-julia/86375/2 "2022-08-26T09:33:08Z")

</div>

You could write your one latex recipe for Latexify.jl , see  
[https://korsbo.github.io/Latexify.jl/stable/tutorials/recipes/](https://korsbo.github.io/Latexify.jl/stable/tutorials/recipes/)

For the Interval Notation it could be something like

```julia
@latexrecipe function f(x::Interval)
       return Expr(:latexifymerge, 
                    x.first in x ? "[" : "(", 
                    x.first, ",", 
                    x.last, 
                    x.last in x ? "]" : ")")
end

```

I’m not sure if you also wanted to generate the graphs, but for that you could of course also just use Latex and Latexify…

---

<div class="post-metadata">

**Author:** ![Freya\_the\_Goddess](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/freya_the_goddess/32/36835_2.png) [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)\
**Post date:** [August 26, 2022, 10:00am UTC](https://discourse.julialang.org/t/create-interval-notation-in-julia/86375/3 "2022-08-26T10:00:55Z")

</div>

I manage to do it with lots of tricks:

```julia
using Plots, LaTeXStrings, Plots.PlotMeasures

plot([0.5,1],[0,0],arrow=true,color=:black,linewidth=2, xticks=false, yticks=false,
     showaxis=false, label="", bottom_margin = 10mm,)

annotate!([(0.65,0, (L"|", 14, :black))])
annotate!([(0.85,0, (L")", 14, :black))])
annotate!([(0.65,-0.1, (L"0", 10, :black))])
annotate!([(0.85,-0.1, (L"3", 10, :black))])

```

![Capture d’écran_2022-08-26_17-00-43](https://global.discourse-cdn.com/julialang/original/3X/4/1/41eb2611eef6d03e0e2634c6f0cdd193b0261624.png)

Another better version:

```julia
using Plots, LaTeXStrings, Plots.PlotMeasures

f(x) = 0.1
plot([0.5,1],[0,0],arrow=true,color=:black,linewidth=2, xticks=false, yticks=false,
     ylims=(0,1), showaxis=false, label="", bottom_margin = 10mm)
plot!(f,0.5,0.85, fill=(0, 0.25, :blue), label="")

annotate!([(0.65,0, (L"|", 14, :black))])
annotate!([(0.85,0, (L")", 14, :black))])
annotate!([(0.65,-0.1, (L"0", 10, :black))])
annotate!([(0.85,-0.1, (L"3", 10, :black))])

```
