ArcGIS Pro 2.0 | How to Center labels?

2049
6
01-31-2018 07:25 AM
VincentLaunstorfer
Occasional Contributor III

Hi,

I made some automatic Python stacked labels but I am just looking at how to justify "Center" these labels. I cannot find the 'center' button in all the tabs! Any guess?

Thanks

0 Kudos
6 Replies
DanPatterson_Retired
MVP Emeritus

hmmm don't make maps much and label less, but let's see how pythonic Pro is in that regard

label = "hello"

frmt = "{!s:^15}\n{!s:^15}".format(label, "Vincent")

print(frmt)
     hello     
    Vincent    

So it 'label' were your field, then you just need the stuff to the right of the = sign

0 Kudos
VincentLaunstorfer
Occasional Contributor III

Tried it! But not luck. Nothing happened on the map.

0 Kudos
DanPatterson_Retired
MVP Emeritus

looks like an html designator for bold and italics... perhaps that is what you need for the labeling.

The formatting I send would require a 'print' which I guess labelling doesn't do..

But bookmark https://docs.python.org/3.6/library/string.html for working with strings in python 3.. it is a whole new world

VincentLaunstorfer
Occasional Contributor III

Tried to encapsulate the print statment but no luck. Stacked labels are not justified "Center"

It did not produced an error though!

0 Kudos
DanPatterson_Retired
MVP Emeritus

found it  Text Formatting tags

not there

but if this doesn't work...

a = 'hello'
a.center(10, " ")
'  hello   '

but  desperate times

def lbl(a, pad=10):
    """attempt to center"""
    sp = " "
    sides = (pad - len(str(a)))//2
    out = sp*sides + str(a) + sp*sides
    return out


lbl('hello')
'  hello  '‍‍‍‍‍‍‍‍‍‍
0 Kudos
DanPatterson_Retired
MVP Emeritus

strangely bumped in June?

0 Kudos