Timothée HENRY
Timothée HENRY

Reputation: 14614

Julia plot applies which function for colors?

When using the Plots.plot function in the case below, apparently the matrix m is taken as the colors, but also is not shown on every point. There seems to be a function applied to the values before it is displayed.

The matrix m has no value at 0 nor 1, but the image shows a lot of white areas... It seems to work out some kind of levels... How can I find out which function is used?

For example I would like to be able to use the data after that transformation.

# I define a matrix of 21 x 21 pixels
m = Float32[0.22 0.24 0.24 0.26 0.3 0.33 0.33 0.36 0.42 0.4 0.38 0.39 0.42 0.44 0.49 0.53 0.54 0.55 0.56 0.56 0.56; 0.23 0.24 0.25 0.29 0.32 0.36 0.39 0.41 0.44 0.42 0.41 0.44 0.45 0.46 0.54 0.59 0.61 0.61 0.59 0.58 0.58; 0.26 0.26 0.27 0.33 0.36 0.4 0.41 0.44 0.48 0.49 0.46 0.48 0.46 0.48 0.54 0.56 0.58 0.62 0.6 0.6 0.59; 0.27 0.28 0.32 0.36 0.4 0.41 0.44 0.46 0.47 0.47 0.46 0.48 0.46 0.5 0.54 0.57 0.56 0.61 0.6 0.58 0.57; 0.19 0.2 0.25 0.32 0.39 0.42 0.47 0.47 0.47 0.46 0.45 0.47 0.46 0.5 0.56 0.58 0.57 0.62 0.6 0.59 0.58; 0.2 0.2 0.24 0.32 0.34 0.36 0.39 0.42 0.47 0.48 0.46 0.47 0.45 0.49 0.56 0.57 0.6 0.63 0.58 0.59 0.59; 0.21 0.2 0.27 0.34 0.35 0.35 0.36 0.37 0.39 0.45 0.46 0.47 0.45 0.48 0.56 0.62 0.62 0.61 0.58 0.58 0.58; 0.23 0.24 0.31 0.35 0.36 0.38 0.37 0.38 0.38 0.4 0.44 0.45 0.47 0.47 0.55 0.64 0.58 0.58 0.58 0.58 0.57; 0.22 0.28 0.35 0.36 0.37 0.38 0.39 0.39 0.4 0.42 0.43 0.43 0.45 0.47 0.53 0.57 0.56 0.56 0.57 0.57 0.57; 0.21 0.28 0.34 0.36 0.37 0.38 0.39 0.41 0.42 0.42 0.44 0.45 0.45 0.49 0.51 0.54 0.56 0.56 0.56 0.56 0.56; 0.22 0.27 0.31 0.32 0.34 0.37 0.39 0.39 0.39 0.43 0.46 0.46 0.49 0.51 0.51 0.54 0.55 0.56 0.56 0.55 0.55; 0.23 0.27 0.3 0.31 0.33 0.35 0.38 0.38 0.39 0.44 0.46 0.49 0.51 0.5 0.52 0.53 0.55 0.56 0.56 0.56 0.56; 0.23 0.27 0.31 0.34 0.36 0.36 0.38 0.4 0.42 0.45 0.45 0.49 0.51 0.52 0.55 0.55 0.56 0.58 0.58 0.57 0.58; 0.26 0.32 0.35 0.36 0.36 0.36 0.4 0.44 0.47 0.47 0.47 0.49 0.51 0.54 0.56 0.58 0.58 0.58 0.59 0.58 0.57; 0.3 0.33 0.35 0.35 0.36 0.37 0.4 0.47 0.5 0.47 0.46 0.47 0.5 0.53 0.56 0.58 0.6 0.6 0.61 0.6 0.59; 0.31 0.35 0.36 0.36 0.37 0.4 0.44 0.48 0.49 0.46 0.45 0.45 0.5 0.55 0.58 0.6 0.62 0.62 0.61 0.6 0.58; 0.33 0.39 0.41 0.39 0.38 0.44 0.47 0.49 0.5 0.47 0.46 0.45 0.47 0.52 0.54 0.56 0.57 0.58 0.56 0.56 0.55; 0.33 0.4 0.42 0.45 0.46 0.48 0.49 0.5 0.51 0.48 0.46 0.45 0.46 0.49 0.54 0.56 0.56 0.59 0.6 0.59 0.57; 0.37 0.41 0.43 0.47 0.5 0.52 0.49 0.48 0.51 0.49 0.47 0.47 0.47 0.49 0.58 0.61 0.62 0.62 0.62 0.61 0.6; 0.4 0.43 0.47 0.49 0.49 0.51 0.49 0.48 0.51 0.49 0.48 0.49 0.46 0.51 0.59 0.59 0.6 0.6 0.59 0.59 0.59; 0.42 0.47 0.5 0.5 0.49 0.48 0.49 0.49 0.51 0.49 0.5 0.49 0.49 0.55 0.58 0.56 0.57 0.61 0.6 0.58 0.58]
    
using Plots
plot(1:21, 1:21, m)

enter image description here

Upvotes: 1

Views: 66

Answers (1)

Nils Gudat
Nils Gudat

Reputation: 13800

It looks like plot called with two vectors and a matrix produces a contour plot - so you'll get the same output from contour(1:21, 1:21, m).

If you want to get rid of the whitespace, use the fill = true keyword:

julia> plot(1:21, 1:21, m, fill = true) 

enter image description here

Upvotes: 2

Related Questions