Labeling a line layer in QGIS with many features, not all labels can be drawn without overlapping. Best result in the sense to show as many labels as possible without overlap I got using Parallel mode with allowed positions above and below line, see screenshot:
As you can see, I have set a distance of 12 of the labels from the line. It would now be great to have at least two or three varying distances for the labels, than more labels could be placed. A workaraound would be to use a case when ... condition, like:
case when $id %5 = 0 then 20 when $id %4 = 0 then 15 (...) end
. However, this is not flexible at all:
Is there an option to allow QGIS to autonomously choose from e.g. two or three fixed distances (like: 5, 10, 15) in a way to automatically optimize label placement?
id
.case when id % 3 then array_get(@value_array, id % 3)
. This would mean every third label is at a set height, etc. (I'm not sure what the modulo operator is off the top of my head). Thinking about it, I guess this is only useful for evenly spaced labels.