-
Notifications
You must be signed in to change notification settings - Fork 51
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
Feature Request: Permanent Tooltip / Annotate last datapoint #1244
Comments
Hi, I do something similar to what you request by filtering on the geom_text . I'm sharing an example just where the last point of each group is labelled with its value in case you find it useful. # example for showing how to annotate the last point
# data frame to illustrate the example
df2 = pd.DataFrame(data=[
['2024Q1', 'Sold', 4], ['2024Q1', 'InStock', 16], ['2024Q1', 'Arriving', 5],
['2024Q2', 'Sold', 8], ['2024Q2', 'InStock', 16], ['2024Q2', 'Arriving', 7],
['2024Q3', 'Sold', 12], ['2024Q3', 'InStock', 16], ['2024Q3', 'Arriving', 25]
], columns=['Quarter', 'Status', 'Units'])
# this is the quarter that will be annotated
last_quarter = '2024Q3'
p3 = (lp.ggplot(df2, lp.aes(x='Quarter', y='Units', colour='Status'))
+ lp.geom_point(shape=1, size=4)
+ lp.geom_line(size=1.3)
+ lp.geom_text(
data=df2[df2['Quarter'] == last_quarter],
mapping=lp.aes(label='Units', y='Units'), size=8, nudge_x=0.1, label_format="{d}", show_legend=False)
+ lp.theme_bw()) Cheers, |
Hi guys,
Geom "last only" is a surprising idea) We are planning to address this general topic with the help of layer annotation settings (see Annotating Charts). Layer annotations currently present to some extent in |
Hi all @syd-doyen 's answer is a good approach - I have not thought of using For bar plots I do the same and annotate on the highest y-axis coordinate. So @alshan 's solution with the labels is actually something I have not thought of either and might be helpful here in the future. With a surrogate field that is empty if not on the last x-axis datapoint, I can achieve what I basically want on my bar plots using the labels: The use case for me is definitely the annotation of the last element on the x-axis (x-axis = time component). For whatever reason, the people that I am creating these plots for have grown accustomed to having their plots annotated in specific places (usually the last data point on the x-axis) to quickly glance the most recent value. My plots usually make quite extensive use of the tooltips, hence, my initial suggestion to basically have a trigger that can be triggered to permanently show the tooltip of a given datapoint (i.e. when preparing a plot to be exported as an image). But it seems that the label functionality basically would solve this as well (same syntax as tooltips). So it appears having the labeling possibility for |
I'm not completely sure why |
Hi all
when exporting plots as static assets (such as PNG), tooltips are obviously no longer working. So sometimes it would be handy to automatically (based on provided mappings) annotate/label certain data points permanently. geom_text / geom_label would be potential options, however, this gets awfully complicated if you have for instance a line plot with various lines (just as an example).
I found this R ggplot package that somewhat overcomes this and somewhat does what I envision: https://cmap-repos.github.io/cmapplot/reference/geom_text_lastonly.html however, this does not completely solve all the issues.
Since we are already able to specify tooltips and format them to our preferences, wouldn't it be neat if we could have the already defined tooltip be permanently visible (without hovering) for a given x-axis datapoint (or automagically for "the first"/"the last" datapoint) if we either say so explicitely or call ".to_png()"?
The text was updated successfully, but these errors were encountered: