Method for captioning plots `df.hvplot.caption()` or `hvplot.caption()`
I'm creating a explanatory visualization and it'd be awesome if hvplot had a caption method so you can do something like
df.hvplot.bar("date", "arr") * df_sum.hvplot.caption("Total ARR {arr} from {ini_date} to {end_date}")
Or even df.hvplot.bar("date", "arr", caption=f"Total ARR {arr} from {ini_date} to {end_date}", caption_loc="bottom_left")
Can you please define a bit more what you would expect to see on the plot when setting caption? I'd appreciate it if you could provide links to HoloViews to see what feature we'd need to expose in hvPlot, and if not already supported in HoloViews, to Bokeh and Matplotlib docs.
Oops, missed this in the pile of GitHub notifications about locked issues.
Perhaps this should be first implemented in HoloViews, e.g. hv.Title(loc=...)
https://docs.bokeh.org/en/latest/docs/user_guide/basic/annotations.html#labels
That does this in Bokeh:
from bokeh.models import Title
from bokeh.plotting import figure, show
p = figure(title="Left Title", title_location="left",
width=300, height=300)
p.scatter([1, 2], [3, 4])
# add extra titles with add_layout(...)
p.add_layout(Title(text="A caption about life and such\nLong caption", align="left"), place="below")
show(p)
And this in matplotlib (focus only on the bottom left caption):
import matplotlib.pyplot as plt
fig, ax = plt.subplots(figsize=(3, 3))
# main title on the left (like title_location="left")
ax.set_title("Left Title", loc="left")
# scatter plot
ax.scatter([1, 2], [3, 4])
# add caption below the plot
fig.text(
0.1, -0.05, # (x, y) in figure coordinates, can be tuned
"A caption about life and such\nLong caption",
ha="left", va="top"
)
plt.show()
Yes these notifications are wild! I think @hoxbro has a bot or something to clear them automatically. He has a bot or script for everything ;)
Ok thanks I understand better what you mean:
- As far as hvPlot is concerned, I don't really think that should be a plot method but simply exposed as an option
caption=.... - Let's open an issue for HoloViews (I'd prefer if this was a plot option rather than a element, not a fan of having to deal with overlays for simply adding a caption)