Is your matrix controlled by the MAX7219 IC? You provide no details of the type of matrix you are using.
it gives me output on the display but it is repeating the displayed text after some pixel again.
With the 7219IC this means that there are more matrices than the software thinks there are. When you update the display, the serial data communications pushed the 'current' data off the end of the 'known' modules into the others, which will show the old display as was previously on the 'known' modules before they were updated.
You need to find somewhere in the library that has the number of modules and change that to be those for your matrix.
If they are not controlled by the MAX7219, then this explanation may not be correct for your matrix.