I have been trying to create and export multiple graphs using the following code, instead I am getting a single graph that essentially does what I want but crams all my graphs into one:

Code:
local variables a b c d e f

foreach x in `variables'{
gr hbar `x', over(year) by(treat) title("fancy title") ytitle ("Years")
gr export "$graphdir/`x'.png", replace
}
Instead of creating individual graphs I am getting one big graph with all my variables. Is there anyway to split this within the loop? Is there anyway of affixing what Nick Cox said in this post to my code https://www.statalist.org/forums/for...s-using-a-loop?

Thanks in advance!

Lorien