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

RendererSVG CSS 'white-space' property conflicts with default HTML CSS #14283

Copy link
Copy link
Closed
@aodin

Description

@aodin
Issue body actions

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.

matplotlib-whitespace-svg

Expected outcome

The SVG renderer should not set a CSS property that conflicts with default values.

matplotlib-whitespace-svg-expected

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

default_style = generate_css({

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.

    Type

    No type

    Projects

    No projects

    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.