GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — svg backend truncates output size to integer, which it doesn't need to (and pdf backend doesn't) · Issue #9815 · matplotlib/matplotlib

svg backend truncates output size to integer, which it doesn't need to (and pdf backend doesn't) #9815

New issue
Copy link
New issue
Copy link
Closed
#9817
Closed
svg backend truncates output size to integer, which it doesn't need to (and pdf backend doesn't)#9815
#9817
Copy link
Labels
backend: svg
Milestone
v2.2.0

Description

@anntzer
anntzer
opened on Nov 19, 2017
Issue body actions

Bug report

Bug summary

For vector backends, it should be acceptable for the output canvas to have a noninteger size. Indeed, the pdf backend will output canvas with noninteger sizes "as is". On the other hand, the svg backend truncates the output to the integer below, which it doesn't need to do.

Code for reproduction

gcf(); savefig("/tmp/foo.pdf"); savefig("/tmp/foo.svg")

and examine foo.pdf and foo.svg with a plain text viewer.

Actual outcome

foo.pdf contains the line

/MediaBox [ 0 0 460.8 345.6 ] /Parent 2 0 R /Resources 8 0 R /Type /Page >>

(460.8 is 6.4 inches at 72dpi, 345.6 is 4.8 inches at 72 dpi).

foo.svg contains the line

<svg height="345pt" version="1.1" viewBox="0 0 460 345" width="460pt" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">

so the SVG was truncated. Note that interestingly, the SVG also contains e.g.

   <path d="M 0 345.6 
L 460.8 345.6 
L 460.8 0 
L 0 0 
z
" style="fill:#ffffff;"/>

i.e. some paths that overflow the SVG canvas.

I believe it is just as valid for the SVG output to use noninteger sizes (at least, manually editing the file doesn't make inkscape complain).

Expected outcome

SVG backend should not crop the output size.

Matplotlib version

  • Operating system: N/A
  • Matplotlib version: 2.1/master
  • Matplotlib backend (print(matplotlib.get_backend())): SVG
  • Python version: N/A
  • Jupyter version (if applicable): N/A
  • Other libraries: N/A

Activity

  1. anntzer
    added
    backend: svg
    on Nov 19, 2017
  2. tacaswell
    added this to the This milestone has been deleted milestone on Nov 19, 2017
  3. tacaswell commented on Nov 19, 2017

    @tacaswell
    tacaswell
    on Nov 19, 2017
    Member
    More actions

    It appears have been this way since at least 2005 but see no reason for it to be so.

  4. tacaswell
    added a commit that references this issue on Nov 19, 2017

    API: do not truncate the total size of svg element to integers

    This issue will close once commit f435941 is merged into the 'main' branch.
    f435941
  5. anntzer
    closed this as completedin #9817on Nov 20, 2017
  6. QuLogic
    modified the milestones: This milestone has been deleted, v2.2.0 on Feb 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    backend: svg

    Type

    No type

    Projects

    No projects

      Milestone

      • v2.2.0

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.