Title: [Bug]: Saving as an SVG and PDF produce different outputs with Latex characters, with wrong character sizing · Issue #29791 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: Saving as an SVG and PDF produce different outputs with Latex characters, with wrong character sizing · Issue #29791 · matplotlib/matplotlib
X Title: [Bug]: Saving as an SVG and PDF produce different outputs with Latex characters, with wrong character sizing · Issue #29791 · matplotlib/matplotlib
Description: Bug summary When saving certain outputs using Latex rendering as an SVG, it produces wrong outputs. Using plt.show() it renders correctly, and it works for saving as a PDF, but saving the output as a SVG math environment characters can r...
Open Graph Description: Bug summary When saving certain outputs using Latex rendering as an SVG, it produces wrong outputs. Using plt.show() it renders correctly, and it works for saving as a PDF, but saving the output as...
X Description: Bug summary When saving certain outputs using Latex rendering as an SVG, it produces wrong outputs. Using plt.show() it renders correctly, and it works for saving as a PDF, but saving the output as...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/29791
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: Saving as an SVG and PDF produce different outputs with Latex characters, with wrong character sizing","articleBody":"### Bug summary\n\nWhen saving certain outputs using Latex rendering as an SVG, it produces wrong outputs. Using plt.show() it renders correctly, and it works for saving as a PDF, but saving the output as a SVG math environment characters can render in the wrong size (see attached screenshots.) \n\n### Code for reproduction\n\n```Python\nfrom pathlib import Path\nimport pandas as pd\nimport matplotlib.pyplot as plt\nimport scienceplots\n\n\nBASE_PATH = Path(__file__).parent\nDATA_PATH = BASE_PATH / \"ion_ranges.csv\"\n\n\nplt.style.use(['science', 'latex-siunitx'])\n\ndat = pd.read_csv(DATA_PATH)\n\nplt.plot(dat[\"energy\"], dat[\"projected_range_um\"], marker=\"o\", linestyle=\"-\")\nplt.xlabel(\"Energy (keV)\")\nplt.ylabel(r\"Projected Range (\\si{\\um})\")\nplt.tight_layout()\nplt.savefig(BASE_PATH / \"ion_ranges_plot.pdf\")\n```\n\n### Actual outcome\n\n\n\n### Expected outcome\n\n[ion_ranges_plot.pdf](https://github.com/user-attachments/files/19395486/ion_ranges_plot.pdf)\n\n\n\n\n### Additional information\n\n_No response_\n\n### Operating system\n\n_No response_\n\n### Matplotlib Version\n\n3.10.1\n\n### Matplotlib Backend\n\n_No response_\n\n### Python version\n\n_No response_\n\n### Jupyter version\n\n_No response_\n\n### Installation\n\nNone","author":{"url":"https://github.com/jamesmeiklejohn","@type":"Person","name":"jamesmeiklejohn"},"datePublished":"2025-03-21T18:43:11.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/29791/matplotlib/issues/29791"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:d2c0bdcc-8686-54a9-2593-a41b04bdd99c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C0FA:2FD3E:FE2531:1529740:6A529858 |
| html-safe-nonce | da0d5ae50e596a802f4a6132ae51b064b6032dbe0b9a669e32f9708a3166f9b3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMEZBOjJGRDNFOkZFMjUzMToxNTI5NzQwOjZBNTI5ODU4IiwidmlzaXRvcl9pZCI6IjEyMjYwNjAxMjY1MTcxMDY3NzYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 174fad68f01030276ba40cdb5ba61ec91b61fe183d21c04ea994f5df43a65380 |
| hovercard-subject-tag | issue:2939227011 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/matplotlib/matplotlib/29791/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1ec61ce155793f3be03566d255db8add71422d85a99f5fe1be0bf72173c010f4/matplotlib/matplotlib/issues/29791 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1ec61ce155793f3be03566d255db8add71422d85a99f5fe1be0bf72173c010f4/matplotlib/matplotlib/issues/29791 |
| og:image:alt | Bug summary When saving certain outputs using Latex rendering as an SVG, it produces wrong outputs. Using plt.show() it renders correctly, and it works for saving as a PDF, but saving the output as... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jamesmeiklejohn |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | canary-1 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width