Kuniyoshi, Royal Academy of Arts, London

Kuniyoshi's highly stylised prints capture Japan's changes during a tumultuous period in its history

The subject of Utagawa Kuniyoshi's woodblock print Rainbow at Surugadai is, as you'd imagine, a rainbow. Rainbows are tricky things to do, irresistible to a certain kind of painter but almost always unsatisfactory.

To a Romantic such as Constable, they were charged with the pagan grandeur of Nature, towering over the spire in Salisbury Cathedral from the Meadows. To Seurat – witness his L'arc-en-ciel – their interest was optical, the kind of flickery light-effect that pointillism was meant to be good at. Yet neither man found a convincing way of painting rainbows, their efforts being atypically wooden and clumsy.

So how does Kuniyoshi go about it in early 19th-century Japan? Oddly, while the title role of his oban – a standard 10 x 15 inch print, mass produced for a popular audience – goes to the rainbow, the picture's visual interest does not. Where the artist has expended a deal of care on the gradated tints of his sky and on the gestures and postures of a trio of figures to the left, the rainbow is an afterthought, a dull arc of white. The most evanescent thing in the picture, it is rendered the most solid. Compared with it, everything else seems transient, contingent – the travellers on their endless road, the social hierarchies that divide and bind them, the time of day and shadows; life itself.

All of which is to say that Kuniyoshi is an artist of that lyrical place known as ukiyo, the Floating World. For nearly three centuries, from 1603 to 1868, Japan was ruled by a cabal of warlords or shogun, a form of government at once socially repressive and intellectually enlightened. Kuniyoshi's own life – he was born in 1779 and died in 1861 – coincided with the death throes of the shogunate, when that formula was reversed.

As social structures buckled and swayed, the last Edo rulers turned artistic despots. Theatres might be shut down or moved, representations of those theatres – a staple of ukiyo-e print-making – censored or forbidden. As the shutters came down, so light shone through the chinks. With an awareness of the Western power forced on Japan by US military threat – the 1854 Treaty of Kanagawa gave American ships trading rights at Japanese ports – foreign forms of representation also leaked out to the country's artists. It was a time of nightmares and dreams, when nothing and everything seemed possible; a time, above all, of fantasy.

You see this most vividly in Kuniyoshi's scenes from the theatre and from novels based on Japanese myths, images in which the unthinkable is thought through with almost photographic clarity. In one print, a muscular, red child wrestles with a giant carp; in others, warriors do battle with octopuses or spiders or crabs, or are faced with the bloodied ghosts of warriors on the seabed at Daimotsu Bay. Just as the dullness of the rainbow in Rainbow at Surugadai makes the solid world tentative and fleeting, so the specificity of myth and play become more real than reality.

More real, perhaps, even than Realism. While, 6,000 miles away, Courbet was pondering how to paint a life that looked lifelike, Kuniyoshi fought to integrate all that was new and weird into a world of unapologetic artifice. The post-Renaissance West lost itself in looking outwards, in focusing its fantasies on distant prospects: a painting was a finestra aperta, an open window. By absolute contrast, Japanese windows and paintings remained papered shut, with layers of screening over them to direct the eye and mind inwards. The action in Kuniyoshi's prints runs flat up against the picture from left to right, with mid-grounds and backgrounds treated as parallel planes rather than as elements in a receding space. New and subversive things might be projected on these screens – the ladle-wielding cat that stands in for a proscribed female kabuki player, say – but the screens themselves are never questioned.

You see this simple clash of East and West in a delightful oban called The Loyal Retainers Attack Moronao's Mansion at Night. There's something odd about the work, the oddness being that it is based on a 17th-century Dutch print. Of all the Western images open to Kuniyoshi by the mid-1830s, this is the one he chose to work from – a naive picture in which walls run parallel to the picture-plane, in which the Western world seems comfortingly Japanese. That, too, turned out to be an illusion, the meeting of minds a misapprehension.

Royal Academy of Arts, London W1 (020-7300 8000), to 7 Jun