You only have to use a global variable which will keep track of the new worms, and to which you will refer for plotting.
As we do not have a full example of your code, I am just going to write something that plausibly mimics what you should do:
breed [animals animal]
globals [
cumulative-worms
]
; **************************
; The rest of your code here
; **************************
to get-infected ; The procedure executed by animals when they get new worms.
let new-worms (1 + random 5)
set worm-number (worm-number + new-worms)
set cumulative-worms (cumulative-worms + new-worms)
end
At this point you can just create a plot where you will use plot cumulative-worms
.