Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Bug]: Nondeterminism in SVG clipPath element id attributes #27831

Closed
@jayaddison

Description

@jayaddison

Bug summary

Hello - I'm trying to make the astroplan documentation build reproducibly in Debian, and have found a snag: despite configuring the svg.hashsalt to successfully make path identifiers in some SVG plots generated by matplotlib deterministic, there is a remaining problem that clipPath identifiers are nondeterministic.

The cause appears to be the use of Python object ID (via id(...) calls here) when generating clippath IDs.

Code for reproduction

import matplotlib as mpl
import matplotlib.pyplot as plt
import sys

mpl.rcParams["svg.hashsalt"] = "fixed-salt"

fig = plt.gcf()
fig.add_subplot(projection="polar")

plt.savefig(sys.stdout.buffer, format="svg")

Actual outcome

Differences appear in the clipPath identifiers and their references from elsewhere in the SVG output.

Expected outcome

When an svg.hashsalt value is configured, the SVG output should be deterministic.

Additional information

This could arguably be an enhancement request rather than a bug.

Configuring a static PYTHONHASHSEED value does not help to produce deterministic results.

Operating system

Debian GNU/Linux (trixie)

Matplotlib Version

3.6.3

Matplotlib Backend

TkAgg

Python version

Python 3.11.8

Jupyter version

N/A

Installation

Linux package manager

Metadata

Metadata

Assignees

No one assigned

    Labels

    Difficulty: Mediumhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issuesGood first issueOpen a pull request against these issues if there are no active ones!backend: svgstatus: confirmed bug

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions