When I examined the colors showed on a pH paper which is red for acids and violet for bases, greenish yellow for neutral and other ranges in between, I noticed that the sequence is exactly same to that of visible light spectrum that is violet, indigo, blue, green, yellow, orange, and red. Is there a connection between the two, and if yes what it is?
It has to do with the way pH indicators and particularly large-range pH indicators work.
In simplest terms, a pH indicator is simply a weak acid/base which has one color in its acidic form, and one color in its basic form. When the solution is highly acidic, all of the indicator molecules are protonated, and the color of the indicator is the color of the protonated form. When the solution is highly basic, all of the indicator molecules are deprotonated, and the color of the indicator is the color of the deprotonated form.
Where it gets interesting is where the pH of the solution is close to the pKa of the indicator. In those situations, you have some of the indicator molecules in the protonated form, and some of them in the deprotonated form. You don't ever get "fractionally protonated" forms - each individual molecule is either one or the other. Since light absorption happens on a molecular level, you get
You can see this with a titration of something like Bromothymol Blue [image]. The protonated form is yellow, so at low pH, everything is yellow. The deprotonated form is blue, so at high pH, everything is blue. At around the pKa (~7), there's near equal amounts of the two forms, so it acts like you mixed equal amounts of a yellow pigment/dye and a blue pigment/dye. That is, you get a green solution due to the subtractive color mixing model. As you titrate the pH, you get a range of colors as you add and remove the amount of protonated and deprotonated forms, as would be indicated by the Henderson–Hasselbalch equation.
Okay, so that's a single pH indicator, which is normally limited to a small range. (Because more than ±1 pH unit to either side of the pKa you typically have only a single species present.) To get broad range pH indicators, you have to mix multiple different pH indicators, each with their own different colors and changes. But you have to do this intelligently, as the indicators are always present, and will always contribute to the color.
Here's a chart of some of the major pH indicators, their pH ranges and their colors. You can see what might happen with various indicator combinations. For example, with an ethyl violet/ethyl orange mixture, at low pH you'd have an orange solution (yellow+red), which would transition to be purple (blue+red) at around pH 3 and then to be green at high pH (blue+yellow). But those intermediate colors are going to be pretty muddy. At around 1.5 you'll have an orangy-purple, and at around 4.5 you'll have a greeny-purple. Imagine what things would look like if you mixed orange paint with purple paint, or purple paint with orange paint.
What we need is a layout of color that can gradually transition one to the other and look good all the way through the approximately 7-ish transitons you'd need to segment up a 14 unit pH scale ... right, the rainbow spectrum has that property.
So there's no real chemical reason for the connection. It's more a practical human consideration, where the people combining the indicator molecules to make a large-range pH indicator need to pick particular ones which make a clear, unambiguous color sequence, and the visual color spectrum has the same useful properties they need.