This question already has an answer here:

I am trying to render the layer in QGIS as a map using python console. I am using QgsComposerLegend() for drawing the legend in the map.

Is it possible to make the layer name hidden in the map legend using python console?

marked as duplicate by mgri, Vince, whyzar, PolyGeo Jul 9 '17 at 23:05

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.