Better solution for updating layout with dynamic dict keys?

The original method to update layout works. How can I change key (yaxis3) dynamically? I tried the following methods.
Method A:

Method B: # this doesn’t work
n_trace = 3
fig[“layout”].update([(f"yaxis{n_trace}", dict(overlaying=“y1”))])

Method C:
def trans(input_str):
return input_str
n_trace = 3
fig[“layout”].update({trans(f"yaxis{n_trace}"): dict(overlaying=“y1”)})

Method C works. But, is there any better solution?

1 Like

Method C is definitely a lifesaver!