My Pluto notebook is not Reactive

Hey Guys,

I tried my first attempt at a Pluto Notebook, and I have a concern.

But first, here is my environment:

  1. I’m running on Windows 11, latest build (version 22H2)
  2. Julia 1.8.5
  3. Google Chrome

I have put the Notebook on my GitHub REPO at:

Shown below is a plot that shows my concern. The data is X=50, Y=50, and the plot stops after 25. Why?

Any suggestion will be greatly appreciated.


I find the same behavior, but I think the reason is simply that the constructed X vector has a maximum value of 25. You can see this by running maximum(X).

The size function just tells you what are the dimensions of the array. So size(X) == (50,) indicates that X is a one-dimensional array with 50 elements.

To see if the “reactivity” of Pluto is working correctly, you can try modifying some prior cell defining X, Y, or the model, and see if the plot changes accordingly.

As a side note, you may want to take advantage of Pluto’s built-in package environment manager. This would let you run the using commands without needing to import Pkg and install them. Note that when you import Pkg as done here, this will install the packages in your global environment. This may lead to difficulties down the line when you want to work with a different set of packages. You can see more about Julia’s package environment manager here and here.


Thank you for your reply. I did as you suggested, and I printed out maximum(X). I got 50. It’s the number of rows in the “cars” dataset.

The plot only shows a range of about 25. This is very discouraging.

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)

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.

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");

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");

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");

I’m not sure exactly where the point of confusion is, but I’ll try to summarize.

  1. You are plotting Dist versus Speed.
  2. maximum(cars.Speed) is 25. Thus the plot only extends to 25.
  3. 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.

Thank you for your excellent explanation. I get it now!