QGIS Atlas – How to Fix Scale Bar Width for Different Scales

atlasprint-composerqgis

Following on from Setting Atlas scale and scale bar for each map to round number using QGIS

When we set the scale bar to work correctly at one scale and then the atlas cycles through other scales you end up with it looking like below at some scales.

enter image description here

Is it possible to fix the width and allow the internal ticks to automatically update and NOT CHANGE the width?
enter image description here

I am using QGIS 3.22

Best Answer

You have two option to create a scale bar

What you do "normally" you fix the width of your segment in your map unit according to the scale you use and to have easy to use number "25 / 50 / 75 /100". If your map scale change your scale bar length in the print composer.

OR

You can set the segment size in your layout, this is the Fit segment width option. If you set it to be 50 mm long in your layout no matter the scale used then you will get value that are not "round" (see picture below) that will be difficult to use for the map user and ugly (my opinion)

enter image description here

To do it better you have three different solutions :

  1. let the scale bar size change a bit. You set the segment width to be between two length that could fit in your layout. In my example I choose between 40 and 60 mm. All your pages will have approximately the same scale bar length (+ - 10 mm). enter image description here
  2. fix your map scale. You set your map to be controlled by atlas but not the option get margin around feature but use the predefined scale (best fit) option. Then set your predefined scale to match most atlas page.
  3. fake the round number. If you want no change in the scale used in the map neither to change the scale bar size then you can customize format number to round it. Warning this would be fake value. Go to Item properties of you scale bar, then Units and Customize. Below it is the 39,05 rounded to get only one significant number. enter image description here

UPDATE FOR YOUR USE CASE

To use the solution number 1 you have to set the two values in yellow. The one in the top is used as the minimal dimension of a segment in your layout and the one below is the maximal size for your segment.

enter image description here

In your screenshot, we see that your legend element is 20 mm long. As you have two segments, the max size for each segment should be 10 and the minimal size should be 6 mm to keep segment visible. QGIS will choose the segment size to get a round number to show in map unit.

Related Question