# Animating the content of a title of a plot in Makie.jl

**URL:** <https://discourse.julialang.org/t/animating-the-content-of-a-title-of-a-plot-in-makie-jl/53564>\
**Category:** New to Julia\
**Tags:** plotting\
**Created:** [January 18, 2021, 9:44pm UTC](https://discourse.julialang.org/t/animating-the-content-of-a-title-of-a-plot-in-makie-jl/53564 "2021-01-18T21:44:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Datseris](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/datseris/32/13406_2.png) [@Datseris](https://discourse.julialang.org/u/Datseris)\
**Post date:** [January 18, 2021, 9:44pm UTC](https://discourse.julialang.org/t/animating-the-content-of-a-title-of-a-plot-in-makie-jl/53564/1 "2021-01-18T21:44:33Z")

</div>

My “expected” way of animating the title of a plot does not work.

MWE:

```julia
using GLMakie
fig = Figure()
ax = fig[1,1] = Axis(fig)
s = Observable(0) # counter of current step
titlestr = lift(x -> "step = "*string(x), s)
ax.title = titlestr

```

produces

```julia
ERROR: MethodError: Cannot `convert` an object of type Observable{String} to an object of type String
Closest candidates are:
  convert(::Type{T}, ::T) where T<:AbstractString at strings/basic.jl:229
  convert(::Type{T}, ::AbstractString) where T<:AbstractString at strings/basic.jl:230     
  convert(::Type{S}, ::CategoricalArrays.CategoricalValue) where S<:Union{AbstractChar, AbstractString, Number} at C:\Users\datse\.julia\packages\CategoricalArrays\ZjBSI\src\value.jl:73
  ...

```

What is the correct approach?

---

<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 18, 2021, 9:48pm UTC](https://discourse.julialang.org/t/animating-the-content-of-a-title-of-a-plot-in-makie-jl/53564/2 "2021-01-18T21:48:58Z")

</div>

after you create the `Axis`, all its internal observables exist already. While usually observables are changed with `observable[] = newcontent` for Makie attributes we don’t force people to write the empty index notation all the time.

So what you wrote is equivalent to `ax.attributes[:title][] = titlestr`, so you’re setting the content of an observable to an observable. You want to create the observable first and pass it to `Axis` so it gets used directly.

```julia
ax = fig[1, 1] = Axis(fig, title = titlestr)

```

Or you change the existing observable whenever `titlestr` changes, but that is less elegant:

```julia
on(titlestr) do t
    ax.title = t
end

```
