Map from Google - Madagascar

Madagascar is a large island in the Indian Ocean, with a tropical climate, rainy along the east coast, arid in the south-west and temperate in the mountains. In inland areas the mountain ranges mitigates the climate, while the rains vary depending on slope exposure. Being in the Southern Hemisphere, the country has reversed seasons compared with Europe or North America.
The whole country has a rainy season from November to March, which produces little effect in the arid southwest, and in most of the country there is a dry season from April to October (or from May to September in the north), except on the east coast where it rains all year round. The rains occur, as happens in the Tropics, in the form of thunderstorms in the afternoon, so there's no shortage of sunshine even in the wettest months, at least in the morning.
Here are the climatic zones of Madagascar.

Climates in Madagascar

During winter, the south-east trade winds blow, cool and dry everywhere except along the east coast, where they release the moisture that has been picked up over the ocean. For this reason, on the east coast and on the first slopes near the coast, it rains throughout the year, and a tropical forest flourishes. In Toamasina (formerly Tamatave), 3,350 millimetres of rain per year fall. In March, the rainiest month, rainfall exceeds 400 mm. The only months when the rains become moderate, around 100/150 mm per month, are September and October, and this is true in general for the entire east coast. Between June and September, the whales that congregate in the channel between the island of Sainte-Marie and the coast of Madagascar for breeding, are observed in an often rainy context.
Here is the average precipitation of Toamasina.
Average precipitation - Toamasina
ToamasinaJanFebMarAprMayJunJulAugSepOctNovDecYear
ToamasinaJFMAMJJASONDY
Prec. (mm)4103804803252302602902201201351703553370
Days232024212221252419181721255

And here are the average temperatures of Toamasina. You can notice the cooling during the austral winter: in July and August, the daily average is 21 °C.
Average temperatures - Toamasina
ToamasinaJanFebMarAprMayJunJulAugSepOctNovDec
ToamasinaJFMAMJJASOND
Min (°C)232322212018171717192022
Max (°C)303030292726252526272829

The temperature of the sea on the east coast is high enough for swimming all year round, although it decreases a bit from July to October, as we can see in the following table.
Sea temperature - Toamasina
ToamasinaJanFebMarAprMayJunJulAugSepOctNovDec
ToamasinaJFMAMJJASOND
Sea (°C)282828282726252424252627

The cool trade winds have a smaller effect on the north-western coast (see Nosy-Be), which therefore is warmer in winter.
Average temperatures - Nosy Be
Nosy BeJanFebMarAprMayJunJulAugSepOctNovDec
Nosy BeJFMAMJJASOND
Min (°C)232323222019181819202223
Max (°C)313131313129292931323231

The period from November to March is not only rainy, but it's also hot and muggy. We are in the austral summer, and in this season the country is divided into two: in the north, the north-west monsoon prevails, bringing heavy rains along the north-west coast, where from 400 to 500 mm per month in January and February fall. Here the average rainfall of Nosy-Be, which being on the northwest coast is directly exposed to the northwest monsoon.
Average precipitation - Nosy Be
Nosy BeJanFebMarAprMayJunJulAugSepOctNovDecYear
Nosy BeJFMAMJJASONDY
Prec. (mm)4654252851406050354040951903602185
Days20161373333351014100

In this part of the coast, the sea temperature is high throughout the year, as we can see in the following table.
Sea temperature - Nosy Be
Nosy BeJanFebMarAprMayJunJulAugSepOctNovDec
Nosy BeJFMAMJJASOND
Sea (°C)292929292827262626262828

In the austral summer, in the south the south-east trade winds still blow, bringing rains along the eastern side, but much less in the south-west. In Toliara (formerly Tulear), just 420 mm of rain per year fall, with a maximum of around 90 mm per month from December to February. Here is the average precipitation.
Average precipitation - Toliara
ToliaraJanFebMarAprMayJunJulAugSepOctNovDecYear
ToliaraJFMAMJJASONDY
Prec. (mm)959035201515668122095420
Days89533321223748

In the southwest, the hottest area of the country, the temperature can reach 40 °C from December to March. Here the amount of sunshine is very good even in summer. Here are the average temperatures in Toliara.
Average temperatures - Toliara
ToliaraJanFebMarAprMayJunJulAugSepOctNovDec
ToliaraJFMAMJJASOND
Min (°C)232322201715141516192022
Max (°C)323232312927272829293031

The temperature of the sea in the southern part of the coast touches 23 °C in August, therefore it remains warm enough for swimming.
Sea temperature - Toliara
ToliaraJanFebMarAprMayJunJulAugSepOctNovDec
ToliaraJFMAMJJASOND
Sea (°C)282928272624242324252627

The west coast is less rainy than the north-west coast, so that between 700 and 1,000 mm per year fall, compared with 1,500/2,000 mm of the northwest coast.
As mentioned, in inland areas the altitude temper the climate, at least at intermediate altitudes, while above 2,000 metres during winter the temperature can drop below freezing, especially in the south. In the dry season, on the plateau a wind that can raise the dust from the parched ground can blow.
The capital Antananarivo (formerly Tananarive) is located at 1,300 metres above sea level, and has a pleasant climate, so that the average goes from 21 °C in the summer months, to 15 °C in July and August. Winter is therefore pretty cool. Here the best months are April, September and October.
Average temperatures - Antananarivo
AntananarivoJanFebMarAprMayJunJulAugSepOctNovDec
AntananarivoJFMAMJJASOND
Min (°C)171716151311101011131516
Max (°C)282625252321202123252626

Throughout the year, in Antananarivo 1,400 mm of rain fall, most of which occur from November to March. Here is the average precipitation.
Average precipitation - Antananarivo
AntananarivoJanFebMarAprMayJunJulAugSepOctNovDecYear
AntananarivoJFMAMJJASONDY
Prec. (mm)27025518550207101510651703051365
Days18171796689481420136

In the warm season, Madagascar may be affected by tropical cyclones, that form in the Indian Ocean during the period from November to mid-May, although they are more likely from late December to mid-April.
The country is very interesting, not only for the beauty of the landscapes, but also for its flora and fauna, because it has a great biodiversity and several native species, having been separated from the African continent millions of years ago.

Baobabs in Madagascar

When to go

The best time to visit Madagascar as a whole, to explore its various attractions in the country, corresponds to the months of September and October, to avoid the heat, but also the rains and cyclones of the austral summer, but also the cold at night that at high altitudes is more intense in winter, from June to August. The period from June to August is still good, even though it's very rainy on the east coast, and as mentioned it can be cold in mountain areas.
For a beach holiday, the west coast is preferable to the east coast, being sunnier and less rainy. Anyway, on the west coast you can go from mid-May to October, in the east coast in September and October. As regards the west coast, you can distinguish between the northern part, the one facing north-west which is warm throughout the year (see Nosy-Be, Antsiranana), and the central-southern part, which in winter can sometimes be reached by cool air masses from the south and can experience cold nights (see Toliara): therefore, in the latter it's preferable to go in September and October, but if you intend to travel in July or August, to avoid surprises you can choose the northernmost area. In Nosy-Be you can go from mid-May to October, although in October a little atmospheric instability begins to occur, with the first afternoon thunderstorms.

What to pack

In winter (June to August): on the south-central and eastern coast, spring/autumn clothes, light for the day, sweater and light jacket for the evening; on the east coast, add a raincoat or umbrella. On the north coast (Mahajanga, Nosy Be), light clothing, a sweatshirt for the evening, a scarf for the breeze. In Antananarivo and the plateau, spring/autumn clothes, jacket, sweater and hat for the evening, scarf for the wind.
For the reef, equipment for snorkeling, water shoes or rubber soled shoes.

In summer (December to February): throughout the coasts and inland areas at low altitude, light clothing made of natural fibres, sun hat, a light sweatshirt for the evening, light raincoat or umbrella. In Antananarivo and the plateau, light clothes for the day, sweatshirt and light jacket for the evening, raincoat or umbrella.