import numpy as np
import matplotlib.pyplot as plt
import sys

interval = (1, 4)  # start, end
if len(sys.argv) > 2:
    interval = (float(sys.argv[1]), float(sys.argv[2]))

accuracy = 0.0001
reps = 600  # number of repetitions
numtoplot = 200
lims = np.zeros(reps)

fig, biax = plt.subplots()
fig.set_size_inches(16, 9)

lims[0] = np.random.rand()
for r in np.arange(interval[0], interval[1], accuracy):
    for i in range(reps-1):
        lims[i+1] = r*lims[i]*(1-lims[i])

    biax.plot([r]*numtoplot, lims[reps-numtoplot:], 'b.', markersize=.02)

biax.set(xlabel='r', ylabel='x', title='logistic map')
plt.show()
