It is quite easy to control spin polarization and the spin direction of a system via magnetic fields. However, there is no such direct and efficient way to manipulate the valley pseudospin degree of freedom. Here, we demonstrate experimentally that it is possible to realize valley polarization and valley inversion in graphene by using both strain-induced pseudomagnetic fields and real magnetic fields. Pseudomagnetic fields, which are quite different from real magnetic fields, point in opposite directions at the two distinct valleys of graphene. Therefore, the coexistence of pseudomagnetic fields and real magnetic fields leads to imbalanced effective magnetic fields at two distinct valleys of graphene. This allows us to control the valley in graphene as conveniently as the electron spin. In this work, we report a consistent observation of valley polarization and inversion in strained graphene via pseudo-Landau levels, splitting of real Landau levels, and valley splitting of confined states using scanning tunneling spectroscopy. Our results highlight a pathway to valleytronics in strained graphene-based platforms.