• Illumined Insights
  • Posts
  • Preattentive Attributes in Data Visualization: Enhancing Perception and Understanding

Preattentive Attributes in Data Visualization: Enhancing Perception and Understanding

The Power of Perception: Leveraging Preattentive Attributes for Effective Data Visualizationere

Welcome to the “Illumined Insights” newsletter! Thank you so much for subscribing. This newsletter touches on all things analytics and data science with a focus on areas such as data visualization and sports analytics. This week we take a look at a fundamental data visualization principle: The use of “preattentive attributes”.

Stephen Hill, Ph.D.

Data visualization is a key tool in the analytics/data science toolkit, and the way data is presented can have a significant impact on the insights discovered and decisions made. One important aspect of effective data visualization is the use of "preattentive attributes." Preattentive attributes are visual cues that are processed quickly and unconsciously by our brains, allowing us to quickly perceive patterns and relationships in data. In this article, we will discuss four types of preattentive attributes and provide examples of how they can be used in data visualization.

Color: Color is a powerful preattentive attribute that can be used to highlight important data and illuminate differences. For example, a bar chart showing sales by region could use a distinctive color to represent a particular region of interest. In the chart below, we use red to provide a strong contrast to the gray bars. Our eye is immediately drawn to the red bar when we look at the bar chart.

Bar chart with color as a preattentive attribute

The R code to produce the data and this visualization is provided below:

# Load sample data
df = data.frame(Region = c("North", "South", "East", "West"), Sales = c(100, 200, 300, 400))

# Create bar chart
ggplot(df, aes(x=Region, y=Sales, fill=Region)) +
  geom_bar(stat="identity") +
  scale_fill_manual(values=c("gray",
                             "gray",
                             "red",
                             "gray")) +
  labs(x="Region", y="Sales") +
  ggtitle("Sales by Region") +
  theme_bw() +
  theme(legend.position = "none")    

Size: The size of objects in a visualization can be used to represent aspects of data and draw attention to important information. For example, in a scatter plot, we could use the size of the points to represent the magnitude of a variable, making it easier to see which data points have higher or lower values. This is demonstrated in the scatterplot shown below.

Scatterplot with size as a preattentive attribute

The R code to produce this visualization is provided below (requires that the “ggplot2” package has been installed and loaded):

# Load sample data
df = data.frame(x=c(1,2,3,4,5), y=c(3,3,1,4,5), size=c(10,25,40,60,80))

# Create scatter plot
ggplot(df, aes(x=x, y=y, size=size)) +
  geom_point() +
  labs(x="Variable 1", y="Variable 2", size="Variable 3") +
  ggtitle("Scatter Plot with Point Size Representing a Third Variable") +
  theme_bw()

Shape: The shape of objects in a visualization can also be used as a preattentive attribute. For example, a scatter plot could use different shapes to represent different categories, allowing viewers to quickly see patterns and relationships between the categories. This is illustrated in the plot below.

Scatterplot with size as a preattentive attribute

The R code to produce this visualization is provided below:

# Load sample data
df = data.frame(x=c(1,2,3,4,5), y=c(4,5,3,4,1), category=c("A","B","A","B","A"))

# Create scatter plot
ggplot(df, aes(x=x, y=y, shape=category)) +
  geom_point(size = 5) +
  labs(x="Variable 1", y="Variable 2", shape="Category") +
  ggtitle("Scatter Plot with Point Shape Representing a Third Variable") +
  theme_bw()

Position: The position of objects in a visualization can also be used to convey information. For example, an outlier is easily identified in a scatterplot by its position relative to the other data points. This is illustrated in the scatterplot below.

Scatterplot with position as a preattentive attribute

The R code to produce this data and the plot is provided below:

# Create two clusters of non-outlier points in the lower left corner
set.seed(123)
X_cluster1 <- rnorm(25, mean = 5, sd = 1)
Y_cluster1 <- rnorm(25, mean = 5, sd = 1)
X_cluster2 <- rnorm(25, mean = 8, sd = 1)
Y_cluster2 <- rnorm(25, mean = 2, sd = 1)

# Combine the clusters and add the outlier
X <- c(X_cluster1, X_cluster2, 20)
Y <- c(Y_cluster1, Y_cluster2, 20)

# Combine the X and Y variables into a data frame
data <- data.frame(X, Y)

ggplot(data, aes(x = X, y = Y)) +
  geom_point() +
  labs(title = "Scatterplot of X and Y Variables",
       x = "X", y = "Y") +
  theme_bw()

Intensity: By varying the intensity of colors used to represent data points or areas in a chart, we can create visual contrast that can highlight important patterns or trends. For example, we might use a higher intensity of color to represent areas of high activity or concentration, while using a lower intensity for areas with lower values. This technique can help viewers quickly identify important information in the visualization without having to spend time processing every detail. In the scatterplot below, intensity of color is used to illustrate the magnitude of a third variable.

Scatterplot with color intensity as a preattentive attribute

The R code to produce this data and the plot is provided below:

# Create a sample data frame with 30 data points
set.seed(123)
data = data.frame(
  X = rnorm(30, 10, 3),
  Y = rnorm(30, 5, 2),
  Intensity = runif(30, 0.5, 1)
)

# Define a single color and different intensities
my_color = "#0072B2"
my_intensity = c(0.4, 0.7, 1)

# Create a scatterplot with intensity encoding the "Group" variable
ggplot(data, aes(x = X, y = Y, color = Intensity)) +
  geom_point(size = 4) +
  scale_color_gradient(low = "white", high = my_color, 
                      guide = guide_colorbar(reverse = TRUE), 
                      limits = c(min(my_intensity), max(my_intensity))) +
  labs(x = "X", y = "Y", title = "Intensity of color as a preattentive attribute in a scatterplot") +
  theme_bw() +
  theme(legend.position = "none")

There are additional preattentive attributes beyond these four. For example, we can use width, length, texture, movement, etc. to enhance our visualizations. The use of preattentive attributes in data visualization can significantly enhance perception and understanding. By incorporating these visual cues into your visualizations, you can help viewers quickly perceive patterns and relationships in data, leading to better insights and more informed decision-making.

How will you use preattentive attributes in your data visualizations?

Are you interested in learning more about data visualization using R? Click below to get notified about my upcoming book “Data Visualization in R”.

Each week we’ll feature a dataset that we find interesting, useful, etc. This week we highlight a dataset containing fundraising data for members of Congress. You’ll need to sign up for free access to the data.world site in order to download the dataset.

Feedback?

Did you enjoy this week’s newsletter? Do you have a topic, tool, or technique that you would like to see featured in a future edition? I’d love to hear from you!

Support the Newsletter?

Support this newsletter with a “coffee” (optional, but appreciated).

Start Your Own Newsletter?

This newsletter is created on and distributed via Beehiiv, the world’s best newsletter platform. Want to start your own newsletter? Click below to get started. Please note that this is an affiliate link. I may receive a small commission if you sign up for Beehiiv via this link.