Homepage

Grid plot in Julia

Posted on November 15, 2022  •  1 minutes  • 181 words

After deciding that I should get more used to program in Julia, this is one of my first attempts: A grid plot a.k.a. an old time favorite in spatial stats. All the steps to end up with the expected results are:

  1. Installing Julia (I alredy had done that)
  2. Finding an IDE: Visual Studio.
  3. Inspecting commands like: typeof()
  4. Installing some packages.
  5. Finding out which package to use to open a matlab file (data here).
  6. Learning some characteristics of Julia, for example, how it completes matrices. I needed this in order to present a vector in “the right form”.
  7. Using the required function to plot the grid.

My code is here:

vars = matread("/Desktop/R0_time2.mat") # This is a dictionary
m = vars["R0_time2"]; # This is a matrix
vals = m[1, :]; # The feature I want to plot is in one row
vals2 = reshape(vals,18,18)'
d = [];
for i in 1:18
    j = 19-i
    d = vcat(d,vals2[j,:])
end 
e = Vector{Float64}(d) # I had to assing this type in order to plot with viz.
grid = CartesianGrid(18, 18)
viz(grid, color=e)

The plot:

Follow me

Let's connect 👩🏽‍💻