edited barplot r function to optionally produce figure, wrapper is buggy