# How to set xticks dependent on Observable?

**URL:** <https://discourse.julialang.org/t/how-to-set-xticks-dependent-on-observable/113740>\
**Category:** Visualization\
**Created:** [May 2, 2024, 1:58pm UTC](https://discourse.julialang.org/t/how-to-set-xticks-dependent-on-observable/113740 "2024-05-02T13:58:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vladdez](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vladdez/32/45806_2.png) [@vladdez](https://discourse.julialang.org/u/vladdez)\
**Post date:** [May 2, 2024, 1:58pm UTC](https://discourse.julialang.org/t/how-to-set-xticks-dependent-on-observable/113740/1 "2024-05-02T13:58:52Z")

</div>

I have an Observable figure dependent on the vector called sortvalues. It perfectly updates except the xticks:

1. when i put:  
` axleft.xticks = sortvalues`  
it shows an error:  
`It is disallowed to set `xticks`, an Observable field of the Makie.Axis struct, to an Observable with dot notation (`setproperty!`), because this would replace the existing Observable. If you really want to do this, use `setfield!` instead.`

2. When I put:

```julia
axleft.xticks = [
            minimum(to_value(sortvalues)),
            maximum(to_value(sortvalues)),
        ]

```

It takes xticks of the first instance of Observable vector and do not update them anymore.  
How to make it updateable?

---

<div class="post-metadata">

**Author:** ![vladdez](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vladdez/32/45806_2.png) [@vladdez](https://discourse.julialang.org/u/vladdez)\
**Post date:** [May 2, 2024, 3:41pm UTC](https://discourse.julialang.org/t/how-to-set-xticks-dependent-on-observable/113740/2 "2024-05-02T15:41:05Z")

</div>

> [@vladdez](#):
>
> axleft.xticks = sortvalues

I tried:

```julia
vec = @lift([minimum($sortvalues), maximum($sortvalues)])
setfield!(axleft, :xticks, vec)

```

But it gave me weird error:

```julia
ERROR: TypeError: in setfield!, expected Observable{Any}, got a value of type Observable{Vector{Float64}}

```

How that even possible?  
Any should accept any type, right?

---

<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:** [May 2, 2024, 4:29pm UTC](https://discourse.julialang.org/t/how-to-set-xticks-dependent-on-observable/113740/3 "2024-05-02T16:29:27Z")

</div>

The error message tells you that you may not update the value to an Observable. So you have to either extract the values out of your observable with `[]` or create the Axis with xticks = observable

---

<div class="post-metadata">

**Author:** ![vladdez](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vladdez/32/45806_2.png) [@vladdez](https://discourse.julialang.org/u/vladdez)\
**Post date:** [May 10, 2024, 2:38pm UTC](https://discourse.julialang.org/t/how-to-set-xticks-dependent-on-observable/113740/4 "2024-05-10T14:38:31Z")

</div>

I created but in that case it just doesn’t updates.  
I also realized that I also want to make limits dependent on Observable. The same problem:

- it doesn’t updates with `Axis(limits = (to_value(@lift(minimum($sortvalues))), to_value(@lift(maximum($sortvalues))), 1, size(to_value(sortvalues), 1)))`
- it gives a Method error with `Axis(limits = (@lift(minimum($sortvalues)), @lift(maximum($sortvalues)), 1, size(to_value(sortvalues), 1)))`

It seems like this functionality doesn’t exists yet and it should be created

---

<div class="post-metadata">

**Author:** ![vladdez](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/vladdez/32/45806_2.png) [@vladdez](https://discourse.julialang.org/u/vladdez)\
**Post date:** [May 13, 2024, 12:58pm UTC](https://discourse.julialang.org/t/how-to-set-xticks-dependent-on-observable/113740/5 "2024-05-13T12:58:50Z")

</div>

```julia
limits = @lift((minimum($sortvalues), maximum($sortvalues), 1, size($sortvalues, 1))),

```
