The code I am attaching here renders the wrong plot when knitted ("Tk.wrong.png", first plot here). However, if I run it as a standard R code, the rendered plot is