add option to specify interval length and also add legend