Interactive graphics

  • Key tool for visual analytics
  • Much more efficient than static graphics

Examples:

  • Navigation (panning, rotation, zooming)
  • Selection (highlighting)
  • Connecting (linked views)
  • Filtering (sample)
  • Reconfiguring (change aesthetics)

Theory of interaction

  • Current visualization systems contain certain interaction
    • Limited Features
  • Why do we need a theory?
    • To understand what can be interacted and how
    • To see limitations of existing visualization software
    • To be able to propose new relevant interaction tools missing

Interaction operators

Navigation operator:

  • Camera location
  • Viewing direction
  • Level of details (e.g. hierarchical representations)

Interaction operators

Example:

Australian crabs

Selection operators

  • User isolates a subset of objects
    • Highlighting
    • Masking
    • Focusing
  • How to implement?
    • Click
    • Click+hold
    • Bounding box, lasso

Selection operator

Example:

Australian crabs

Connection operators

  • Related observations are linked in corresponding views
  • Selection operator+Connection operator = Brushing
    • Persistent and transient

Connection operators

  • Challenges
    • How to link data with various mappings
      • Ex: Histogram and scatter plot
      • Ex2: Contour plot and bar chart
      • Ex3: link in which direction? (Hierarchically connected)
    • How to define the corresponding link (key)?
    • Allow for disconecting views?

Connection operators

  • Australian crabs:
    • Which sex do the upper-cluster-crabs have?

Filtering operators

  • Reducing data acc. to specifications

Reconfiguring operators

  • Transforming data
    • Sorting rows, reorder columns, MDS
    • Change aesthetics mapping

Encoding operators

  • Changing the visualization type
  • Changing aesthetics
    • Another color map
    • Change shapes

Abstraction operators

  • Distoring objects locally or globally

Interaction operands

  • What can the operators be applied to?
  • What actions does it imply?

Screen space:

  • Navigation: pixel-wise actions
  • Selection: sets of pixels (boxes, polygons,…)
  • Abstraction: distortion of image (fisheye)
  • Filtering: removing some pixels

Interaction operands

Data value space

  • Operate observations instead of pixels
  • Navigating: translate the axis range
  • Zooming: increase/decrease axis range
  • Filtering: sample the data, sample dimensions
  • Reconfiguring: sorting observations, dimensions, nonlinear transformations

Interaction operands

Data structure space

  • Different data structures exist: matrix, list, graph,…

  • Navigation operator: how navigate the view in the long tree?

  • Selection operator: node in the tree is selected -> subbranches must be selected

  • Filtering operator: Social network: click on node - nodes that are X links away disappear

  • Abstraction/Elaboration: histogram with zooming - recompute bars?

Attribute space

  • Working with aesthetics

  • Navigation: change range of aesthetics to certain interval (show certain range of colors)

  • Encoding operator: change shapes of symbols, non-linear color mapping

  • Selection: highlight certain ranges of aesthetics (highlight stars)

Visualization structure space

  • Dashboards, scatter plot matrices
    • How to navigate user in these?
    • Which components of dashboard can user hide, move, rearrange?
    • Distortion of certain elements

Example: flea data

  • Measurements of fleas and their types
  • Which operators are available here?
  • Which clusters do you see?

Interactive visualization in Plotly

Without Shiny: key ingridients

  • Create cross-talk objects from your dataframes by d<-SharedData$new(data, key, group)
    • key parameter should point to same observations in dataframes
      • Not specified: row id used
    • Group - a unique name related to the same data

Interactive visualization in Plotly

Without Shiny: key ingridients

  1. highlight-function:
    • applied to Plotly object
    • parameters:
      • on: ‘plotly_click’, ‘plotly_selected’,…
      • persistent: TRUE/FALSE
      • dynamic:T/F - enables color selector
      • selectize: T/F text field for selection

Interactive visualization in Plotly



d <- SharedData$new(crabs)
scatterCrab <- plot_ly(d, x = ~CL, y = ~RW) %>%
  add_markers(color = I("black"))

barCrab <-plot_ly(d, x=~sex)%>%add_histogram()%>%layout(barmode="overlay")

subplot(scatterCrab,barCrab)%>%
  highlight(on="plotly_selected", dynamic=T,
            persistent = T, opacityDim = I(1))%>%
  hide_legend()

Interactive visualization in Plotly

plotly_data(barCrab)
## # A tibble: 200 × 9
##    species sex   index    FL    RW    CL    CW    BD .crossTalkKey
##    <chr>   <chr> <int> <dbl> <dbl> <dbl> <dbl> <dbl> <chr>        
##  1 Blue    Male      1   8.1   6.7  16.1  19     7   1            
##  2 Blue    Male      2   8.8   7.7  18.1  20.8   7.4 2            
##  3 Blue    Male      3   9.2   7.8  19    22.4   7.7 3            
##  4 Blue    Male      4   9.6   7.9  20.1  23.1   8.2 4            
##  5 Blue    Male      5   9.8   8    20.3  23     8.2 5            
##  6 Blue    Male      6  10.8   9    23    26.5   9.8 6            
##  7 Blue    Male      7  11.1   9.9  23.8  27.1   9.8 7            
##  8 Blue    Male      8  11.6   9.1  24.5  28.4  10.4 8            
##  9 Blue    Male      9  11.8   9.6  24.2  27.8   9.7 9            
## 10 Blue    Male     10  11.8  10.5  25.2  29.3  10.3 10           
## # ℹ 190 more rows

Interactive visualization

  • Link can be one-to-many or even dynamic (scatter/barchart)

Interactive visualization

m <- SharedData$new(mpg)
p1 <- ggplot(m, aes(displ, fill = class)) + geom_density()
p2 <- ggplot(m, aes(displ, hwy, fill = class)) + geom_point()
subplot(p1, p2) %>% highlight("plotly_click") %>% hide_legend()

Text visualization

Applications:

  • Articles, books
  • Emails, blogs, websites
  • Program Logs
  • Collections (corpus) of books, blogs,..

Analysis:

  • Understanding structure/context of text
  • Group similar documents
  • Development of contents/topics over time

Text processing

  • A text document is a sequence of characters->processing needed
  • R package: use tidytext
  • Raw text
line text
1 Visualization is very cool.
2 I like it.

Text processing

  • Tidy text format: one token per row
line word
1 visualization
1 is
1 very
1 cool
2 i
2 like
2 it

Text processing

-Data in tidy format can be analysed by dplyr, tidyr, ggplot2, plotly

-n-grams: tokens of consecutive n words:

word
visualization is very
is very cool
very cool i

Word cloud

  • Visualizes word frequencies
  • Words are placed in 2D
  • Layout decided algorithmically
  • Size of words=Word frequency
  • Another aesthetics: color

Word cloud

Issues:

  • Stopwords need to be removed: a, the, is, actually…
  • Words sharing the same stem aggregated
  • Synonyms
  • “Satisfied”/“not satisfied” example
  • Incorrect spelling?
  • Hyphens and apostrophes

TF-IDF

  • If stop words not removed, they are most common in each document
  • Solution
    1. Count how frequent the word is among all documents
    2. Weigh the word frequency by the inverse of this number
  • TF-IDF model
    • \(Tf(w)\)=frequency of word, \(df(w)\)=frequency of word in all documents, \(N\)=#documents

\[ TFIDF(w)=Tf(w) \cdot log(N/df(w)) \]

Sentiment analysis

  • Aim: understand the emotional context of the text
  • Each token is given a label/score (positive/negative, [-3,3] )
## # A tibble: 2,477 × 2
##    word         value
##    <chr>        <dbl>
##  1 breathtaking     5
##  2 hurrah           5
##  3 outstanding      5
##  4 superb           5
##  5 thrilled         5
##  6 amazing          4
##  7 awesome          4
##  8 brilliant        4
##  9 ecstatic         4
## 10 euphoric         4
## # ℹ 2,467 more rows

Sentiment analysis

  • A possible strategy:
    1. Count total sentiment per text chunks
    2. Analyse Total Sentiment versus Chunk index

WordTree

Phrase net

Phrase net

  • Size of the word = word freq
  • Thickness of the connection =co-occurance freq
  • Color: dark colors -> word often to the left

Analysis:

  • Analyse most frequent
  • Analyse connections and paths
  • Analyse strength of paths and intensity of colors

Steam graphs

  • Analyses thematic changes in document collections over time

https://hrbrmstr.github.io/streamgraph/

  • Example: #movies by genre,different years
  • Perception problem: angles in areas

Text visualization

  • Other tools for document collection:
    • Place similar documents close in 2D (MDS, clustering, SOM)
  • Graph/network visualization can be used for text
  • A plenty of other visualizations for text:

http://textvis.lnu.se/

Reading home

  • Chapters 10,11

  • Plotly book, ch. 4

  • Text Mining with R book, ch 2.1, 2.2, 2.5, 3.1, 3.3, 4.1.1, 4.1.4

  • Van Ham, F., Wattenberg, M., & Vi?gas, F. B. (2009). Mapping text with phrase nets. IEEE transactions on visualization and computer graphics, 15(6).

  • Wattenberg, M., & Vi?gas, F. B. (2008). The word tree, an interactive visual concordance. IEEE Transactions on Visualization & Computer Graphics, (6), 1221-1228.