Title: [Bug]: Incorrect rendering of Abugida fonts on Matplotlib visualization · Issue #29357 · matplotlib/matplotlib · GitHub
Open Graph Title: [Bug]: Incorrect rendering of Abugida fonts on Matplotlib visualization · Issue #29357 · matplotlib/matplotlib
X Title: [Bug]: Incorrect rendering of Abugida fonts on Matplotlib visualization · Issue #29357 · matplotlib/matplotlib
Description: Bug summary While trying to plot a heatmap, with labels in Devanagari script, I observe that words with vowel markers that come before the consonant are being rendered incorrectly in the plot. The issue seems to lie only within the plot ...
Open Graph Description: Bug summary While trying to plot a heatmap, with labels in Devanagari script, I observe that words with vowel markers that come before the consonant are being rendered incorrectly in the plot. The ...
X Description: Bug summary While trying to plot a heatmap, with labels in Devanagari script, I observe that words with vowel markers that come before the consonant are being rendered incorrectly in the plot. The ...
Opengraph URL: https://github.com/matplotlib/matplotlib/issues/29357
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[Bug]: Incorrect rendering of Abugida fonts on Matplotlib visualization","articleBody":"### Bug summary\n\nWhile trying to plot a heatmap, with labels in Devanagari script, I observe that words with vowel markers that come before the consonant are being rendered incorrectly in the plot. \r\n\r\n\u003cimg width=\"281\" alt=\"image\" src=\"https://github.com/user-attachments/assets/3d5c2fbb-5fb7-4b4e-a7a7-ebf53a72cd49\" /\u003e\r\n\r\nThe issue seems to lie only within the plot and is correctly rendered outside the plot in other Jupyter notebook output cells. I have imported _**Noto Serif Devanagari Thin**_ of format \"_**.ttf**_\" in the font_manager of matplotlib. \n\n### Code for reproduction\n\n```Python\n#-------------------------------------Importing font file--------------------------------------------\r\nimport matplotlib.pyplot as plt\r\nfrom matplotlib import font_manager\r\n\r\nfont_path = r'../NotoSerifDevanagari-Thin.ttf' #Font Download URL https://fonts.google.com/noto/specimen/Noto+Serif+Devanagari\r\nfont_manager.fontManager.addfont(font_path)\r\nprop = font_manager.FontProperties(fname=font_path)\r\n\r\nplt.rcParams['font.family'] = 'sans-serif'\r\nplt.rcParams['font.sans-serif'] = prop.get_name()\r\n\r\n\r\n#---------------------------------------Printing the Heatmap------------------------------------------\r\n\r\ncols = ['कंऊ', 'कंकन', 'कंकाल', 'कंग', 'कंगण', 'कंगणयाठ', 'कंगणा', 'कंगणी',\r\n 'कंगणु', 'कंगयारी', 'कंगर', 'कंगरमाला', 'कंगला', 'कंगाळ',\r\n 'कंगावणो', 'कंगियारी', 'कंगूरा', 'कंगोयर', 'कंगड़ोणा', 'कंघू']\r\n\r\nimport seaborn as sns\r\n\r\ndistances = [[ 1.00000012, 0.07712191, 0.14661103, -0.04143704, 0.53648712,\r\n 0.33697583, 0.53648712, 0.51686014, 0.38120874, 0.50693332,\r\n 0.45912105, 0.39092736, 0.37029334, 0.48355384, 0.08494762,\r\n 0.2027287 , 0.22532 , -0.13099329, 0.21541182, 0.2619344 ],\r\n [ 0.07712191, 1. , 0.27505046, 0.02465715, 0.19377662,\r\n 0.1261098 , 0.19377662, 0.1506419 , 0.35335953, 0.20175425,\r\n 0.24165124, 0.28307295, 0.16849031, 0.0239366 , 0.07874829,\r\n 0.13574625, 0.20279602, 0.13992496, 0.07440536, 0.29719737],\r\n [ 0.14661103, 0.27505046, 1. , -0.04620013, 0.33248773,\r\n 0.15105981, 0.33248773, 0.22782895, 0.32314968, 0.16231962,\r\n 0.33643136, 0.33366867, 0.06132669, 0.00628519, 0.31157723,\r\n 0.32549456, 0.24985954, 0.08681663, -0.0043968 , 0.30289415],\r\n [-0.04143704, 0.02465715, -0.04620013, 1. , -0.03092548,\r\n 0.06609477, -0.03092548, -0.13675212, -0.02324197, -0.24876945,\r\n -0.19765455, -0.09264191, 0.10586093, -0.03386144, -0.07041141,\r\n -0.16070572, -0.11320979, 0.05005207, 0.06435453, -0.04384374],\r\n [ 0.53648712, 0.19377662, 0.33248773, -0.03092548, 1. ,\r\n 0.29916139, 1. , 0.65163825, 0.72046704, 0.55254239,\r\n 0.57694138, 0.62017921, 0.42146252, 0.40582417, 0.13931256,\r\n 0.42310567, 0.34080061, 0.02983071, 0.21334639, 0.47694966],\r\n [ 0.33697583, 0.1261098 , 0.15105981, 0.06609477, 0.29916139,\r\n 1. , 0.29916139, 0.54745869, 0.28604334, 0.39199968,\r\n 0.36999825, 0.2213295 , 0.26273593, 0.39979477, 0.15303509,\r\n 0.33649553, 0.09807743, 0.05601585, 0.2305386 , 0.40991256],\r\n [ 0.53648712, 0.19377662, 0.33248773, -0.03092548, 1. ,\r\n 0.29916139, 1. , 0.65163825, 0.72046704, 0.55254239,\r\n 0.57694138, 0.62017921, 0.42146252, 0.40582417, 0.13931256,\r\n 0.42310567, 0.34080061, 0.02983071, 0.21334639, 0.47694966],\r\n [ 0.51686014, 0.1506419 , 0.22782895, -0.13675212, 0.65163825,\r\n 0.54745869, 0.65163825, 1. , 0.71716835, 0.63264708,\r\n 0.62838955, 0.47028607, 0.33207874, 0.47275523, 0.16827085,\r\n 0.50378844, 0.26850763, -0.06614359, 0.25800855, 0.56002025],\r\n [ 0.38120874, 0.35335953, 0.32314968, -0.02324197, 0.72046704,\r\n 0.28604334, 0.72046704, 0.71716835, 1. , 0.50603543,\r\n 0.5059674 , 0.52531186, 0.29890772, 0.30439026, 0.31332371,\r\n 0.46341207, 0.33670898, 0.1210591 , 0.1456821 , 0.45291205],\r\n [ 0.50693332, 0.20175425, 0.16231962, -0.24876945, 0.55254239,\r\n 0.39199968, 0.55254239, 0.63264708, 0.50603543, 1. ,\r\n 0.55836697, 0.25994718, 0.31039424, 0.36613216, 0.24675051,\r\n 0.465611 , 0.23443568, 0.01218331, 0.37018659, 0.45373405],\r\n [ 0.45912105, 0.24165124, 0.33643136, -0.19765455, 0.57694138,\r\n 0.36999825, 0.57694138, 0.62838955, 0.5059674 , 0.55836697,\r\n 1. , 0.44948247, 0.25360835, 0.39044196, 0.23445548,\r\n 0.59344035, 0.56251523, -0.01464187, 0.22015723, 0.61909768],\r\n [ 0.39092736, 0.28307295, 0.33366867, -0.09264191, 0.62017921,\r\n 0.2213295 , 0.62017921, 0.47028607, 0.52531186, 0.25994718,\r\n 0.44948247, 1. , 0.3531896 , 0.22887981, 0.06463467,\r\n 0.3665741 , 0.42415992, 0.08162159, 0.08619286, 0.39534383],\r\n [ 0.37029334, 0.16849031, 0.06132669, 0.10586093, 0.42146252,\r\n 0.26273593, 0.42146252, 0.33207874, 0.29890772, 0.31039424,\r\n 0.25360835, 0.3531896 , 1. , 0.76107077, -0.00676973,\r\n 0.24680215, 0.09632001, 0.00772719, 0.178872 , 0.29167667],\r\n [ 0.48355384, 0.0239366 , 0.00628519, -0.03386144, 0.40582417,\r\n 0.39979477, 0.40582417, 0.47275523, 0.30439026, 0.36613216,\r\n 0.39044196, 0.22887981, 0.76107077, 1. , 0.00392713,\r\n 0.17269458, 0.0984515 , -0.09089949, 0.12039699, 0.30054512],\r\n [ 0.08494762, 0.07874829, 0.31157723, -0.07041141, 0.13931256,\r\n 0.15303509, 0.13931256, 0.16827085, 0.31332371, 0.24675051,\r\n 0.23445548, 0.06463467, -0.00676973, 0.00392713, 1.00000012,\r\n 0.31029389, 0.00211672, 0.10704701, 0.04611979, 0.17345914],\r\n [ 0.2027287 , 0.13574625, 0.32549456, -0.16070572, 0.42310567,\r\n 0.33649553, 0.42310567, 0.50378844, 0.46341207, 0.465611 ,\r\n 0.59344035, 0.3665741 , 0.24680215, 0.17269458, 0.31029389,\r\n 1. , 0.40896827, 0.10605786, 0.21322685, 0.62610233],\r\n [ 0.22532 , 0.20279602, 0.24985954, -0.11320979, 0.34080061,\r\n 0.09807743, 0.34080061, 0.26850763, 0.33670898, 0.23443568,\r\n 0.56251523, 0.42415992, 0.09632001, 0.0984515 , 0.00211672,\r\n 0.40896827, 1. , 0.08140745, 0.10477526, 0.31258686],\r\n [-0.13099329, 0.13992496, 0.08681663, 0.05005207, 0.02983071,\r\n 0.05601585, 0.02983071, -0.06614359, 0.1210591 , 0.01218331,\r\n -0.01464187, 0.08162159, 0.00772719, -0.09089949, 0.10704701,\r\n 0.10605786, 0.08140745, 1. , 0.00525283, 0.08305563],\r\n [ 0.21541182, 0.07440536, -0.0043968 , 0.06435453, 0.21334639,\r\n 0.2305386 , 0.21334639, 0.25800855, 0.1456821 , 0.37018659,\r\n 0.22015723, 0.08619286, 0.178872 , 0.12039699, 0.04611979,\r\n 0.21322685, 0.10477526, 0.00525283, 1. , 0.08586092],\r\n [ 0.2619344 , 0.29719737, 0.30289415, -0.04384374, 0.47694966,\r\n 0.40991256, 0.47694966, 0.56002025, 0.45291205, 0.45373405,\r\n 0.61909768, 0.39534383, 0.29167667, 0.30054512, 0.17345914,\r\n 0.62610233, 0.31258686, 0.08305563, 0.08586092, 1. ]]\r\n\r\nfig, ax = plt.subplots(figsize=(20, 20))\r\n\r\ns = sns.heatmap(distances, square=True, annot=True, cbar=False, cmap='Blues', ax=ax)\r\n\r\ns.set_yticklabels(cols)\r\ns.set_xticklabels(cols)\r\n\r\nhfont = {'fontname':'Helvetica'}\r\nplt.xlabel('Words', **hfont)\r\nplt.ylabel('Words', **hfont)\r\n\r\nplt.xticks(rotation=90)\r\nplt.yticks(rotation=0) \r\n\r\nplt.rcParams.update({'font.size': 20})\r\nplt.show()\n```\n\n\n### Actual outcome\n\n\u003cimg width=\"386\" alt=\"image\" src=\"https://github.com/user-attachments/assets/757f182d-bcbd-4f7c-805a-8aa3fc66fd0e\" /\u003e\r\n\n\n### Expected outcome\n\nIn the expected outcome, the highlighted label in the bug summary image should be rendered as **_कंगियारी_**. In the current output it is being rendered like कंगयिारी which is wrong.\n\n### Additional information\n\nI observe that words with vowel markers that come before the consonant are being rendered incorrectly in the plot. This makes me believe that this might be due to some old font engine which is being used in matplotlib to render Unicode characters. \n\n### Operating system\n\nWindows\n\n### Matplotlib Version\n\n3.4.3\n\n### Matplotlib Backend\n\nmodule://matplotlib_inline.backend_inline\n\n### Python version\n\n3.9.7\n\n### Jupyter version\n\n6.4.5\n\n### Installation\n\npip","author":{"url":"https://github.com/nik9hil","@type":"Person","name":"nik9hil"},"datePublished":"2024-12-20T12:23:05.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/29357/matplotlib/issues/29357"}
| 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:17f809aa-11f2-0180-5c7e-224b0bd33b15 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D174:B0958:28F8AD0:3647D63:6A521653 |
| html-safe-nonce | a2dd5bac520328910097020e7e3bd08ce3ee36e1d1b62b52b099413611e77886 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMTc0OkIwOTU4OjI4RjhBRDA6MzY0N0Q2Mzo2QTUyMTY1MyIsInZpc2l0b3JfaWQiOiI1MDQyNTk4OTcxMjAxMzQ3MzkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | feff2e44b15a857159dd0a8803a03f0b28cb254543c341c1e5ae237abc35e721 |
| hovercard-subject-tag | issue:2752633741 |
| 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/29357/issue_layout |
| twitter:image | https://opengraph.githubassets.com/347e91231d5051556edae309311c91ee01d22e4dc01467b33bdf972400458159/matplotlib/matplotlib/issues/29357 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/347e91231d5051556edae309311c91ee01d22e4dc01467b33bdf972400458159/matplotlib/matplotlib/issues/29357 |
| og:image:alt | Bug summary While trying to plot a heatmap, with labels in Devanagari script, I observe that words with vowel markers that come before the consonant are being rendered incorrectly in the plot. The ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | nik9hil |
| 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 | 7aed05249554b889eb33d002851a973eebcc7e91 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width