Is a graphic that shows mainly code a listing or a figure?
It' s a figure. Without the graphical elements, it is not comprehensible any more. A listing could be formated in other ways without changing the meaning, but changing the graphical elements would change the meaning.