-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error on using add_vline with text annotation for data with date-time x axis #3065
Comments
Yep, definitely a bug! Thanks for the clear and reproducible report :) I'm not immediately clear why we need to compute the midpoint of anything here
(x|y)anchor attribute instead of trying to do math on the coordinates in the Python layer.
|
Hi @MR0205, If you're looking for a temporary workaround, you can get the annotation to work by converting your
|
@awrobel1 Thanks for your idea, I thought on using a rectangle as a replacement, where you would make both edges start at the limit of a single day. Not sure though that will completely imitate the vertical line, due to possible problem when zooming. |
Following this too! |
The above suggestion from @awrobel1 was great for me. In my case I simplified a tad with |
Yes, after looking into this a bit more, the implementation assumes the data are types that can have arithmetic performed on them. It needs to do this in order to compute where to put the annotation. This bug probably got through because to compute where an annotation is placed, it only needs to find the minimum, maximum or mean of the extreme coordinate values.
|
Hi all, I have a rather weird problem that might be connected to this issue. I deployed an app using streamlit (V'1.2.0') I use Plotly (V'5.3.1') to create a plot in the app. The plot is a timeline, and there is a vertical line in it. And then use this in Is this known? Not sure if helpful, but this would be the app: |
Hi @ClaudiaBehnke86, Not sure, but you might be having trouble with time zones? When you run time timestamp calculation I believe that its looking for the timestamp based on your current timezone. So locally, everything works intuitively, but when you host your code in the cloud you start running on a UTC server and the times all seem to jump. If this is the problem you just need to make sure to adjust your line based on the difference between your current time and UTC, by adding/subtracting milliseconds or using timezone aware times. Also, make sure your code can handle time shifts for daylight savings time if relevant! |
Yes, this makes a lot of sense :-D. Thanks for the hint! |
Thanks for this! I had the same issue and it worked for me! |
Hi, how can I do similar things when |
This is still a problem for all categorial data on the x axis. Is there any solution for when x are strings? |
Yup this is still a very real and weird problem because if you try to do the annotation within the add_vline arguments you'll get the exception:
but if you do it with an add_annotation function it works fine
|
Just got this exact error today, removing the annotation_text parameter works |
Same error! For both, |
Another solution is to add a box with a specific width: from datetime import timedelta
fig.add_vrect(
x0=epoch,
x1=epoch + timedelta(minutes=1),
annotation_text="Text laebel",
fillcolor=color,
line_width=2,
line_color=color,
) |
Got the same problem today as the one before using
|
Can confirm this problem. Is it planned to be fixed in any upcoming release? It's been around for a while ;) |
What happens if you convert the dates to UNIX timestamps? |
Oh gosh, I don’t think we want to recommend Unix timestamps… we’d need them to be in milliseconds, and quite likely this will give time zone problems due to our weird backward-compatibility hacks on the plotlyjs side |
I will try to test it on the week of the 11th of March as before I don't have time. I hope I will remember XD |
You're right, I've tried changing the datetime to a unix timestamp but the time zone is not kept, resulting in an offset on the vertical lines. |
Hi, I am trying to use the library for a simple visualisation for the first time, and I stumbled upon supposedly a bug trying to draw a vertical line with text annotation on a graph with a date-time x axis.
I get the following error message:
TypeError: unsupported operand type(s) for +: 'int' and 'str'
Could anyone please help me confirm that it is indeed a bug, my version is '4.14.1' ? Thank you.
The text was updated successfully, but these errors were encountered: