This example shows you how to specific PlotMarkers for each point in a data set. The solution is quite simple, just partition the dataset into different series, each set only contains one point exactly: Partition[data, 1]. Then we can assign the different PlotMarkers for each point.
Let’s download some weather data:
data = WeatherData[$GeoLocation, "WindDirection", {{2009, 1, 1}, {2009, 1, 5}}];
data = Select[data, FreeQ[#, {_, Missing["NotAvailable"]}] &];
We like to use arrows to represent wind directions:
markers =
Graphics[{Red, Arrow[{{0, 0}, -0.5 {Sin[#[[2]] Degree], Cos[#[[2]] Degree]}}],
EdgeForm[], FaceForm[], Rectangle[{-1, -1}, {1, 1}]}] & /@ data;
We put a invisible box around arrow to make sure that the markers are aligned by {0, 0}.
newdata = data; newdata[[All, 2]] = 0;
g = DateListPlot[Partition[newdata, 1], PlotRange -> All, PlotMarkers -> markers, Axes -> {True, False}, FrameTicks -> {Automatic, None}]
Let’s test another place: Tokyo, Japan
Summer time:
Winter time:
The pattern of winter “north” wind and the summer “south” wind is very clear, it is much better than just plotting points.
No notebook, all the codes are here already.
1 comment:
MMA needs a TickStyle to flow X-axis labels vertically. Shrink plots a little, and horizontal ticks cram each other. Maybe v8 is the charm?
Thanks for the nice web-log.
Post a Comment