You cannot put a text tag in rect . If you want to display text inside a rect element, you must put them in a group.
<svg height="100" width="710"> <g> <rect width="70" height="50" style="fill: rgb(0, 0, 255);"></rect> <text y="0" style="fill: white;">-0.123994</text> </g> <g> <rect width="70" height="50" style="fill: rgb(255, 0, 0);" transform="translate(630,0)"></rect> <text y="50">0.387869</text> </g> </svg>
Please adjust the coordinates of the text to display inside the rectangle.
source share