# PyPlot vmin and vmax equivalent in Makie?

**URL:** <https://discourse.julialang.org/t/pyplot-vmin-and-vmax-equivalent-in-makie/105276>\
**Category:** General Usage\
**Tags:** plotting, pyplot, makie\
**Created:** [October 22, 2023, 11:02am UTC](https://discourse.julialang.org/t/pyplot-vmin-and-vmax-equivalent-in-makie/105276 "2023-10-22T11:02:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jddorellanao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jddorellanao/32/44261_2.png) [@jddorellanao](https://discourse.julialang.org/u/jddorellanao)\
**Post date:** [October 22, 2023, 11:02am UTC](https://discourse.julialang.org/t/pyplot-vmin-and-vmax-equivalent-in-makie/105276/1 "2023-10-22T11:02:09Z")

</div>

In PyPlot.jl when plotting a 2D matrix using `imshow()` you can set `vmin` and `vmax` wich acording to the [official documentation](https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.imshow.html): " _vmin_ and _vmax_ define the data range that the colormap covers."

Using this package I create the next figure:

```julia
fig=figure()
im = imshow(diff(data, dims=2)', vmin=-1e3, vmax=1e3, cmap="gray")
cb = colorbar(im)

```

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

So I tried to recreate it but using Makie, what I did was to normalize the data

```julia
data_ = diff(data, dims=2)
data_ = (data .- minimum(data)) / (maximum(data) - minimum(data));
data__ = data_ * (1e3 - (-1e3)) .+ (-1e3);
f = Figure(resolution = (500, 500))
ax, hm = heatmap(f[1, 1], data__, colormap=:grays, axis = (aspect = 1, yreversed = true))
Colorbar(f[1, 2], hm)

```

But the result is quite far from the desired:

![image](https://global.discourse-cdn.com/julialang/original/3X/5/b/5be5e6bb8daf2b36e463ab1fed205a6bbf7dba13.png)

`colorrange` does not solve the problem, nor does it have to do with the `colormap` used, since plotting the normalized data with PyPlot yields a result similar to Makie.

This is the [data](https://github.com/jddorellanao/inversion_sismica_tesis/blob/main/modelo1/rtm.txt).

---

<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:** [October 22, 2023, 11:54am UTC](https://discourse.julialang.org/t/pyplot-vmin-and-vmax-equivalent-in-makie/105276/2 "2023-10-22T11:54:02Z")

</div>

> [@jddorellanao](#):
>
> ```julia
> data_ = diff(data, dims=2)
> data_ = (data .- minimum(data)) / (maximum(data) - minimum(data));
> 
> ```

You define `data_` twice. The second overwrites the `diff` version.
