Plot angles around $360^\circ$ (North) I want to plot wind angles. I typically have around 25 observations (the amount is not important here). I want to use a line chart to quickly see the trend (veering or backing) and the amount of oscillation. I also calculate statistics of the values.
Mostly this is trivial. But how to manage the situation when wind is around North?
E.g. I have observations 5, 10, 350, 345, 355, 0, 5. This produces a non-informative plot because the values are seemingly so separate although in reality they are not. Calculating average produces wrong result (153, the right should be 359).
OK, I get it right using negative values for the big numbers. (350 = -10)
Now the question: what kind of algorithm should i write to make a decision about when I need this value changing or is there another means to handle this?
 A: The question implies that you want a linear plot (and not a circular plot). That being so, a general principle that usually works is to rotate the scale so that the vector mean is at the centre. The vector mean is the arctangent of the ratio of the sum of sines to the sum of cosines. Some care is needed to catch the four-quadrant character of the calculation (not to mention the fact that most such data arrive in degrees and trigonometric routines commonly assume use of radian measure). 
The vector mean for your example of $5, 10, 350, 345, 355, 0, 5$ degrees is $358.9^\circ$. 
A direction close to the vector mean will often work just as well. For example, with one kind of circular data I work with, the vector mean is often close to North-East but, unsurprisingly, no law of nature makes that exact. A convention to put NE at the center of a scale is helpful, however. Let's spell out that it can be more helpful to choose a standard scale for a series of related graphs than to optimise each separately. 
In the case of winds, winds from every direction at some time or another are likely in most topographic situations, although usually with different frequencies. (For a variety of reasons wind is rarely measured instrumentally on very steep slopes.) But note in particular that two modes opposite on the circle are possible in some cases, as when two modes are up-valley and down-valley winds (anabatic and katabatic), onshore or offshore, etc. In such cases, it can be best to avoid cutting the circle at a mode. 
In general, two principles that usually do not contradict are 


*

*Put the vector mean at or near the middle of the scale. 

*Avoid cutting the scale (i.e. choosing the ends of the scale, which are necessarily identical) to cut a mode that is interesting or important. 
One often cited example dataset in circular statistics concerns turtle migration between land and sea in which there are two modes for direction, and the usual wry comment is that evidently some of the turtles are confusing backwards and forwards. The same phenomenon has been observed in political science, although with different players. 
A: Operating under the assumption than the period is 360 degrees, if the angle is greater than 180, subtract from 360. That should give you the right averages.
