Skip to content
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

Automatic figure captioning for both static and interactive plots #1401

Open
TK-21st opened this issue Jul 22, 2021 · 1 comment
Open

Automatic figure captioning for both static and interactive plots #1401

TK-21st opened this issue Jul 22, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@TK-21st
Copy link

TK-21st commented Jul 22, 2021

Is your feature request related to a problem? Please describe.

For notebooks with a large number of plots that are a mix between matplotlib figures
and bokeh/plotly interactive plots, it would be great if we can support captioning
and automatic numbering of the captions for all the plots in a notebook.

Currently, I'm adding the following metadata to code-cell generating matplotlib figure

{
    "render": {
        "figure": {
            "caption": "<b>Figure 1</b> My Caption.",
            "name": "fig1"
        }
    }
}

This will have a caption added on the bottom as described here.

However, there are 2 issues with this current solution (1 is an issue, the other is more like an incovenience):

  1. The same metadata does not work for interactive plots generated by Bokeh/Plotly
  2. The figure number <b>Figure 1</b> has to be hard coded into the caption, where it would be GREAT if it could be automatically generated (like in latex's figure environment)

Describe the solution you'd like

I'm not sure how to get the caption to work with interactive plots but the same API could suffice.

As per automating this process assuming that caption works for both static/interactive plots, here are some ideas:

  1. It would be great to support cell metadata tag like figure. In absence of any further metadata configuration, at compile time, this tag will generate the following metadata for the figure:
{
    "figure-index": 1,
    "render": {
        "figure": {
            "caption": "", 
            "name": "fig$figure-index" # I'm not sure how this could work in JSON schema but the idea is to reference figure index
        }
    }
}

which can be rendered into the caption

Figure 1 # with id fig1

Unless manually specified by the user, figure-index metadata is calculated by looking through all cells that has tag figure.

If additional metadata is specified, like

{
    "render": {
        "figure": {
            "caption": "My Caption.",
            "name": "my-figure-name"
        }
    }
}

then the rendered caption is
which can be rendered into the caption

Figure 1: My Caption # now with id my-figure-name

  1. An even stronger automation of the suggestion above will to be support a notebook level configuration that automatically detect all figures (static or interactive) and assign figure tag to those cells.

Describe alternatives you've considered

The current solution to the problem is to manually add a new code cell below the previous code cell and type in the caption, but this really isn't a solution.

Additional context

Add any other context or screenshots about the feature request here.

@TK-21st TK-21st added the enhancement New feature or request label Jul 22, 2021
@welcome
Copy link

welcome bot commented Jul 22, 2021

Thanks for opening your first issue here! Engagement like this is essential for open source projects! 🤗

If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.

If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).

Welcome to the EBP community! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant