Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7765024

Browse files
committed
FIX: try more reliable way to get string length
Fixed width byte/unicode dtypes seem to have the pattern "[|<>][US][1-9][0-9]*" thus if we drop the first two charters we will have the fixed width.
1 parent 0cb2c3a commit 7765024

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/matplotlib/mlab.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3188,7 +3188,8 @@ def get_justify(colname, column, precision):
31883188
ntype = column.dtype
31893189

31903190
if np.issubdtype(ntype, str) or np.issubdtype(ntype, bytes):
3191-
length = max(len(colname), len(column[0]))
3191+
fixed_width = int(ntype.str[2:])
3192+
length = max(len(colname), fixed_width)
31923193
return 0, length+padding, "%s" # left justify
31933194

31943195
if np.issubdtype(ntype, np.int):

0 commit comments

Comments
 (0)