What function is used as arange
in Julia ? For example, if I want to manage the frequency of xticks
in my plots.
In Python it works like:xticks(arange(0, length(l_ticks)+1, 1))
.
Thanks in advance!
What function is used as arange
in Julia ? For example, if I want to manage the frequency of xticks
in my plots.
In Python it works like:xticks(arange(0, length(l_ticks)+1, 1))
.
Thanks in advance!
Check out range
. Example:
julia> range(0,2,step=1) |> collect
3-element Array{Int64,1}:
0
1
2
In most cases you won’t need the collect call, just using it here to display all values.
Note that you can also just write 0:1:2
(start:step:stop):
julia> 0:1:2 |> collect
3-element Array{Int64,1}:
0
1
2
It generates but the idea is just I wanted fewer xticks for example, what 0:2:24 |> collect
gives me even numbers. I need these numbers to be the xticks in the plot. However, it doesn’t work or it gives me dimension mismatched error. Below is simple data.
price = [7.33, 7.42, 6.14, 5.77, 6.07, 9.44, 12.69, 15.97, 29.27, 23.86, 20.13, 19.60, 19.45, 19.09, 19.55, 20.16, 22.47, 43.11, 52.85, 34.01, 32.00, 23.91, 15.55, 13.85]
x_ticks=["1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24"]
l_ticks=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]
plot(l_ticks,price);
You specify the tick locations separately from the x coordinates of the data (which have to match the actual data), something like
plot(1:length(price), price, ticks=1:4:24)
IIRC. There is also an xticks!
function.
And, of course, you can control x
and y
ticks independently:
julia> plot(rand(10),rand(10),xticks=0:0.2:1,xlims=(-0.5,1.5),yticks=0:0.5:1,ylims=(-2,2))
julia> savefig("./plot.png")
Thanks!