Moved plotting to a function, added html index generation