{"id":973,"date":"2012-06-18T10:13:50","date_gmt":"2012-06-18T15:13:50","guid":{"rendered":"https:\/\/blogs.mathworks.com\/community\/?p=973"},"modified":"2012-06-15T15:14:57","modified_gmt":"2012-06-15T20:14:57","slug":"multipoint-data-gathering-in-trendy","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/community\/2012\/06\/18\/multipoint-data-gathering-in-trendy\/","title":{"rendered":"Multipoint data gathering in Trendy"},"content":{"rendered":"<p>When we launched Trendy, you could only grab one data point per trend. One of our very first plots, which was created as simple example, tracks the <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/trendy\/plots\/692\">daily high and low temperatures in Anchorage, Alaska<\/a>. Naturally, this plot requires two data points for each day: the <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/trendy\/trends\/1155\">daily high in Anchorage<\/a>, and the <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/trendy\/trends\/1328\">daily low in Anchorage<\/a>. But the thing is, these two numbers both come from the <a href=\"http:\/\/www.nws.noaa.gov\/view\/validProds.php?prod=RTP&amp;node=PAFC\">same web page<\/a>. That means we&#8217;re visiting the same page twice to get two numbers. Seems a shame, eh? It would be much nicer if we could just visit the page once and extract both numbers.<\/p>\n<p>That&#8217;s why we recently added the ability to grab and store multiple data points (i.e. vectors) per day in a single trend. In keeping with our weather example, here&#8217;s the first vectorized trend I created: <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/trendy\/trends\/1656\">Vectorized High\/Low for Anchorage<\/a>. Plotting is very straightforward. The data for vectorized trends is stored as the rows of a matrix. So if you plot time against data, you get a nice time series plot of each piece of data. Here is the resulting <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/trendy\/plots\/866\">high-low temperature plot<\/a> and the accompanying code.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-1047\" title=\"anchorage-high-low\" src=\"https:\/\/blogs.mathworks.com\/community\/files\/anchorage-high-low.png\" alt=\"\" width=\"512\" height=\"384\" \/><\/p>\n<p><code>plot(time1656,data1656(:,1),'red')<br \/>\nhold on<br \/>\nplot(time1656,data1656(:,2),'blue')<br \/>\nhold off<br \/>\ndatetick<br \/>\nylabel('Temperature (deg. F)')<br \/>\ntitle('High\/Low Temperatures in Anchorage, Alaska')<\/code><\/p>\n<p>Now let&#8217;s move on to something a little more ambitious. Suppose you wanted to track the standings of every American major league baseball team. Before vectorized trends, you would need to create 30 different trends, one for each team. <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/trendy\/owners\/184\">Patrick Kalita<\/a> has done this. At the time he didn&#8217;t have any choice, but it must have taken him a while. Using this data, Patrick is tracking the standings for <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/trendy\/plots\/833\">each division in the major leagues<\/a>. I want to call your attention to the fact that he has carefully aligned each team&#8217;s line color with their real-life team colors. Nice work Patrick!<\/p>\n<p>I wanted to try to do something similar: track the winning percentage of all the major league teams. Now I can do that in a <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/trendy\/trends\/1690\">single trend<\/a>. With all the data in one place, I can easily show all the teams in a single plot. But maybe more important, it&#8217;s easier for me to analyze the data. For instance, here&#8217;s a plot where I calculate the <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/trendy\/plots\/885\">longest current winning and losing streaks<\/a>. Note the freakish correlation between the Nationals and the Yankees.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-1055\" title=\"trendy-mlb\" src=\"https:\/\/blogs.mathworks.com\/community\/files\/trendy-mlb.png\" alt=\"\" width=\"512\" height=\"384\" \/><\/p>\n<p>Cleverest usage of vectorized trends so far: Aurelien&#8217;s <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/trendy\/plots\/894\">Reasons why MathWorks should have an office in my village<\/a>. It&#8217;s a comparison of the weather differences between <a href=\"http:\/\/fr.wikipedia.org\/wiki\/Meudon\">Meudon<\/a> (near Paris) and <a href=\"http:\/\/fr.wikipedia.org\/wiki\/Corbi%C3%A8res_(Alpes-de-Haute-Provence)\">Corbi\u00e8res<\/a>. It looks like Corbi\u00e8res is winning!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When we launched Trendy, you could only grab one data point per trend. One of our very first plots, which was created as simple example, tracks the daily high and low temperatures in Anchorage,&#8230; <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/community\/2012\/06\/18\/multipoint-data-gathering-in-trendy\/\">read more >><\/a><\/p>\n","protected":false},"author":69,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/973"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/users\/69"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/comments?post=973"}],"version-history":[{"count":17,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/973\/revisions"}],"predecessor-version":[{"id":1061,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/posts\/973\/revisions\/1061"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/media?parent=973"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/categories?post=973"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/community\/wp-json\/wp\/v2\/tags?post=973"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}