I want to create a simple atlas composer map using PyQGIS3. My question is about atlas feature scale. I want to use this settings from image.

enter image description here

I know this select option but I don't know how to add some number percent for margin in first option ( layout.referenceMap().setAtlasScalingMode(QgsLayoutItemMap.Auto) )


Any idea how to do this in PyQGIS3?

1 Answer 1


Look at

layout.referenceMap().atlasMargin(QgsLayoutObject.OriginalValue) # Get current value.
# You can replace above QgsLayoutObject.OriginalValue with QgsLayoutObject.EvaluatedValue
# if using an expression instead of a fixed value
layout.referenceMap().setAtlasMargin(yourvalue) # Set current value
  • how to get scale number from atlas feature after this code ?
    – Mar
    May 27, 2020 at 7:24

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.