Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

[Bug]: Incorrect rendering of Abugida fonts on Matplotlib visualization #29357

Open
Assignees
QuLogic
Milestone
@nik9hil

Description

@nik9hil

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.

image

The issue seems to lie only within the plot and is correctly rendered outside the plot in other Jupyter notebook output cells. I have importedNoto Serif Devanagari Thin of format ".ttf" in the font_manager of matplotlib.

Code for reproduction

#-------------------------------------Importing font file--------------------------------------------importmatplotlib.pyplotaspltfrommatplotlibimportfont_managerfont_path=r'../NotoSerifDevanagari-Thin.ttf'#Font Download URL https://fonts.google.com/noto/specimen/Noto+Serif+Devanagarifont_manager.fontManager.addfont(font_path)prop=font_manager.FontProperties(fname=font_path)plt.rcParams['font.family']='sans-serif'plt.rcParams['font.sans-serif']=prop.get_name()#---------------------------------------Printing the Heatmap------------------------------------------cols= ['कंऊ','कंकन','कंकाल','कंग','कंगण','कंगणयाठ','कंगणा','कंगणी','कंगणु','कंगयारी','कंगर','कंगरमाला','कंगला','कंगाळ','कंगावणो','कंगियारी','कंगूरा','कंगोयर','कंगड़ोणा','कंघू']importseabornassnsdistances= [[1.00000012,0.07712191,0.14661103,-0.04143704,0.53648712,0.33697583,0.53648712,0.51686014,0.38120874,0.50693332,0.45912105,0.39092736,0.37029334,0.48355384,0.08494762,0.2027287 ,0.22532   ,-0.13099329,0.21541182,0.2619344 ],       [0.07712191,1.        ,0.27505046,0.02465715,0.19377662,0.1261098 ,0.19377662,0.1506419 ,0.35335953,0.20175425,0.24165124,0.28307295,0.16849031,0.0239366 ,0.07874829,0.13574625,0.20279602,0.13992496,0.07440536,0.29719737],       [0.14661103,0.27505046,1.        ,-0.04620013,0.33248773,0.15105981,0.33248773,0.22782895,0.32314968,0.16231962,0.33643136,0.33366867,0.06132669,0.00628519,0.31157723,0.32549456,0.24985954,0.08681663,-0.0043968 ,0.30289415],       [-0.04143704,0.02465715,-0.04620013,1.        ,-0.03092548,0.06609477,-0.03092548,-0.13675212,-0.02324197,-0.24876945,-0.19765455,-0.09264191,0.10586093,-0.03386144,-0.07041141,-0.16070572,-0.11320979,0.05005207,0.06435453,-0.04384374],       [0.53648712,0.19377662,0.33248773,-0.03092548,1.        ,0.29916139,1.        ,0.65163825,0.72046704,0.55254239,0.57694138,0.62017921,0.42146252,0.40582417,0.13931256,0.42310567,0.34080061,0.02983071,0.21334639,0.47694966],       [0.33697583,0.1261098 ,0.15105981,0.06609477,0.29916139,1.        ,0.29916139,0.54745869,0.28604334,0.39199968,0.36999825,0.2213295 ,0.26273593,0.39979477,0.15303509,0.33649553,0.09807743,0.05601585,0.2305386 ,0.40991256],       [0.53648712,0.19377662,0.33248773,-0.03092548,1.        ,0.29916139,1.        ,0.65163825,0.72046704,0.55254239,0.57694138,0.62017921,0.42146252,0.40582417,0.13931256,0.42310567,0.34080061,0.02983071,0.21334639,0.47694966],       [0.51686014,0.1506419 ,0.22782895,-0.13675212,0.65163825,0.54745869,0.65163825,1.        ,0.71716835,0.63264708,0.62838955,0.47028607,0.33207874,0.47275523,0.16827085,0.50378844,0.26850763,-0.06614359,0.25800855,0.56002025],       [0.38120874,0.35335953,0.32314968,-0.02324197,0.72046704,0.28604334,0.72046704,0.71716835,1.        ,0.50603543,0.5059674 ,0.52531186,0.29890772,0.30439026,0.31332371,0.46341207,0.33670898,0.1210591 ,0.1456821 ,0.45291205],       [0.50693332,0.20175425,0.16231962,-0.24876945,0.55254239,0.39199968,0.55254239,0.63264708,0.50603543,1.        ,0.55836697,0.25994718,0.31039424,0.36613216,0.24675051,0.465611  ,0.23443568,0.01218331,0.37018659,0.45373405],       [0.45912105,0.24165124,0.33643136,-0.19765455,0.57694138,0.36999825,0.57694138,0.62838955,0.5059674 ,0.55836697,1.        ,0.44948247,0.25360835,0.39044196,0.23445548,0.59344035,0.56251523,-0.01464187,0.22015723,0.61909768],       [0.39092736,0.28307295,0.33366867,-0.09264191,0.62017921,0.2213295 ,0.62017921,0.47028607,0.52531186,0.25994718,0.44948247,1.        ,0.3531896 ,0.22887981,0.06463467,0.3665741 ,0.42415992,0.08162159,0.08619286,0.39534383],       [0.37029334,0.16849031,0.06132669,0.10586093,0.42146252,0.26273593,0.42146252,0.33207874,0.29890772,0.31039424,0.25360835,0.3531896 ,1.        ,0.76107077,-0.00676973,0.24680215,0.09632001,0.00772719,0.178872  ,0.29167667],       [0.48355384,0.0239366 ,0.00628519,-0.03386144,0.40582417,0.39979477,0.40582417,0.47275523,0.30439026,0.36613216,0.39044196,0.22887981,0.76107077,1.        ,0.00392713,0.17269458,0.0984515 ,-0.09089949,0.12039699,0.30054512],       [0.08494762,0.07874829,0.31157723,-0.07041141,0.13931256,0.15303509,0.13931256,0.16827085,0.31332371,0.24675051,0.23445548,0.06463467,-0.00676973,0.00392713,1.00000012,0.31029389,0.00211672,0.10704701,0.04611979,0.17345914],       [0.2027287 ,0.13574625,0.32549456,-0.16070572,0.42310567,0.33649553,0.42310567,0.50378844,0.46341207,0.465611  ,0.59344035,0.3665741 ,0.24680215,0.17269458,0.31029389,1.        ,0.40896827,0.10605786,0.21322685,0.62610233],       [0.22532   ,0.20279602,0.24985954,-0.11320979,0.34080061,0.09807743,0.34080061,0.26850763,0.33670898,0.23443568,0.56251523,0.42415992,0.09632001,0.0984515 ,0.00211672,0.40896827,1.        ,0.08140745,0.10477526,0.31258686],       [-0.13099329,0.13992496,0.08681663,0.05005207,0.02983071,0.05601585,0.02983071,-0.06614359,0.1210591 ,0.01218331,-0.01464187,0.08162159,0.00772719,-0.09089949,0.10704701,0.10605786,0.08140745,1.        ,0.00525283,0.08305563],       [0.21541182,0.07440536,-0.0043968 ,0.06435453,0.21334639,0.2305386 ,0.21334639,0.25800855,0.1456821 ,0.37018659,0.22015723,0.08619286,0.178872  ,0.12039699,0.04611979,0.21322685,0.10477526,0.00525283,1.        ,0.08586092],       [0.2619344 ,0.29719737,0.30289415,-0.04384374,0.47694966,0.40991256,0.47694966,0.56002025,0.45291205,0.45373405,0.61909768,0.39534383,0.29167667,0.30054512,0.17345914,0.62610233,0.31258686,0.08305563,0.08586092,1.        ]]fig,ax=plt.subplots(figsize=(20,20))s=sns.heatmap(distances,square=True,annot=True,cbar=False,cmap='Blues',ax=ax)s.set_yticklabels(cols)s.set_xticklabels(cols)hfont= {'fontname':'Helvetica'}plt.xlabel('Words',**hfont)plt.ylabel('Words',**hfont)plt.xticks(rotation=90)plt.yticks(rotation=0)plt.rcParams.update({'font.size':20})plt.show()

Actual outcome

image

Expected outcome

In 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.

Additional information

I 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.

Operating system

Windows

Matplotlib Version

3.4.3

Matplotlib Backend

module://matplotlib_inline.backend_inline

Python version

3.9.7

Jupyter version

6.4.5

Installation

pip

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp