# How to print a vector as a column vector?

**URL:** https://discourse.julialang.org/t/how-to-print-a-vector-as-a-column-vector/67291
**Category:** General Usage
**Tags:** io
**Created:** [August 29, 2021, 4:14pm UTC](https://discourse.julialang.org/t/how-to-print-a-vector-as-a-column-vector/67291 "2021-08-29T16:14:12Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![qdmj](https://avatars.discourse-cdn.com/v4/letter/q/eb9ed0/32.png) [@qdmj](https://discourse.julialang.org/u/qdmj)
#### Post date: [August 29, 2021, 4:14pm UTC](https://discourse.julialang.org/t/how-to-print-a-vector-as-a-column-vector/67291/1 "2021-08-29T16:14:12Z")

</div>

In REPL, I can call

```julia
a = [1,2]

```

to get

> 2-element Vector{Int64}:  
> 1  
> 2

However, when I run a script and call

```julia
print(a)

```

, I can just get

> [1, 2]

as an row vector.

Then is there a method to get a column vector as output when running a script?

---

<div class="post-metadata">

### Author: ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)
#### Post date: [August 29, 2021, 4:26pm UTC](https://discourse.julialang.org/t/how-to-print-a-vector-as-a-column-vector/67291/2 "2021-08-29T16:26:43Z")

</div>

All julia vectors are “column vectors”, as julia is column major. The `,` in `[1, 2]` indicates that this is a column vector. A “row vector” (which doesn’t exist in julia) would be printed like `[1 2]`:

```julia
julia> a = [1 2]  
1×2 Matrix{Int64}:
 1 2             
                  
julia> print(a)   
[1 2]             

```

The real question is though, what do you want to do with that representation?

---

<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: [August 29, 2021, 4:27pm UTC](https://discourse.julialang.org/t/how-to-print-a-vector-as-a-column-vector/67291/3 "2021-08-29T16:27:17Z")

</div>

> [@How to repeat the format in @printf?](https://discourse.julialang.org/t/how-to-repeat-the-format-in-printf/66695):
>
> Sorry for another stupid question. Not proud of asking these kind questions sweat_smile. I am sure it is stupid, however I searched google and stack overflow but still not sure how to do this. The question is very simply, using Printf @printf("%9.3f %9.3f %9.3f %9.3f",1.0,2.0,3.0,4.0) I need to display 4 numbers from 1.0 to 4.0 for example. Now, do I have to manually put %9.3f for four times in the fmt? In Fortran I can do things like 4(9.3f) So that I do not need to put 9.3f 4 times. I…

I think this thread exhausted all alternatives

---

<div class="post-metadata">

### Author: ![qdmj](https://avatars.discourse-cdn.com/v4/letter/q/eb9ed0/32.png) [@qdmj](https://discourse.julialang.org/u/qdmj)
#### Post date: [August 29, 2021, 4:40pm UTC](https://discourse.julialang.org/t/how-to-print-a-vector-as-a-column-vector/67291/4 "2021-08-29T16:40:31Z")

</div>

When debugging, I have to print some vectors. Sometimes the entries of the vector are quite long and I think it is hard to see it visually.

---

<div class="post-metadata">

### Author: ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)
#### Post date: [August 29, 2021, 6:46pm UTC](https://discourse.julialang.org/t/how-to-print-a-vector-as-a-column-vector/67291/5 "2021-08-29T18:46:04Z")

</div>

> [@qdmj](#):
>
> `print(a)`

try `display(a)` ?

---

<div class="post-metadata">

### Author: ![Paul\_Soderlind](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paul_soderlind/32/1753_2.png) [@Paul\_Soderlind](https://discourse.julialang.org/u/Paul_Soderlind)
#### Post date: [August 29, 2021, 6:58pm UTC](https://discourse.julialang.org/t/how-to-print-a-vector-as-a-column-vector/67291/6 "2021-08-29T18:58:23Z")

</div>

I am sure there are many ways, but let me just suggest two (both will do the job)

1. You could use [https://github.com/ronisbr/PrettyTables.jl](https://github.com/ronisbr/PrettyTables.jl)

or

1. just grab the `printmat.jl` file from my github page [https://github.com/PaulSoderlind/JuliaTutorial/tree/master/jlFiles](https://github.com/PaulSoderlind/JuliaTutorial/tree/master/jlFiles)
