In Shinto, the patron deity (kami) of academics, scholarship and learning is Tenjin, who was once a real man. In Japanese history, Sugawara no Michizane was a successful government official during the late 9th century. He was also a renowned poet and scholar. In the early 10th century he was plotted against which lead to his demotion, exile and subsequent death. In the year he died, heavy rain and lightning struck the capital causing fires and the destruction of many homes belonging to those who had betrayed him. 

'Portrait of Tenjin (Sugawara Michizane)' - Katsukawa Shunsho.

The Emperor's court concluded that Michizane's angry spirit was the cause of the disturbances. To placate it, the Emperor restored Michizane's offices and burned the order of exile. He then declared that Michizane be worshipped under the name Tenjin [Ten (天) means sky and jin (神) means deity] and a shrine was built in his honour. For several hundred years, Tenjin was a god of natural disasters and was worshiped in order to placate him in order to avoid these events. 

'Tenjin (Sugawara Michizane) Riding an Ox' - Utagawa Yoshiteru.

But because he was such a famous scholar, over time he came to be regarded as a patron of education and learning. Today his role in preventing disasters has been largely forgotten, and he is now called upon when seeking help to pass exams, and is given thanks by students and their parents when academic success is achieved.

'Portrait of Tenjin (Sugawara Michizane)' - Okumura Masanobu, 1740.

When alive, Michizane loved plum trees and there is a legend that his favourite tree flew to be with him in exile after he wrote a poem about it. Plum trees bloom in February which is when exam results are usually announced so Tenjin shrines often have festivals around this time. 

'Plum Garden at Kameido from the series 'One Hundred Famous Views of Edo' - Utagawa Hiroshige, 1857.

Tenjin is also associated with bulls because during his funeral procession, the bull pulling the cart containing his remains stopped and wouldn't move any further. His shrine was then built in that location. 

'The Tenjin sutra: Sugawara no Michizane Riding a Bull' - Utagawa Kuniyoshi, ca. 1845.

'Toto Tenjin with Plum Branch' - unknown artist.

'Festival Parade Floats Entering the Tenma Tenjin Shrine' from the series '100 Views of Osaka' - Utagawa Yoshitaki, 1860.
Unknown artist.

'Tsuyu no Tenjin Shrine' from the series '100 Views of Osaka' - Hasegawa Sadanobu I, 1869.
'Portrait of Sugawara Michizane' - Okumura Masanobu, ca. 1716-1736.

Tenjin paper scroll, 15th C.