Unit 4: Data Plotting and Visualization

ECAP792 11 min read

I. Foundations and Governing Principles

Data visualization is the systematic representation of data through graphical marks, spatial arrangements, and visual properties. Its governing principle is that a graphic should make patterns, comparisons, relationships, and uncertainty easier to perceive without distorting the underlying evidence.

  • Purpose: Visualization converts numerical, categorical, spatial, or temporal data into forms that support exploration, explanation, and decision-making.
  • Data-to-visual pipeline:
    • Acquire: Obtain data from surveys, databases, sensors, files, or APIs.
    • Prepare: Clean missing values, correct data types, and calculate required measures.
    • Encode: Map variables to position, length, color, size, shape, or other visual channels.
    • Render: Produce the chart using software or a programming library.
    • Interpret: Examine patterns while considering scale, context, and uncertainty.
  • Core conventions: Titles identify purpose; axes state variables and units; legends explain encodings; annotations identify important values; sources establish provenance.
  • Accuracy principle: Visual proportions must correspond to data proportions. For example, a bar representing 40 units should be twice as long as one representing 20 units.
  • Audience principle: Chart complexity, terminology, interaction, and detail should match the viewers’ knowledge and intended task.
  • Ethical principle: Designers should not conceal observations, manipulate scales, misuse color, or imply unsupported causal relationships.
  • Accessibility principle: Meaning should not depend on color alone; readable labels, adequate contrast, and alternative descriptions should be provided.

II. Introduction to Data Visualization — Turning Data into Visible Evidence

A. Introduction to data visualization

Data visualization uses graphical representations to communicate the structure and meaning of data more efficiently than raw tables alone.

  • Exploratory visualization: Analysts create charts while investigating data, such as a histogram used to discover skewness or unusual observations.
  • Explanatory visualization: A refined figure communicates a selected finding, such as an annotated line chart showing when sales began to decline.
  • Primary tasks:
    • Comparison: Determine which category has the highest value.
    • Trend detection: Observe how a measurement changes over time.
    • Distribution analysis: Examine center, spread, skewness, and outliers.
    • Relationship analysis: Identify association between variables.
    • Composition analysis: Show how parts contribute to a whole.
  • Context: A value of 75 is interpretable only when its variable, unit, time period, population, and comparison point are known.
  • Integrity: Three-dimensional decoration, truncated axes, and inconsistent intervals can exaggerate or obscure differences.

B. Applications and limitations

Visualization strengthens analysis, but a chart remains a model rather than the data itself.

  • Applications: Dashboards monitor operations, maps reveal geographic patterns, and scientific figures communicate experimental results.
  • Pattern advantage: A scatter plot can reveal clusters that are difficult to detect in hundreds of table rows.
  • Aggregation limitation: A monthly average can hide daily volatility or differences among subgroups.
  • Causality limitation: A visible correlation does not establish that one variable causes another.
  • Data-quality limitation: Missing, biased, duplicated, or incorrectly measured data produce misleading graphics even when chart construction is technically correct.

III. Visual Encoding — Mapping Variables to Perceptual Channels

A. Visual encoding

Visual encoding assigns data fields to marks and visual channels so that values become perceptible graphical differences.

  • Marks: Geometric objects represent observations or groups:
    • Points: Individual cases in a scatter plot.
    • Lines: Connections or ordered sequences in a time series.
    • Areas: Magnitudes in bars, maps, or filled regions.
  • Channels: Properties of marks carry information, including position, length, angle, area, color, shape, and orientation.
  • Effectiveness hierarchy: Position on a common scale usually enables more accurate comparison than length, angle, area, or color intensity.
  • Variable matching:
    • Quantitative: Encode values such as income in position or length.
    • Ordinal: Encode ordered classes such as low, medium, and high with ordered lightness.
    • Nominal: Encode unordered groups such as departments with distinct hues or shapes.
  • Redundant encoding: Representing a category by both color and shape improves accessibility and recognition.
  • Scale mapping: For a linear position scale,
TEXT
p = p_min + ((x - x_min) / (x_max - x_min)) × (p_max - p_min)

Here, x is a data value, x_min and x_max are the data bounds, and p, p_min, and p_max are the corresponding display positions.

B. Encoding accuracy and limitations

An encoding should maximize perceptual accuracy while preventing visual channels from implying the wrong relationship.

  • Zero baseline: Bar length represents magnitude, so bar charts generally require a zero baseline; otherwise, small differences appear disproportionately large.
  • Color choice: Sequential palettes suit increasing values, diverging palettes emphasize deviation from a midpoint, and qualitative palettes distinguish categories.
  • Area limitation: Doubling a circle’s radius quadruples its area, so size encodings must scale area—not radius—proportionally to value.
  • Overplotting: Thousands of overlapping points can hide density; transparency, sampling, jittering, binning, or aggregation can reduce the problem.
  • Dual-axis risk: Two vertical scales can be adjusted to manufacture apparent agreement between unrelated series.

IV. Data Visualization Software — Platforms for Creating and Sharing Graphics

A. Data visualization software

Data visualization software provides interfaces for importing, transforming, plotting, and distributing data-driven graphics.

  • Spreadsheet software: Microsoft Excel and LibreOffice Calc support tables, pivot summaries, conditional formatting, and standard charts.
  • Business-intelligence software: Tableau and Microsoft Power BI connect multiple sources and create interactive dashboards with filters and drill-down operations.
  • Statistical software: R environments, SAS, SPSS, and Stata combine statistical analysis with publication-oriented graphics.
  • Notebook environments: Jupyter Notebook integrates executable code, output, equations, and narrative in one reproducible document.
  • Selection criteria: Choice depends on data volume, chart requirements, collaboration, automation, cost, governance, and user expertise.
  • Deployment: A static PNG suits a report, an SVG supports resolution-independent publishing, and an interactive web dashboard supports user-selected views.

B. Applications and limitations

Software should be evaluated by whether it supports a reliable workflow rather than merely producing attractive output.

  • Advantages: Graphical interfaces enable rapid chart construction, while templates help maintain organizational consistency.
  • Reproducibility: Scripted or recorded transformations are preferable when charts must be updated repeatedly.
  • Vendor limitation: Proprietary formats, license costs, and platform-specific services can restrict portability.
  • Automation limitation: Recommended-chart features cannot determine whether a visual matches the analytical question.
  • Governance: Published dashboards require controlled data access, refresh schedules, versioning, and documented metric definitions.

V. Data Visualization Libraries — Programmable and Reproducible Graphics

A. Data visualization libraries

Visualization libraries are reusable code packages that translate data and plotting instructions into static or interactive graphics.

  • Python ecosystem: Matplotlib provides low-level control; Seaborn supplies statistical defaults; Plotly and Bokeh support interaction; Altair uses a declarative grammar.
  • R ecosystem: ggplot2 builds graphics through layers based on data, mappings, geometric marks, scales, and themes.
  • JavaScript ecosystem: D3.js binds data to web-document elements, while Vega-Lite specifies charts through a declarative JSON grammar.
  • Reproducibility: Code preserves transformations, filters, labels, and style settings, allowing the same figure to be regenerated with new data.
  • Example:
PYTHON
import seaborn as sns
sns.scatterplot(data=df, x="height_cm", y="weight_kg", hue="group")

Here, df is a tabular dataset; height_cm and weight_kg are quantitative columns; group is a categorical column encoded by color.

B. Applications and limitations

Libraries are especially valuable when customization, automation, or integration with analysis is required.

  • Applications: A script can generate hundreds of consistent regional charts or rebuild a report after each data refresh.
  • Control: Programmers can define scales, annotations, facets, themes, and export formats precisely.
  • Learning cost: Effective use requires knowledge of programming, data structures, and library conventions.
  • Dependency risk: Version changes may alter output or break code, so environments and package versions should be recorded.
  • Performance: Browser-based charts may become slow when they attempt to render millions of individual marks.

VI. Basic Data Visualization Tools — Accessible Methods for Routine Analysis

A. Basic data visualization tools

Basic tools provide straightforward chart creation for small or moderately sized datasets with limited programming.

  • Tables: Sorting, filtering, and conditional formatting reveal exact values and simple ranking patterns.
  • Spreadsheet charts: Bar, line, pie, scatter, and histogram tools support common comparisons without code.
  • Pivot charts: Aggregation by category and time allows users to summarize measures such as total sales by region.
  • Chart builders: Drag-and-drop interfaces map fields to axes, color, labels, and filters.
  • Workflow: Select a clean rectangular data range, choose a chart suited to the analytical task, label variables and units, and remove unnecessary decoration.
  • Best use: Basic tools are suitable for classroom analysis, administrative reporting, prototypes, and one-time presentations.

B. Applications and limitations

Basic tools prioritize speed and accessibility but provide less control over complex analysis and deployment.

  • Strengths: Immediate visual feedback makes them effective for users without programming experience.
  • Transparency: Visible formulas and pivot settings can make small analyses easy to inspect.
  • Scale limitation: Large datasets, frequent updates, and many linked sources can make spreadsheet workflows fragile.
  • Error risk: Manual range selection, copied formulas, and hidden cells can introduce unnoticed mistakes.
  • Design limitation: Default colors, legends, and axis settings often require deliberate correction before publication.

VII. Advanced Data Visualization Tools — Interactive, Multidimensional, and Specialized Systems

A. Advanced data visualization tools

Advanced tools handle complex data, specialized visual forms, interactive exploration, and scalable delivery.

  • Interactive dashboards: Filters, brushing, linked views, tooltips, and drill-down controls let users examine different levels of detail.
  • Geospatial systems: QGIS, ArcGIS, and web-mapping frameworks combine coordinates, boundaries, projections, and thematic layers.
  • Network visualization: Node-link diagrams and adjacency matrices represent entities and relationships, such as users connected by messages.
  • Large-scale rendering: Aggregation, server-side queries, tiled maps, and GPU acceleration support datasets too large to draw mark by mark.
  • Specialized outputs: Animated timelines, three-dimensional scientific views, and immersive displays can represent change or spatial structure.
  • Analytical integration: Advanced platforms may incorporate forecasting, clustering, anomaly detection, or calculated metrics.

B. Applications and limitations

Advanced capabilities are justified only when interaction or specialized structure contributes directly to understanding.

  • Applications: A public-health map can link geographic regions to time-series panels and demographic filters.
  • Cognitive cost: Excessive controls, motion, dimensions, or simultaneous views can overwhelm users.
  • Three-dimensional limitation: Perspective and occlusion make accurate value comparison difficult on ordinary two-dimensional screens.
  • Operational cost: Advanced systems require data pipelines, hosting, access control, testing, maintenance, and performance monitoring.
  • Validation: Every filter state and linked view must preserve consistent definitions and totals.

VIII. Data Visualization Types — Matching the Chart to the Analytical Task

A. Data visualization types

Visualization types should be selected according to the question, variable types, and relationships that need to be displayed.

  • Comparison: Bar charts compare categorical magnitudes; dot plots offer a compact alternative when many categories are present.
  • Temporal change: Line charts show ordered observations over time, while area charts emphasize cumulative magnitude.
  • Distribution: Histograms group quantitative values into bins; box plots summarize median, quartiles, spread, and possible outliers; violin plots add density shape.
  • Relationship: Scatter plots compare two quantitative variables; bubble charts add a third variable through area; heat maps encode values in a matrix using color.
  • Composition: Stacked bars show part-to-whole relationships across categories; pie charts are most readable with few, clearly different proportions.
  • Geospatial pattern: Choropleth maps shade regions by normalized rates, while proportional-symbol maps represent totals with symbol area.
  • Hierarchy and flow: Treemaps display nested composition; Sankey diagrams encode flows by band width; network diagrams represent links among entities.
  • Small multiples: Repeating the same axes across panels enables consistent comparison among groups.

B. Selection principles and limitations

A chart type is effective when its visual structure corresponds directly to the analytical task and data semantics.

  • Counts versus rates: Mapping population counts by region may mainly reproduce population size; a rate per 100,000 people often supports fairer comparison.
  • Bin sensitivity: Histogram shape depends on bin width, while choropleth interpretation depends on class boundaries.
  • Ordering: Ranking bars by value improves comparison, whereas chronological and ordinal categories should retain meaningful order.
  • Normalization: A 100% stacked bar emphasizes proportions, but an ordinary stacked bar preserves totals.
  • Uncertainty: Confidence intervals, error bars, ranges, or probability bands should accompany estimates where sampling or measurement uncertainty matters.
  • Final criterion: The simplest chart that accurately answers the intended question is generally preferable to a more decorative or technically elaborate alternative.