# How to set ticklabels for an image, within the range of x, and y

**URL:** <https://discourse.julialang.org/t/how-to-set-ticklabels-for-an-image-within-the-range-of-x-and-y/63637>\
**Category:** Visualization\
**Tags:** images, plots\
**Created:** [June 27, 2021, 8:31am UTC](https://discourse.julialang.org/t/how-to-set-ticklabels-for-an-image-within-the-range-of-x-and-y/63637 "2021-06-27T08:31:29Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![empet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/empet/32/221303_2.png) [@empet](https://discourse.julialang.org/u/empet)\
**Post date:** [June 27, 2021, 8:31am UTC](https://discourse.julialang.org/t/how-to-set-ticklabels-for-an-image-within-the-range-of-x-and-y/63637/1 "2021-06-27T08:31:29Z")

</div>

I searched this forum and the web for the Julia equivalent of `extent` in matplotlib.pyplot.imshow:

```julia
plt.imshow(M, origin="lower", extent=[a, b, c, d])

```

but I couldn’t find any reference. I need this feature for plotting complex functions on a given rectangle in the complex plane:

```julia
using Images, ImageTransformations
function perfract(x, t, m=0.7, M=1)
    x = x / t
    return m + (M-m) * (x-floor(x))
end 

function domcol(w; n=10)
    logm = log.(abs.(w)) # for lines of constant modulus
    H = angle.(w)*180/π #compute argument of w within interval [-180, 180], iei the Hue

    V = perfract.(logm, 2π/n) # lines of constant log-modulus
    arr = permutedims(cat(H, ones(size(H)), V, dims=3), [3,1,2]) #HSV-array

    return RGB.(colorview(HSV, arr[:, end:-1:1,:]))
end

f = z->z^2*tan(z)
x = -5π/4:0.005:5π/4
y = -2.5:0.005:2.5
w = [f(u+1im*v) for v in y, u in x]
img = domcol(w; n=13)
imgn = imresize(img, ratio=1/4)

```

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [June 27, 2021, 11:56am UTC](https://discourse.julialang.org/t/how-to-set-ticklabels-for-an-image-within-the-range-of-x-and-y/63637/2 "2021-06-27T11:56:06Z")

</div>

Couldn’t you just use Plots.jl (with optional `xlims`, `ylims` arguments)?

```julia
using Plots; gr()
plot(x, y, imgn, xlims=(-3,2.2), ylims=(-1.5,2.5))

```

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

---

<div class="post-metadata">

**Author:** ![empet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/empet/32/221303_2.png) [@empet](https://discourse.julialang.org/u/empet)\
**Post date:** [June 27, 2021, 2:51pm UTC](https://discourse.julialang.org/t/how-to-set-ticklabels-for-an-image-within-the-range-of-x-and-y/63637/3 "2021-06-27T14:51:14Z")

</div>

Thank you very much!!! Why you addressed a question? How could I know that this is possible? I searched the web two or three hours, but nowhere met such an example. I like so much Julia, but it is a nightmare to find out what attributes has a chart type. Almost no docstrings. After the transition from Python to Julia, the lack of docstrings in the packages and a reference to all attributes is what always urges me, “go back” ☹

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [June 27, 2021, 3:45pm UTC](https://discourse.julialang.org/t/how-to-set-ticklabels-for-an-image-within-the-range-of-x-and-y/63637/4 "2021-06-27T15:45:16Z")

</div>

The reason for the question was that the sought Python functionality was unclear. 🙂

This Plots.jl syntax for images appeared several times in Discourse posts.

Regarding the docs, they are in general quite good, the difficulty is that the number of options, recipes, etc, is massive. [This section should partially address it.](https://docs.juliaplots.org/latest/generated/gr/#gr-ref51)

---

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [June 27, 2021, 9:07pm UTC](https://discourse.julialang.org/t/how-to-set-ticklabels-for-an-image-within-the-range-of-x-and-y/63637/5 "2021-06-27T21:07:08Z")

</div>

You can also have complete control over the tick positions and labels using the `xticks` and `yticks` keywords:

```julia
julia> using Plots

julia> plot(1:10,rand(10),xticks=([3,7,8],["three","seven","eight"]),xrotation=60)

```

![image](https://global.discourse-cdn.com/julialang/original/3X/a/c/acc0c40378e098826b0f4d3277d044b8a8acaabb.png)

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [July 15, 2022, 6:31am UTC](https://discourse.julialang.org/t/how-to-set-ticklabels-for-an-image-within-the-range-of-x-and-y/63637/6 "2022-07-15T06:31:41Z")

</div>

Here is an updated link to Plots.jl manual - [Images with custom axes](https://docs.juliaplots.org/latest/gallery/pyplot/generated/pyplot-ref51/#pyplot_demo_51).
