NOT long after she moved into the medieval Tuscan rectory owned by her friend Penelope Jardine, Muriel Spark leaned out of her window and saw her companion toiling away below, clearing boulders from the wilderness of fruit trees and olives that surrounded the ramshackle house.

"When you've finished playing in the garden," said Spark, "would you mind coming in and making me a cup of tea?"

Jardine can now laugh at the memory, but at the time it must have been a little galling. In all the years Spark shared her home, she never so much as plucked a dandelion or daisy, though a glass of wine on the roof terrace overlooking their idyllic grounds was a perfectly acceptable end to the day. It was not that Spark did not like gardens - she loved them - but that they were for sitting in and admiring, not grubbing around on hands and knees. Her sole contribution to the outdoor demesne was to buy Jardine a sit-on lawnmower the size of a Sherman tank, and almost as alarming.

For many novelists and poets, writing usually wins over weeding. Virginia Woolf was not the first to use a hut at the bottom of the garden in which to write (in her case the term summer house might be more accurate), and while she had an affinity with the land around her, for her contemporary equivalent - the likes, say, of Philip Pullman and David Almond - one suspects the piece of land attached to their house is interesting primarily as a space in which to build a water-tight office where they can work undisturbed by cold callers and family. Not for them the habits of Sir Walter Scott who, when his gardener tapped on the window of a morning, would put his head outdoors to check the weather, then set off to help prune and plant trees on his Abbotsford estate, sometimes until day's end.

It is those such as Scott on whom Jackie Bennett focuses in her lavishly illustrated book The Writer's Garden. A TV producer turned gardening columnist, she picks out some of the finest gardens kept or created by the more green-fingered of Britain's most celebrated writers over the past two centuries. In so doing, she tries to tease out the connection between those such as Beatrix Potter and Laurence Sterne, who paid as much attention to leafy plots as to the literary sort, and the influence of their passion for plants and trees on their work.

To be fair, the link is tenuous in several of the instances cited here. For instance, the word "gardener" is hardly suitable, Bennett concedes, for Robert Burns, whose miserable farm at Ellisland in Ayrshire helped make him ill and dragged him into debt. As she writes: "it was probably Jean or one of the helpers who dug the vegetable plot and grew a few flowers for the table. He did, however, understand country life from first-hand experience, and gardening was part and parcel of that life. It was at Ellisland that he composed The Gard'ner wi' His Paidle, in which he shows his emotion for those who worked the land."

Ellisland might have been couthy, but there was nothing inspirational about it except in the widest sense. In common with writers before and since, Burns wrote about that which was in front of his nose, be it a mouse startled from its nest by a plough or an injured hare. But had anyone suggested that the red red rose of which he wrote so sweetly had been tended by his own hand, in some flowery arbour or window box, he would have been astonished.

The discrepancy between Burns's unrewarding piece of land and that of his near contemporary, Scott - the only two Scots in the book, incidentally - could not be starker. Though the Wizard of the North ended up in as poor a state of finances and health as his Ayrshire compatriot, and his story as tragic, the house and gardens Scott created on the banks of the Tweed near Melrose were incomparable in grandeur and beauty. And while there is no doubt that, like Burns and others, the novelist drew heavily on a lifelong passion for the countryside, it seems that in his design of his outdoor space at Abbotsford, with its walled kitchen garden, formal walks and woodlands, Scott was mimicking the taming process of literature, which imposes order where there might otherwise be meadowland or unploughed fields, and gives shape and borders to nature's unchecked exuberance.

One wonders if, in fact, those writers who devoted themselves to gardens were not so much inspired by them as nurtured, the men and women poets and novelists who planted azaleas and anemones as did Potter or cultivated orchids like Roald Dahl, merely a human form of the vegetation, as much in need of watering and sun, and being kept clear of weeds, albeit in a metaphorical sense. Perhaps for these literary figures, a garden was as much refuge as wellspring. That was indubitably the case for Rudyard Kipling, who moved to a splendid 17th-century mansion in the Sussex Weald after the death of his six-year-old daughter which, coupled with the pressures of fame, made public life intolerable. The first British writer to win the Nobel Prize for literature, he put the £7700 cheque that came with this honour towards improving the garden, which became one of the loveliest Edens in the country. Nor was Kipling a hands-off cultivator, as his often quoted poem The Glory Of The Garden suggests: "Our England is a garden, and such gardens are not made, by singing: - 'Oh how beautiful!' and sitting in the shade."

Of course, someone like Thomas Hardy, brought up in Dorset in a cottage encircled by ferns, vegetables, hens and pigs, was a countryman to the core, and wise with it. As a boy he swapped apples with the son of a nearby bookseller in return for permission to sit in his shop reading. The finest poet of his age, as well as a novelist of renown, one suspects Hardy would have written about trees and landscape even had he been confined to a tenement flat. Fortunately he lived out his days in a red-brick villa whose garden he filled with 2000 Austrian pines, employing a full-time gardener to whom, after a few hours' writing were under his belt, he gave instructions every morning.

Another man for whom the untamed outdoors was his inspiration, rather than anything to be found between box hedge or picket fence, was Ted Hughes. Bennett features Lumb Bank, the sprawling farmhouse where the poet laureate lived only fleetingly. Those familiar with his work, however, will know that he, like the Bronte family before him, drew on the bleakness of the Yorkshire moors, rain-sodden dales, and their wildlife for his work. There was nothing domestic about his crow or ram or toad. Nor can one imagine him planting nasturtium seeds or keeping hyacinths in the broom cupboard till spring. He had the gait of a man at home with a hoe or rake, not with secateurs or flowerpots.

The pre-eminent metaphysical poet of the 19th century, William Wordsworth, was brought up in a house in Cockermouth with magnificent gardens, and later lived with his sister at Dove Cottage, with a vertiginous, cramped garden overlooking Grasmere. Even he, however, seemed to find the spark for his poems in tramping the hills and lakesides rather than contemplating cabbages or crocuses outside his study.

John Ruskin, enthusing about his hobby, expressed it thus: "No words, no thoughts can measure the possible change for good which energetic and tender care of the wild herbs of the fields and trees of the wood might bring ... to the bodily pleasure and mental power of man."

The literature they help inspire is almost incidental to his view of a garden's worth, which is, after all, as much a work of art as any book.

The Writer's Garden by Jackie Bennett is published by Frances Lincoln, £25