3

I am having trouble with the following plot:

enter image description here

created by the following code:

fig, ax = plt.subplots(figsize=(10, 6), dpi=80)
texts = []
for i, data_col in enumerate(data.columns.values):
    ax.plot(data.index, data[data_col], color=tableau20[i], label=data_col)
    texts.append(ax.text(max(data.index), data[data_col][-1], data_col, fontsize=11, color=tableau20[i]))

This is actually very close to the desired output, I am looking for a way to automatically adjust only the y-Position of the text so there will be no overlapping even if the values are changing (so no hard coded offset) What I found is the well working adjustText package from @Phlya, however I don't get the this solution to only adjust the y position, it will always shift the text on the x axis as well.

So this is the output I get with adding the line

adjust_text(texts, ax=ax, only_move=dict(points='y', text='y', objects='y'), autoalign='y')

enter image description here

is there a way to adjust the functions settings or any other way to achieve what i am looking for?

1

0

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.