Description
Bug report
Bug summary
The CSS 'white-space' property was added to the SVG renderer by #13674. This property's value, however, conflicts with the default CSS white-space
value.
Code for reproduction
Create a basic plot and render it to SVG:
from matplotlib import pyplot
pyplot.plot([1, 2, 3, 4])
pyplot.savefig(
'example.svg',
format='svg'
)
Embed the saved SVG into an HTML file and view. Here is a gist with a full example https://gist.github.com/aodin/4292cfeabe9107d0fd7d15c79062bb22
Actual outcome
As you can see from the screenshot below, the white-space
property set by the SVG renderer affects the whole HTML page, overriding the default white-space
value.
Expected outcome
The SVG renderer should not set a CSS property that conflicts with default values.
The above image was made by changing the CSS property name to svg white-space
. I do not know any way to make the CSS properties set within the SVG to be non-global. Additionally, I do not see an easy way to change the default CSS properties set by
While it is possible to override the new value on the HTML page with * {white-space: normal !important;}
, this is a regressive override likely to cause additional CSS issues.
In the future, I ask that developers please consider the use case of embedding rendered SVG before altering CSS defaults.
Matplotlib version
- Operating system: macOS 10.14.4 (18E226)
- Matplotlib version: matplotlib==3.1.0
- Matplotlib backend (
print(matplotlib.get_backend())
): TkAgg - Python version: Python 3.7.3
Python was installed via the latest macOS installer. A virtualenv was created without site-packages and used to install matplotlib via pip install matplotlib