cphyc / matplotlib-label-lines

Label line using matplotlib.
MIT License
301 stars 28 forks source link

On slope alignments #9

Closed ClementPinard closed 3 years ago

ClementPinard commented 6 years ago

Hello, thanks for your repo, which made my life easier and my graph prettier :)

I encountered two problems with alignment with respect to line slope :

I encountered another problem that is related to the first point where we compute y based on x : when line is not valid for every x value (with vertical line for example, bust also more simply with lines with shorter lines than the longest). You check that x is within line range (here), but it conflict with the way you create x values implicitely as linspace from the whole ax range here I don't mind doing this simple x repartition, otherwise it would be very complicated to deal with all kinds of line supports, but maybe we can find the nearest x instead of erroring when not in range ?

cphyc commented 5 years ago

Hi, Thanks for the valuable feedback. There is definitely two issues here:

Unfortunately I won't have much time to do it myself, but I'm totally fine to accept PR(s) that would fix these issues!

cphyc commented 3 years ago

Hi @ClementPinard ,

I think the vertical case should be fixed now. Regarding the issue with noisy line, I think the easiest solution is to allow the user to override the rotation of the ticks so that they can manually set them. What do you think about this?

cphyc commented 3 years ago

Closing this for now, as the vertical alignment has been fixed (see https://github.com/cphyc/matplotlib-label-lines/blob/74eaa682aee9766b6e1bc063bf873e784721323f/labellines/core.py#L78).

Regarding the support for noisy line, that can be implemented if there is request for it (or better a PR!).