The expression
height - 'posxy'[1]
Would evaluate to
height - 'o'
hence the error you are seeing.
According to the documentation, positions
will be a dictionary {node: posxy, ...}
.
posxy
is a tuple, e.g. (1, 2)
, which is immutable, so you can't simply assign to one of the values (e.g. posxy[1] = ...
); you will get a an error here too:
TypeError: 'tuple' object does not support item assignment
Instead, process all of them, creating a new tuple for each position using e.g. a dictionary comprehension:
positions = {k: (v[0], height - v[1]) for k, v in positions.items()}