Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Bug]: Plot directive clutters the output directory with unneeded files #24005

Copy link
Copy link
Open
@MikhailRyazanov

Description

@MikhailRyazanov
Issue body actions

Bug summary

Using the Matplotlib plot directive in Sphinx documentation results in cluttering the output directory with all the produced image files in all generated formats even when they are not needed (plot_html_show_formats = False). This is especially obvious with the singlehtml builder, where all the necessary images must be inside the _images subdirectory, but in fact, in addition to _images, the whole directory tree with every image in every format is copied to the output directory, although nothing of it is referenced from the HTML file.

What is more interesting, if another builder is executed first, then its cached images are reused properly — only the necessary files are copied into _images, without cluttering the output directory with unneeded files and subdirectories.

Code for reproduction

See a minimal working example at https://github.com/MikhailRyazanov/plot-clutter.

Actual outcome

From step 1 of the example above:

$ tree build/singlehtml
build/singlehtml
├── _images
│   ├── index-1.svg
│   ├── other-1.svg
│   └── script.svg
├── index-1.pdf
├── index-1.svg
├── index.html
├── objects.inv
├── _static
│   <skipped>
└── subdir
    ├── other-1.pdf
    ├── other-1.svg
    ├── script.pdf
    └── script.svg

Expected outcome

From step 2 of the example above:

build/singlehtml
├── _images
│   ├── index-1.svg
│   ├── other-1.svg
│   └── script.svg
├── index.html
├── objects.inv
└── _static
    <skipped>

Additional information

In practice, this undesired behavior directly affects the downloadable documentation at Read the docs — see issue #9068 there.

Operating system

No response

Matplotlib Version

3.5.2

Matplotlib Backend

No response

Python version

No response

Jupyter version

No response

Installation

Linux package manager

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.