Note that you can manipulate the limits of the plot via xlims!
.
Assuming that we are talking about the cars
dataset from the RDatasets.jl package, I notice that the maximum value of cars.Speed
, which I think is your X
, is indeed 25
.
julia> using Plots, RDatasets
julia> cars = dataset("datasets", "cars");
julia> X = cars.Speed; Y = cars.Dist;
julia> maximum(X)
25
plot(cars.Speed, cars.Dist, seriestype=:scatter)
Another way of doing this would be to use StatsPlots.jl:
julia> using StatsPlots
julia> @df cars scatter(:Speed, :Dist)
After looking at your notebook, I believe that X
and Y
are in fact Speed
and Dist
.
https://github.com/CBrauer/Pluto-Notebook/blob/a8bfad434f46541a48c07657568d96df4af0b8d0/SmoothingSplineNotebook.jl#L30-L31
Now if you just want to plot X
and Y
against the numbers 1 through 50, you coul do the following.
julia> begin
plot(Y, seriestype=:scatter, label="Y");
plot!(X, seriestype=:scatter, label="X");
end
The above would yield the following which goes out to 50.
You could achieve the same plot by explicitly providing 1:50
.
julia> begin
plot(1:50, Y, seriestype=:scatter, label="Y");
plot!(1:50, X, seriestype=:scatter, label="X");
end
Better yet, you could extract the row numbers directly rather than hard coding thme.
julia> begin
rownumbers = parentindices(cars)[1]
plot(rownumbers, Y, seriestype=:scatter, label="Y");
plot!(rownumbers, X, seriestype=:scatter, label="X");
end
I’m not sure exactly where the point of confusion is, but I’ll try to summarize.
- You are plotting
Dist
versus Speed
.
maximum(cars.Speed)
is 25
. Thus the plot only extends to 25
.
- If you want to plot
Dist
and Speed
versus their Row
number, you can do this by plotting each as their own series. This works by either omitting the x-coordinate values, explicitly hard coding them, or gleaning them from the data frame.