# Automatically insert variable name or symbol in Title and Colorbar

**URL:** <https://discourse.julialang.org/t/automatically-insert-variable-name-or-symbol-in-title-and-colorbar/124624>\
**Category:** Visualization\
**Tags:** makie, glmakie\
**Created:** [January 10, 2025, 7:38am UTC](https://discourse.julialang.org/t/automatically-insert-variable-name-or-symbol-in-title-and-colorbar/124624 "2025-01-10T07:38:56Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![raman\_kumar](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raman_kumar/32/26782_2.png) [@raman\_kumar](https://discourse.julialang.org/u/raman_kumar)\
**Post date:** [January 10, 2025, 3:01pm UTC](https://discourse.julialang.org/t/automatically-insert-variable-name-or-symbol-in-title-and-colorbar/124624/9 "2025-01-10T15:01:50Z")

</div>

Please see this MWE. My data is available at 👇 that earlier post. What modifications should i do in my code so that i have to change variable(here Ψ) only at single place.

> [@Contour plot on Structured grid using Meshes.jl](https://discourse.julialang.org/t/contour-plot-on-structured-grid-using-meshes-jl/123854/1):
>
> [psi.jl](https://discourse.julialang.org/uploads/short-url/27ssQ2AKWVmD6svGyXUwULS6g9w.jl) (103.5 KB)  
> [x.jl](https://discourse.julialang.org/uploads/short-url/jdmXMZCaxdfKpNDOYLq7a2gvBlU.jl) (98.8 KB)  
> [z.jl](https://discourse.julialang.org/uploads/short-url/1b9IkQCrGebxu2S1zmL2KIzxhJi.jl) (97.5 KB)

```julia
using GLMakie, Meshes

x = include("x.jl") # Matrix of x-coordinates
z = include("z.jl") # Matrix of z-coordinates
Ψ = include("psi.jl") # Data matrix
grd = StructuredGrid(x, z)

function m(s::Symbol, value)
    println("The symbol is $s ")
end
macro m(variable::Symbol)
    :(m($(QuoteNode(variable)), $(esc(variable))))
end
@m(Ψ)

safe_log(x::Float64) = x > 0 ? log(x) : 1.0
z_log = safe_log.(Ψ)
fig, ax, plt = Meshes.viz(grd, color=vec(z_log), colorscheme=:jet)
ax.title = "Ψ and Contour Plot (data.$file)"
cbar = Colorbar(fig[1, 2])
cbar.label = L"log(Ψ)"
# Save the plot
save("Demo_Meshes.png", fig)
display(fig)

```

I get this error on using $value.

```julia
julia> z_log = safe_log.($value)

```

> ERROR: syntax: “$” expression outside quote around REPL[10]:1  
> Stacktrace:  
> [1] top-level scope  
> @ REPL[10]:1

---

_[View the full topic](https://discourse.julialang.org/t/automatically-insert-variable-name-or-symbol-in-title-and-colorbar/124624)._
