1

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

5
  • So, you want your segment width to be always 100 m, and automatically change the number of segments?
    – Erik
    Nov 19 '21 at 12:33
  • No, I want the width of the scale bar to be fixed. The internal ticks (segments) of it will need to change to fit to the scale and show two segments for example.
    – GeorgeC
    Nov 19 '21 at 12:36
  • Then choose "fixed segment width" and lower and upper boundary so it fits your possible scales.
    – Erik
    Nov 19 '21 at 12:38
  • I have tried this -it controls the segments / ticks within the bar and not the width of the bar. It is the width between the segments. I need to control the width of the bar.
    – GeorgeC
    Nov 19 '21 at 12:43
  • What scales did you try, and which lower and upper segment widths?
    – Erik
    Nov 19 '21 at 12:47
4

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.

5
  • Great. With 1 - the length I used works for 1:5k, 10k and 15k but not 1:2500 scale. It goes out of the page as in the example. I am using 2 segments only. Can we just set a max width for the bar so that it changes but just doesn't get wider than this value? RE 2 - I tried this but it just prints every page at the defined scales and doesn't just do each page at the defined scale for it. 3 is not an option for my use case.
    – GeorgeC
    Nov 19 '21 at 13:12
  • You mean you use the option 1. Wich size did you set as upper and lower limit for segment width ? If i did calculated well then your scale bar size in the example is 6,666 mm. If you set the size of segment to be between 6 and 8 mm then your scale bar will not be bigger than 2x 8 mm + margin and text. Nov 19 '21 at 13:20
  • I mean I want to find an option that works and I was just mentioning the issues I have with them. Lets focus on #1. I tried these settings but the scale bar becomes too small. I am in EPSG 28355. if this changes anything.
    – GeorgeC
    Nov 19 '21 at 13:31
  • 1
    @GeorgeC I have updated my answer for the solution 1, but it would give you a scale bar that could be between 15 mm and 25 mm... If you really want your scale bar to get no variation then set the two number at the same value (you can calculate the scale bar length in mm that would fit all your used scale) and do solution 2. For your CRS, as the unit is meter it is fine. Nov 19 '21 at 18:05
  • 1
    Thanks for this excellent answer! I just went through this last week and it took me forever to get my head around how it works. I think the confusion for me was “Fit Segment width” which would make more sense as “Fit Segments Within” and then “min width” and “max width”
    – Baswein
    Nov 20 '21 at 23:03

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.