In this case you should change 4 to 04, if you keep it in 2 digit format it doesn't consider the proceeding text to be a part of the color definition. If your number is variable then you can make sure it is in 2 digit format using $base(N,10,10,2) to pad it with a zero if necessary. If you are using $color to return a color number then you can take a shortcut, $color().dd returns it in double digit format