Reputation: 1187
I am new to Julia. While trying out examples online, I got to the plot below:
using Plots
# 10 data points in 4 series
xs = range(0, 2π, length = 10)
data = [sin.(xs) cos.(xs) 2sin.(xs) 2cos.(xs)]
# We put labels in a row vector: applies to each series
labels = ["Apples" "Oranges" "Hats" "Shoes"]
# Marker shapes in a column vector: applies to data points
markershapes = [:circle, :star5]
# Marker colors in a matrix: applies to series and data points
markercolors = [
:green :orange :black :purple
:red :yellow :brown :white
]
plot(
xs,
data,
label = labels,
shape = markershapes,
color = markercolors,
markersize = 10
)
The Problem I am facing is at the beginning. Even if I try below alone on REPL
julia> xs = range(0, 2π, length = 10)
I receive the error below:
ERROR: MethodError: no method matching range(::Int64, ::Float64; length=10)
Closest candidates are:
range(::Any; length, stop, step) at range.jl:76
Stacktrace:
[1] top-level scope at none:0
Did I forget to include some Package?
Upvotes: 3
Views: 193
Reputation: 4370
Which version of Julia are you using? It sounds like you are using a version that is older than the tutorial you are reading. I can verify that range(0, 2π, length = 10)
yields 0.0:0.6981317007977318:6.283185307179586
on Julia 1.5 and Julia 1.6, even without specifying stop
Upvotes: 5
Reputation: 1187
I guess I should have made more research before posting. it's an error in the original post I guess.
I should have used:
julia> xs = range(0, stop=2π, length = 10)
0.0:0.6981317007977318:6.283185307179586
No more errors!!
It's weird, I am following official tutorial... :((
Upvotes: 2