1. For example, red is for Line 1, and green is for Line 2. (subway system)

2. For example, red is Line 1, and green is Line 2. (subway system)

Which one is grammatical? Are both grammatical?

Both are commonly used and grammatically correct; the first sentence is a bit more complete.