I've set my custom grid in the print layout. The problem is, that in one corner both values from X and Y axes overlap each other.
I used the offset, as you can see below, but I am wondering how to make this only one value offset more than the rest.
I found some similar problems here:
Stop Grid Coordinates Overlapping in Print Layout
which led me to the bug here:
https://github.com/qgis/QGIS/issues/45876
My formula for custom grids looks like this:
CASE
WHEN @grid_axis = 'y'
THEN substr('ABCDEFGHIJKLMNOPQRST', (@grid_number +105) / 100, 1)
WHEN @grid_axis = 'x'
THEN round((@grid_number - 5) / 100,0)
END
And I obviously can change it simultaneously with the offset bringing them up, although I tried the solution, which would led offset just only the first value at the Y axis.
The formula I prepared looks like this:
CASE
WHEN @grid_axis = 'y' AND @grid_number = 'A' THEN offset = 15
END
but it stays as it is despite lack of error in the formula.
How can I offset only this one value separately?
Regarding my situation with interval 100 and offset 7 I tried also:
CASE
WHEN @grid_axis = 'y' AND substr('ABCDEFGHIJKLMNOPQRST', (@grid_number = 0) / 100, 1) THEN OFFSET = 15
END
UPDATE:
I think the problem lies with the "Distance to the map frame" issue. As I set it to 5mm then the overlapping occurs. What kind of formula should I place inside then?
I could reduce the distance from the map frame, although with the font size I applied (24px) it still won't work.
Best Answer
After some experimentation it appears that the distance to frame cannot be set independently for the X and Y axes.
Here is my label grid set up. I chose
Outside frame
for the labels so there were legible.Using a
Distance to frame
of 5 mm and the formula:to show the grid axis and grid number in the label itself so there can be no confusion.
Then for
Distance to frame
I used the formulaBoth sets of labels end up at 0 mm distance.
A formula using
@grid_number
Separate note about one of your formulae
The
@grid_number
is never going to beA
, so this formula, despite having no errors, will not evaluate. The@grid_number
is always an integer and it is tied to the grid interval. The first grid square contains 100 grid numbers for each axis (1-100, 100 being your interval in mm). As seen in the image directly above, the displayed grid number for this particular set of labels is the interval0, 100, 200, etc
+ the offset6
for the x axis and +7
for the y axis. The rest of the grid numbes still exist, but they just have no label.