{"id":2745,"date":"2020-10-09T10:50:10","date_gmt":"2020-10-09T14:50:10","guid":{"rendered":"https:\/\/blogs.mathworks.com\/iot\/?p=2745"},"modified":"2020-12-16T20:03:01","modified_gmt":"2020-12-17T01:03:01","slug":"thingspeak-now-supports-matlab-swarm-scatter-charts","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/iot\/2020\/10\/09\/thingspeak-now-supports-matlab-swarm-scatter-charts\/","title":{"rendered":"ThingSpeak Now Supports MATLAB Swarm Scatter Charts"},"content":{"rendered":"

ThingSpeak automatically gives you access to the latest MATLAB features from the latest MATLAB release. MATLAB R2020b now includes swarmchart<\/a> to create sarm scatter charts! The charts are a great way to visualize many measurements across a limited number of categories.<\/p>\n

Here is a swarm chart of wind speed versus hour of day. The chart is created with just two lines of MATLAB code (and a few more for formatting the plot). This plot uses data from the weather station on top of the parking garage at the MathWorks Apple Hill location in Natick (Channel 12397<\/a>).<\/p>\n

\"\"<\/a><\/p>\n

Since the weather station also includes temperature, I\u2019ve color-coded the points using the temperatures for the day.<\/p>\n

To create this chart in ThingSpeak, select the MATLAB Visualizations app, and create a new visualization. You can use this code as a start, change the channel ID to whatever channel you want to read.<\/p>\n

% Read the data from ThingSpeak into a timetable and create the plot.\r\nmyData = thingSpeakRead(12397,'daterange',...\r\n[datetime('now')-days(14) datetime('now')-days(9)],'outputformat','timetable');\r\nswarmchart(hour(myData.Timestamps),myData.WindSpeedmph,30,...\r\nmyData.TemperatureF,'filled')\r\n\r\n% Create the swarmplot with appropriate labels and limits\r\nxlim([0, 24]);\r\nxlabel('Hour of Day');\r\nylabel('Wind Speed (mph)');\r\ntitle('Natick Wind Speed Swarm Chart Visualization');\r\nc = colorbar();\r\nc.TickLabels = c.TickLabels + \"\\circ\";\r\n\r\n% Change the aspect ratio.\r\nset(gcf,'units','points','position',[0,0,600,250]);<\/pre>\n","protected":false},"excerpt":{"rendered":"
<\/div>\n

ThingSpeak automatically gives you access to the latest MATLAB features from the latest MATLAB release. MATLAB R2020b now includes swarmchart to create sarm scatter charts! The charts are a great way… read more >><\/a><\/p>\n","protected":false},"author":148,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[22,4,293],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/posts\/2745"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/users\/148"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/comments?post=2745"}],"version-history":[{"count":1,"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/posts\/2745\/revisions"}],"predecessor-version":[{"id":2749,"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/posts\/2745\/revisions\/2749"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/media?parent=2745"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/categories?post=2745"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/iot\/wp-json\/wp\/v2\/tags?post=2745"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}