I’ve been enjoying the captions for Plot charts, allowing for a description to be connected to a visual, making it easier to move around a notebook as a collective piece. Was experimenting with a way to add a chart title to a Plot chart and wondering if there’s a good way to do this. I’ve seen @Fil address this, and it looks like plot titles has a long standing discussion. Jumping in on this I spose.
Below I have a mark that puts title text in the top left, but any y-axis label will be above the title. Is is possible to use a text mark to place text, above everything else? Is it possible to place text with Plot in relation to the full visual, not just the plot frame? Thanks!
// custom mark for adding a title at the top of a Plot
function titleMark(text, options = {}) {
const defaultOptions = {
frameAnchor: "top-left",
dy: -15,
fontSize: 16,
fontWeight: "bold",
lineAnchor: "bottom",
};
const opts = { ...defaultOptions, ...options };
return Plot.text([text], {
...opts,
text: (d) => d,
});
}
Always learning,
Zach