7

I read the: "Subscript labels in QGIS legends" thread.
I would like to follow up on this for nautical notations.

One Z-value, when displayed, must be displayed in normal script and subscript.
For example: If you want to display the value 9,3 it is supposed to be displayed in the nautical notation as: normal script: 9 subscript: 3

Is there a way to format the label of the value in this manner? Note that heights above datum have an underscore under the whole digits.

how i display it now[![][1]]2

0

4 Answers 4

4

I solved it like this.
It's not elegant, but it works.
The label displays a value called "VALSOU"

  • Set labels to "rule based"
  • Made two labels: 1 called "whole", 1 called "decimal"
  • no expressions set as rule
  • text for label "whole":
    if(to_int( "VALSOU") > "VALSOU",(to_int( "VALSOU") -'1'),to_int("VALSOU"))
    This killed of the decimal from the whole number. I added the -1 because the [to_int(] rounds of the number. Without it 5.6 becomes 6 and then I'm off by a meter in my chart.

  • text for label "decimal":

    CASE
    WHEN to_int("VALSOU")>"VALSOU" THEN to_int(("VALSOU"-(to_int("VALSOU")-'1'))'10')
    WHEN to_int("VALSOU")< "VALSOU" THEN to_int(("VALSOU" - (to_int("VALSOU")))
    '10')
    END

This killed of the whole number and displays the decimal as a whole number.

After this it's a matter of changing the position of the label "whole" and "decimal" relative to the geometry and eachother. the end result

4

Progressing from Albert's comment if you separate the whole and decimal numbers as separate attributes you can duplicate the layer and have both parts as font markers which will allow you to colour via depth

Depth soundings colour gradient by depth

Select the 'Assistant' from the fill color options

Font marker popup

Select required colour ramp

Colour Assistant popoup

3

One idea would be creating a point layer of your labels. The regular underlined value would be a label and the subscript could be a font marker. You can create an expression in Character(s) to input the desired value.

Moving your anchor points of the font marker:

enter image description here

and the quadrant placement of your label:

enter image description here

can create the effect of a subscript. The following image has been made using this method.

enter image description here

1

Have a look at the Python custom expression functions in this answer: Achieving Super or Subscript graticule labels in QGIS Composer windows?

They will allow this labelling style to be achieved without involving multiple components to the label and fiddling with offsets.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.