# CairoMakie hlines behaviour

**URL:** <https://discourse.julialang.org/t/cairomakie-hlines-behaviour/93247>\
**Category:** General Usage\
**Tags:** cairomakie-plotting\
**Created:** [January 20, 2023, 5:33am UTC](https://discourse.julialang.org/t/cairomakie-hlines-behaviour/93247 "2023-01-20T05:33:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![SDA](https://avatars.discourse-cdn.com/v4/letter/s/41988e/32.png) [@SDA](https://discourse.julialang.org/u/SDA)\
**Post date:** [January 20, 2023, 5:33am UTC](https://discourse.julialang.org/t/cairomakie-hlines-behaviour/93247/1 "2023-01-20T05:33:43Z")

</div>

Hi everyone,

I’m trying to understand the output of the below MWE:

> using CairoMakie  
> fig = Figure()  
> ax=Axis(fig[1, 1])
> 
> xmins = zeros(10)  
> xmaxs = [1:5; 3:7]  
> ys = 1:10
> 
> hlines!(ax, ys, xmin=xmins, xmax=xmaxs)

I was expecting horizontal lines that went from zero up to `xmaxs` stacked on top of each other. Instead I got the below figure:

 ![fig_hlines](https://global.discourse-cdn.com/julialang/original/3X/0/0/00ad9bff36c23b7fb4a3d06420a2376e4112ecfd.png)

I also can’t tell exactly from the documentation how the x-axis scaling works.  
(I’m trying to create my own barcode plot and ultimately would like to have the different chunks of xmaxs colour coded but first thing’s first.)

Thank you for any suggestions.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [January 20, 2023, 6:49am UTC](https://discourse.julialang.org/t/cairomakie-hlines-behaviour/93247/2 "2023-01-20T06:49:00Z")

</div>

Xmin and xmax are given in fraction of the axis, from 0 to 1, so yours all extend further than the axis but are clipped off so you can’t see that. The y axis is given in data scaling instead. That’s the point of the primitive, to plot a line across the axis that always covers the full width (or a fraction) no matter what the limits are. If you just want a line, use `lines`.

---

<div class="post-metadata">

**Author:** ![SDA](https://avatars.discourse-cdn.com/v4/letter/s/41988e/32.png) [@SDA](https://discourse.julialang.org/u/SDA)\
**Post date:** [January 23, 2023, 1:18am UTC](https://discourse.julialang.org/t/cairomakie-hlines-behaviour/93247/3 "2023-01-23T01:18:05Z")

</div>

Thank you!
