-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
SVG backend is assigning same id to clipPath elements #4349
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
Comments
|
Isn't this more like a namespace collision issue? The files by themselves
|
@WeatherGod I would phrase it this way: Figures with the same content share the same id, so if you have two or more figures with the same content in the same document, then you're going to have the issue described previously. On the contrary, if you have two figures with different content (e.g. histogram and bar plot), they won't share the same ids and the issue will be avoided even if they are in the same document. |
Under certain conditions the ``id`` of the `clipPath` node emitted by the svg writer will be the same for multiple files. If both svg fragments are embedded in the same document, then one of them is removed, the clipping of the remaining fragment can become inconsistent. See ipython/ipython#8133 Closes matplotlib#4349
@moble originally reported the following bug in the ipython repository, but it is related to the manipulation of SVGs in matplotlib:
If you create a simple HTML file with a couple of SVG elements:
and then using the developer tools in Chrome, you delete one of the images and zoom in (or zoom out), the remaining image has a problem with the clipping paths:
Before deleting image:
After deleting image and zooming in:
The reason is that both figures share the same
id
attribute in theirclipPath
elements. This is the same issue that @moble found after plotting a couple of matplotlib figures and then removing or hiding one of them. Matplotlib currently assign the sameid
to theirclipPath
elements for figures that have the same content in its _make_id method and this causes tricky bugs in the browser.Essentially, Firefox and Chrome behave differently depending on the complexity of the figure but this can be solved by assigning different ids to the
clipPath
elements in matplotlib (which is good practice anyway.)I was suggesting to add a random value before generating ids (but maybe your tests are relying on the current behavior in some way).
The text was updated successfully, but these errors were encountered: