# Subplot of heatmap in Plots

**URL:** <https://discourse.julialang.org/t/subplot-of-heatmap-in-plots/7207>\
**Category:** General Usage\
**Tags:** plotting\
**Created:** [November 21, 2017, 1:06am UTC](https://discourse.julialang.org/t/subplot-of-heatmap-in-plots/7207 "2017-11-21T01:06:27Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![babaq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/babaq/32/891_2.png) [@babaq](https://discourse.julialang.org/u/babaq)\
**Post date:** [November 21, 2017, 1:06am UTC](https://discourse.julialang.org/t/subplot-of-heatmap-in-plots/7207/1 "2017-11-21T01:06:27Z")

</div>

Hi

i have a vector of images that need to plot in heatmap, i want to display all of them in an grid subplots,

the Plots doc shows that the easiest way is to use `heatmap(a,layout=grid(3,3)` given a=array(matrix,9). but it seems Plots don’t know how to automatically map each image to each subplot in grid.

my questions is whether this simple use is possible in Plots, or i have to iterately plot each image in subplots, and how to do that?

---

<div class="post-metadata">

**Author:** ![JackDevine](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jackdevine/32/1048_2.png) [@JackDevine](https://discourse.julialang.org/u/JackDevine)\
**Post date:** [November 21, 2017, 1:45am UTC](https://discourse.julialang.org/t/subplot-of-heatmap-in-plots/7207/2 "2017-11-21T01:45:56Z")

</div>

It is hard to guess what you want without some sort of example involving runnable code. I think that I have guessed what you want and I have tried my best below. The basic idea is that you can make an array of plots called `ps` which you then splat into the `plot` command.

```julia
using Plots; gr()
nimages = 9

a = [rand(50, 50) for _ in 1:nimages]
ps = []
for i in 1:nimages
     push!(ps, heatmap(a[i]))
end

plot(ps..., layout=(3, 3))

```

---

<div class="post-metadata">

**Author:** ![babaq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/babaq/32/891_2.png) [@babaq](https://discourse.julialang.org/u/babaq)\
**Post date:** [November 21, 2017, 3:11am UTC](https://discourse.julialang.org/t/subplot-of-heatmap-in-plots/7207/3 "2017-11-21T03:11:08Z")

</div>

ok, it seems vector of images or cat(3,imgaes…) does’t map in subplot grid.

so i made each plot, and map it to subplot.

```plaintext
using Plots; pyplot()
plot(heatmap.(a,color=:gray,aspect_ratio=:equal,legend=false)...,layout=(3,4))

```

and it show this

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

1, it seems that the vector of plots are maped in subplot grid in row-wise manner, ie, a[1] is mapped in grid[1,1], a[2] in grid[1,2], etc. is there a way to mannully set which grid cell to place a subplot ,such as plot(…, gridcell= (1,3)) ?

2, i also want to hide the whole axis, or make the axis line as box enclose the plot area, and make the interval among subplot small, how to do that?

---

<div class="post-metadata">

**Author:** ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Post date:** [November 21, 2017, 6:58am UTC](https://discourse.julialang.org/t/subplot-of-heatmap-in-plots/7207/4 "2017-11-21T06:58:26Z")

</div>

For complex layouts, check [Layouts · Plots](http://docs.juliaplots.org/latest/layouts/)

---

<div class="post-metadata">

**Author:** ![babaq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/babaq/32/891_2.png) [@babaq](https://discourse.julialang.org/u/babaq)\
**Post date:** [November 21, 2017, 7:32pm UTC](https://discourse.julialang.org/t/subplot-of-heatmap-in-plots/7207/5 "2017-11-21T19:32:56Z")

</div>

by an example, i can get layout showing right subplot in gridcell, but some subplot axis line still shows which i want to eliminate by setting axis=nothing. how can i hide all axis stuff?

```plaintext
using Plots;pyplot()

a = [rand(20,20) for _ in 1:3]
p=plot(layout=grid(2,2),leg=false,axis=nothing)
for i=1:3
    plot!(p[i],a[i],seriestype=:heatmap,ratio=:equal)
end
p

```

and i got:

 ![image](https://global.discourse-cdn.com/julialang/original/3X/9/8/9881438033650af168eab228dd602f752a71ac71.png)

---

<div class="post-metadata">

**Author:** ![mkborregaard](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkborregaard/32/556_2.png) [@mkborregaard](https://discourse.julialang.org/u/mkborregaard)\
**Post date:** [November 21, 2017, 7:54pm UTC](https://discourse.julialang.org/t/subplot-of-heatmap-in-plots/7207/6 "2017-11-21T19:54:42Z")

</div>

Try `framestyle = :none` rather than `axis = nothing`.
