I have an mxd with three data frames. I've written a python script that loops through a list of user-specified coordinates and scales for each data frame before exporting the mxd as a pdf.

Is there a way to "turn off" one of the data frames using python? (e.g. set data frame 1's visibility to False leaving just data frames 2 and 3 visible). The best idea I can come up with is to move data frames off screen when they're not needed and bring them back when they are.


On/off doesn't appear to be an option with a data frame. Moving the frame off the document would work with elementPositionX and elementPositionY. Shrinking the frame to zero is an option as well.

Initial code from python shell in ArcMap:

>>> mxd = arcpy.mapping.MapDocument("CURRENT")
>>> df = arcpy.mapping.ListDataFrames (mxd) [0]
>>> height = df.elementHeight
>>> width = df.elementWidth

Data frame off:

>>> df.elementHeight = 0
>>> df.elementWidth = 0

Data frame on:

>>> df.elementHeight = height
>>> df.elementWidth = width
  • Cheers Emil! I thought it might not be possible as I couldn't see anything about it anywhere. I think the data frame size option you mentioned sounds like the best workaround as it would also mean any extent rectangles in other data frames would also disappear. – davehughes87 Dec 15 '15 at 16:38
  • Thinking about it, the only issue I see with the shrink method is it may create a single pixel on your map if the data frame has a border. Let us know if it does. – Emil Brundage Dec 15 '15 at 17:07
  • I'll give it a go over the next few days - will keep you posted. Ta! – davehughes87 Dec 15 '15 at 21:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.