When we want to plot a series of points we simply write:
points = rand(10000) scatter(points)
this assumes a
y = rand(10000) and
x = 1:10000. From the Official documentation - Argument Passing Behavior
Julia function arguments follow a convention sometimes called “pass-by-sharing”, which means that values are not copied when they are passed to functions.
I know that in this case the variable
points is not copied when passed to
Now consider having a 2×500 Array of points, i.e., 500 points in a 2D space. For this case, the scatter plot requires you to pass both x and y series separately. We usually do this by writing
scatter(points[1, :], points[2, :])
In this case
points[1, :] and
points[2, :] are copies of each row of
points that are created before being passed to the function. A way to prevent this is
scatter(view(points, 1, :), view(points, 2, :))
but it is a bit verbose, is there a way to achieve the same behavior without calling view?