# Why don't I get a matrix of colors instead of a vector?

**URL:** <https://discourse.julialang.org/t/why-dont-i-get-a-matrix-of-colors-instead-of-a-vector/64843>\
**Category:** New to Julia\
**Created:** [July 18, 2021, 3:10am UTC](https://discourse.julialang.org/t/why-dont-i-get-a-matrix-of-colors-instead-of-a-vector/64843 "2021-07-18T03:10:15Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![cybervigilante](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cybervigilante/32/26687_2.png) [@cybervigilante](https://discourse.julialang.org/u/cybervigilante)\
**Post date:** [July 18, 2021, 3:10am UTC](https://discourse.julialang.org/t/why-dont-i-get-a-matrix-of-colors-instead-of-a-vector/64843/1 "2021-07-18T03:10:15Z")

</div>

When I create four random colors, a and b show up as a row of four swatches  
But when I try to create a matrix [a;b], figuring four over and under, all I get is a vector row of eight swatches

What am I doing wrong?

a = [RGB(rand(),rand(),rand()) for x in 1:4]  
b = [RGB(rand(),rand(),rand()) for x in 1:4]

[a;b]

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

---

<div class="post-metadata">

**Author:** ![xiaodai](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/xiaodai/32/15937_2.png) [@xiaodai](https://discourse.julialang.org/u/xiaodai)\
**Post date:** [July 18, 2021, 3:25am UTC](https://discourse.julialang.org/t/why-dont-i-get-a-matrix-of-colors-instead-of-a-vector/64843/2 "2021-07-18T03:25:51Z")

</div>

Interesting. I also want to know, but I would’ve done

```julia
vcat(a, b)

```

or

```julia
transpose([a b])

```

or

```julia
reshape([a;b], 2, :)

```

---

<div class="post-metadata">

**Author:** ![kimikage](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kimikage/32/14534_2.png) [@kimikage](https://discourse.julialang.org/u/kimikage)\
**Post date:** [July 18, 2021, 4:00am UTC](https://discourse.julialang.org/t/why-dont-i-get-a-matrix-of-colors-instead-of-a-vector/64843/3 "2021-07-18T04:00:36Z")

</div>

This is a matter of Julia’s design, not a problem of colors.

```julia
julia> a = [1, 2, 3, 4]; b = [5, 6, 7, 8];

julia> [a; b]
8-element Vector{Int64}:
 1
 2
 3
 4
 5
 6
 7
 8

```

However, I don’t think it is useful to arrange the color swatches vertically.

---

<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 18, 2021, 6:52am UTC](https://discourse.julialang.org/t/why-dont-i-get-a-matrix-of-colors-instead-of-a-vector/64843/4 "2021-07-18T06:52:07Z")

</div>

To get a 2-row matrix from two vectors of reals one can do: `[a'; b']` for more general case you could use: `permutedims([a b])`

---

<div class="post-metadata">

**Author:** ![cybervigilante](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cybervigilante/32/26687_2.png) [@cybervigilante](https://discourse.julialang.org/u/cybervigilante)\
**Post date:** [August 1, 2021, 10:47pm UTC](https://discourse.julialang.org/t/why-dont-i-get-a-matrix-of-colors-instead-of-a-vector/64843/5 "2021-08-01T22:47:34Z")

</div>

Thanks. What is the apostrophe for? I haven’t seen that usage.

---

<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:** [August 1, 2021, 10:49pm UTC](https://discourse.julialang.org/t/why-dont-i-get-a-matrix-of-colors-instead-of-a-vector/64843/6 "2021-08-01T22:49:24Z")

</div>

Check the help:

```julia
help?> '
  A'
  adjoint(A)

  Lazy adjoint (conjugate transposition). Note that adjoint is applied recursively to elements.

  For number types, adjoint returns the complex conjugate, and therefore it is equivalent to the identity function for real    
  numbers.

  This operation is intended for linear algebra usage - for general data manipulation see permutedims.

```
