Chapter 8 Hashtags

The twinetverse, or graphTweets more specifically, not only enables visualising interactions between users, it also lets one build and visualise networks of users and the hashtag(s) they use as well as network of hashtags co-mentions. Let’s first look at connecting users to the hashtags they use.

8.1 Collect

Let’s collect some tweets, since we want to plot relationships between users and hashtags we’ll specify two hashtags: #python and #rstats. This way we’ll be able to see who uses both or either. We’ll also narrow it down to tweets in English to avoid #hashtags we cannot understand.

## Searching for tweets...
## Finished collecting tweets!

8.2 Build

Now let’s build a network of hashtags to visualise which user tweets which #hashtag.

Let’s inspect the edges first.

source target n
_artemiscat #100daysofcode 1
_artemiscat #python 1
_blackhost #ai 1
_blackhost #anaconda 1
_blackhost #bigdata 1
_blackhost #datascience 1

The edges include the n_tweets variable which is the number tweets the #hashtag is found in. Note that in order to ensure we can always distinguish between a user and a hashtag, hashtag are preceded by the the # sign. Let’s take a look at the nodes.

nodes type n
#0days hashtag 1
#100daysofcode hashtag 40
#100daysofmlcode hashtag 3
#1millionwomentotech hashtag 1
#1mwtt hashtag 2
#2nd hashtag 1

Nodes also include the type which is either set to user or hashtag.

8.3 Visualise

Now onto the visualisation. As we did before, we unpack our network, then we prepare the data to fit sigmajs’ expectation, and we color the nodes according to the type, one colour for #hashtags and another for @users.

In the visualisation we add sg_neighbours to highlight neighbours of the node clicked, try it.

It is interesting to see that few users actually tweet both hashtags, this wouldn’t have to be in the same tweet so it is somewhat surprising.