Since you are new, let us show you how Trendy works.

Close-button

World Mood Change

This plot is broken.

Undefined function 'tsmovavg' for input arguments of type 'double'.
  • Created by: Sam Mirsky
  • Latest result: Undefined function 'tsmovavg' for input arguments of type 'double'.
  • Created on: 11 Feb 2012

Included from trend description:

Scrapes Twitter to find "Mood of the World". This is based Twitter Mood Light project by RandomMatrix

This version looks at the percentage change from a 7-day moving average (Thanks Ned G for the filter code).

Plot Image
% time1234 and data1234 available for use
% for Surprise Tweets/min
% 
% time1237 and data1237 available for use
% for Sadness Tweets/min
% 
% time1238 and data1238 available for use
% for Fear Tweets/min
% 
% time1227 and data1227 available for use
% for Love Tweets/Min
% 
% time1236 and data1236 available for use
% for Envy Tweets/min
% 
% time1235 and data1235 available for use
% for Anger Tweets/min
% 
% Joy Tweets/Min
%   time vector is: time1233
%   data vector is: data1233

windowSize   = 7;

dataFiltered = tsmovavg(data1227', 'e', windowSize)';
PercentChange1227   = (data1227 - dataFiltered) ./ dataFiltered * 100;

dataFiltered = tsmovavg(data1233', 'e', windowSize)';
PercentChange1233   = (data1233 - dataFiltered) ./ dataFiltered * 100;

dataFiltered = tsmovavg(data1234', 'e', windowSize)';
PercentChange1234   = (data1234 - dataFiltered) ./ dataFiltered * 100;

dataFiltered = tsmovavg(data1235', 'e', windowSize)';
PercentChange1235   = (data1235 - dataFiltered) ./ dataFiltered * 100;

dataFiltered = tsmovavg(data1236', 'e', windowSize)';
PercentChange1236   = (data1236 - dataFiltered) ./ dataFiltered * 100;

dataFiltered = tsmovavg(data1237', 'e', windowSize)';
PercentChange1237   = (data1237 - dataFiltered) ./ dataFiltered * 100;

dataFiltered = tsmovavg(data1238', 'e', windowSize)';
PercentChange1238   = (data1238 - dataFiltered) ./ dataFiltered * 100;


plot(time1227(windowSize:end),PercentChange1227(windowSize:end), '-+', 'Color', [1 0.5 192/255]  );
hold on;
plot(time1233(windowSize:end),PercentChange1233(windowSize:end), '--o', 'Color', [0.8 0.8 0] );
plot(time1234(windowSize:end),PercentChange1234(windowSize:end), ':x', 'Color', [1 0.5 0]  );
plot(time1235(windowSize:end),PercentChange1235(windowSize:end), '-*', 'Color', [1 0 0]  );
plot(time1236(windowSize:end),PercentChange1236(windowSize:end), '-x', 'Color', [0 1 0] );
plot(time1237(windowSize:end),PercentChange1237(windowSize:end), ':*', 'Color', [0 0.5 1]  );
plot(time1238(windowSize:end),PercentChange1238(windowSize:end), '--x', 'Color', [0 0 0]  );
datetick
legend('Love', 'Joy', 'Surprise', 'Anger', 'Envy', 'Sadness', 'Fear', 'Location', 'SouthWest')
title('Percent Change of Number of Tweets vs. Moving Average')
grid on;
ylabel('Change (%)');
ylim([-100 100]);

today = [PercentChange1227(end), PercentChange1233(end), PercentChange1234(end), PercentChange1235(end), PercentChange1236(end), PercentChange1237(end), PercentChange1238(end) ];

name(1)={'Love'};
name(2)={'Joy'};
name(3)={'Surprise'};
name(4)={'Anger'};
name(5)={'Envy'};
name(6)={'Sadness'};
name(7)={'Fear'};

[todaySort emotion] = sort(today);
todayEmotion = name(emotion(end));
annotation('textbox',[0.65 0.7 0.2 0.2], 'String', [{'Today''s emotion:'},todayEmotion], 'FitBoxToText','on');
Tags:

Add Tags


0 comments