Overview: The campus I work for has a website that students can use to vote how they feel in terms of comfort in a particular room. The options the students have when logged into the site are : Cold, Perfect and Hot. The votes are stored in a large database that contains the time the student voted, the building and room they are in and the type of comfort vote they selected. This gives my team an idea of either overcooling a particular room / building or not cooling enough.

Initial Idea: My idea was to plot the votes that are coming in onto a graph that can be updated as the students vote throughout the day. Cold votes be +1, hot votes be -1 and perfect would be 0, This was to give a general overview of overcooling, undercooling across campus. The problem I ran into is this would never indicate that people are feeling perfect if even one person voted cold/hot.

One option suggested in the comments was to create a bar graph which could keep a sum of the three votes separately, possibly a bar graph per day, then sum the daily count of votes for a monthly bar graph and per year.

Question: I was wondering if there was a way to visualize this in 2D, to quickly get an idea of the comfort of people, whether they are mostly Hot, Cold or Perfect or would I have to keep this in 3D with each dimension pertaining to the vote type?

Example Data:

enter image description here

  • $\begingroup$ Can you post your data (or a small example dataset) for people to work with? What are the students voting on? How many students are voting? Can a student abstain from voting? We need more information here... $\endgroup$ – gung - Reinstate Monica Jun 3 '19 at 17:00
  • 1
    $\begingroup$ Numbers of cold, perfect and hot votes can easily be shown in two dimensions for example with 3 bars. If you're imagining a three-dimensional display you must be wanting to show something else but I can't follow what that is. $\endgroup$ – Nick Cox Jun 3 '19 at 17:01
  • $\begingroup$ @gung I added a small sample dataset, the students vote on a site with the three options, so they are not able to abstain from voting. The number of students voting is variable as it is dependent on when they choose to vote. $\endgroup$ – jaleman Jun 3 '19 at 17:09
  • $\begingroup$ I still don't quite follow this. What are the sites? How many sites are there? What does the timestamp have to do with this? Does the student vote on each site, or assign their "hot" vote to the one they like best? $\endgroup$ – gung - Reinstate Monica Jun 3 '19 at 17:18
  • $\begingroup$ @gung there is only one website where students on campus can vote. They provide information of the building they are in, and after are given three options to choose: Cold, Hot, Perfect. This gets added to a database that is storing the votes of students across campus. The timestamp is recorded when the student submits their vote. The relevance of the timestamp in my initial idea was to use time as the x coordinate and comfort as the y coordinate, to see the trend either go up (colder votes) or down (hotter votes) but I didn't account for perfect, which would not have any impact if left as 0. $\endgroup$ – jaleman Jun 3 '19 at 17:23

I would do a graphic taking as time unit a week or month. Then I would count for each time unit the amount of each vote you have. Then take the percentage of vote for each category for that time unit, this is important in order to be able to compare different times. Then plot this data with lines of different color like this R script:

  data <- data.frame(Time=seq(from=as.Date('1990-01-01'),to=as.Date('1991-12-31'),by='day'))

  asd <- runif(nrow(data),min=0,max = 3)
  data$Vote <-factor(x = 'perfect',levels = c('hot','cold','perfect'))
  data$Vote[asd <= 2] <- 'cold'
  data$Vote[asd <= 1] <- 'hot'
  Times <- seq(from=as.Date('1990-01-01'),to=as.Date('1991-12-31'),by='month')
  new_data <- data.frame(Time=rep(Times,each=3))
  new_data$Votes <- rep(c('hot','cold','perfect'),24)
  new_data$value <- NA
  cont <- 0
  for(ii in 1:length(Times)){
    i <- Times[ii]
    yy <- year(i)
    mm <- month(i)

    index <- year(data$Time) == yy & month((data$Time)) == mm 
    for(vote in c('hot','cold','perfect')){
      cont <- cont +1
      index2 <- data$Vote[index] == vote
        new_data$value[cont] <- length(which(index2))
    new_data$value[(cont-2):cont] <- new_data$value[(cont-2):cont]/(sum(new_data$value[(cont-2):cont],na.rm = T))

  ggplot(data=new_data,aes(x=Time,y=value,col=Votes)) + geom_line()
  • $\begingroup$ Really nice! One question I had was in new_data what does the value column represent for each vote? I ran your script and new_data has for Time 1990-01-01 There is hot votes with 1.0645161 as the value, cold with 1.064551 and perfect with 0.9709677 $\endgroup$ – jaleman Jun 4 '19 at 20:46
  • $\begingroup$ First, sorry I put mean function instead of sum to do the percentage, I already change it. The value column is the percentage of votes for each Vote category. For example, the thirst three rows have the cold, hot and perfect votes for January 1990. The value for each of these rows is Votes_In_this_category / Total_votes consider only that month, so the sum of the first three rows must be 1. $\endgroup$ – Santiago I. Hurtado Jun 5 '19 at 21:11
  • $\begingroup$ Thank you so much! This is perfect for what I am trying to do. $\endgroup$ – jaleman Jun 5 '19 at 22:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.