Skip to content
elevatedevco

Data & MLOps

Making charts and data visualization

A dense, practitioner-focused reference on data visualization for data scientists and ML engineers: chart selection by data type, perceptual and design pri

Intermediate34 questions34 quiz questionsCheat sheet

Questions & Answers

Tap a question to reveal its answer. Written for self-study and interview preparation.

What is data visualization?

Data visualization is the practice of representing data as charts, graphs, or maps so that patterns, trends, and insights are easier to understand. Instead of staring at rows of numbers, a well-designed chart lets your brain spot information quickly. It is used by scientists, businesses, and students to communicate findings clearly.

Which type of chart is best for showing how a value changes over time?

A line chart is best for showing how a value changes over time. Each point on the line represents a value at a specific moment, and the connecting line makes trends—like rising temperatures or growing website visits—easy to spot. Time always goes on the x-axis in a time-series line chart.

What is a bar chart used for?

A bar chart is used to compare quantities across different categories. Each bar's height (or length) represents the value for that category, making it easy to see which category is largest or smallest. For example, you could use a bar chart to compare the number of students who prefer different sports.

What does the x-axis typically represent in a chart?

The x-axis is the horizontal line running left-to-right along the bottom of a chart. It typically represents the independent variable—the thing you are measuring or the categories you are comparing, such as months, names, or age groups. The y-axis (vertical) then shows the measured values for each item on the x-axis.

What is a scatter plot and what kind of relationship can it reveal?

A scatter plot displays pairs of values as individual dots on a two-dimensional grid, with one variable on each axis. By looking at how the dots are arranged, you can see whether two variables are related—for example, whether taller students also tend to weigh more. A pattern of dots slanting upward suggests a positive relationship, while a random cloud of dots suggests no relationship.

What is a pie chart best used for, and when should you avoid it?

A pie chart is best used to show how a whole is divided into parts—for example, what percentage of a class prefers each type of music. You should avoid pie charts when there are many slices (more than 5-6), because it becomes very hard to compare slices of similar size. In those cases, a bar chart is usually clearer.

Why is it important to label the axes in a chart?

Axis labels tell the reader what the numbers on each axis represent and what units are used, like 'Temperature (°C)' or 'Number of Students.' Without labels, a chart is ambiguous—a viewer cannot know if the y-axis measures meters or miles, making the chart useless or even misleading. Clear labels are one of the most basic rules of honest data communication.

What is a histogram and how is it different from a bar chart?

A histogram shows the distribution of a single numerical variable by grouping values into ranges called 'bins' and drawing a bar for each bin whose height shows how many values fall in that range. Unlike a bar chart—which compares separate categories—histogram bars touch each other because the data is continuous with no gaps between ranges. For example, a histogram could show how many students scored between 60-70, 70-80, and 80-90 on a test.

What does a heatmap show and where is it useful?

A heatmap uses color intensity to represent the magnitude of values in a two-dimensional grid, where rows and columns represent two different categories and the cell color shows a third value. For example, a heatmap could show which hour of the day and which day of the week a website gets the most visitors, with darker or warmer colors meaning more traffic. They are great for spotting patterns in large tables of numbers at a glance.

What is the difference between correlation and causation in a scatter plot?

Correlation means two variables tend to change together—when one goes up, the other also tends to go up (or down), which shows as a pattern in a scatter plot. Causation means one variable actually causes the other to change. A famous example: ice cream sales and drowning rates both rise in summer, so they are correlated, but eating ice cream does not cause drowning—both are caused by hot weather. A scatter plot can show correlation but cannot prove causation.

Why can a pie chart be misleading when it has too many slices?

When a pie chart has many slices, especially ones of similar size, it becomes very hard for the human eye to judge which slice is bigger. Our brains are not good at comparing angles and areas as precisely as they compare bar heights. Researchers have found that people make more errors reading pie charts than bar charts, so a bar chart is usually preferred when comparing many categories.

What is Matplotlib and what is it used for in data science?

Matplotlib is a popular Python library used to create charts and graphs. With just a few lines of code, you can make line charts, bar charts, scatter plots, histograms, and much more. It is one of the most widely used data visualization libraries in data science and is often the first plotting tool young programmers learn.

import matplotlib.pyplot as plt
plt.plot([1, 2, 3], [4, 7, 5])
plt.title('My First Chart')
plt.show()
What does it mean when a chart has a 'truncated y-axis'?

A truncated y-axis is when the y-axis does not start at zero but instead starts at a higher value, which can make small differences between bars or lines look much larger than they really are. For example, if sales grew from 995 to 1000, starting the y-axis at 990 makes the bars look dramatically different even though the real difference is tiny. This is a common technique used—sometimes deliberately—to exaggerate changes and mislead viewers.

What is a box plot and what five summary values does it display?

A box plot (also called a box-and-whisker plot) summarizes the distribution of a dataset using five key values: the minimum, the first quartile (25th percentile), the median (50th percentile), the third quartile (75th percentile), and the maximum. The 'box' spans from the first to third quartile, the line inside shows the median, and the 'whiskers' extend to the minimum and maximum excluding outliers. It is very useful for comparing distributions across groups and spotting outliers at a glance.

What role does color play in data visualization?

Color in charts helps group related data, highlight important information, and make charts easier to read. Good color choices use distinct colors for different categories and a gradient (light-to-dark) for numerical scales. However, poor color choices—like using red and green together—can confuse about 8% of men who have red-green color blindness, so designers must choose color palettes that are accessible to everyone.

What is the 'data-ink ratio' concept introduced by Edward Tufte?

Edward Tufte, a famous statistician and designer, introduced the 'data-ink ratio' concept in his 1983 book 'The Visual Display of Quantitative Information.' It means that as much of the ink (or pixels) in a chart as possible should be used to display actual data, and everything else—decorative gridlines, unnecessary borders, 3D effects, background images—should be removed. A chart with a high data-ink ratio is clean and lets the data speak for itself, while a cluttered chart full of 'chartjunk' hides the message.

What is a legend in a chart?

A legend is a small box or label on a chart that explains what each color, line style, or symbol represents. For example, in a line chart showing temperature for multiple cities, the legend tells you which line belongs to which city. Without a legend, the viewer cannot distinguish between different data series in the chart.

Which chart type is best for comparing one measurement across two or more groups side by side?

A grouped (clustered) bar chart is best for comparing one measurement across two or more groups side by side. Each category has multiple bars placed next to each other—one per group—making direct comparison easy. For example, you could compare boys' and girls' average scores in math, science, and English using two bars placed side by side for each subject.

What is an outlier and how does it appear visually in a scatter plot?

An outlier is a data point that is very different from the rest of the data—much higher, lower, or far away from the general pattern. In a scatter plot, an outlier appears as a lone dot that sits far away from the main cluster of points. Outliers can be caused by measurement errors, unusual events, or genuinely extreme cases, and deciding whether to keep or remove them requires careful investigation rather than automatically deleting them.

When should you prefer a line chart over a bar chart for data over time?

A line chart is preferred when data is continuous over time and you want to show the trend or rate of change—like monthly rainfall over a year where the values flow from one month to the next. A bar chart is better when the time intervals represent distinct, separate periods and you want to emphasize the actual value at each point rather than the change between them—like total sales for each of five separate years. The key question is: are you emphasizing flow and trend, or individual totals?

Why should every chart have a clear, specific title?

A chart title tells the reader immediately what the chart is about, so they know what question the visualization is answering before they start reading the data. Without a title, a reader must guess the chart's purpose, which wastes time and can lead to misinterpretation. A good title is specific, like 'Average Monthly Rainfall in Mumbai (2020-2024)' rather than just 'Rainfall.'

What is Seaborn in Python and how does it improve on basic Matplotlib?

Seaborn is a Python data visualization library built on top of Matplotlib that makes it easier to create attractive and informative statistical charts with much less code. While Matplotlib gives you full control but requires many lines of code for nice-looking charts, Seaborn provides built-in themes and ready-made functions for common statistical plots like violin plots, pair plots, and heatmaps. It also integrates smoothly with pandas DataFrames, making exploratory data analysis faster.

import seaborn as sns
import matplotlib.pyplot as plt
sns.histplot([12, 15, 13, 18, 20, 11, 17], bins=5)
plt.show()  # Much simpler than raw Matplotlib
What is a stacked bar chart and when is it most useful?

A stacked bar chart divides each bar into segments, where each segment represents a sub-category and the total height of the bar represents the overall total. It is useful when you want to show both the total value and how it is composed—for example, showing total daily screen time split into social media, gaming, and studying for each day of the week. However, it becomes hard to read when there are many sub-categories, because only the bottom segment has a consistent baseline to compare across bars.

What is 'overplotting' in scatter plots and how can you fix it?

Overplotting occurs when thousands of data points are plotted on a scatter plot and so many dots overlap that you cannot see the actual distribution—the chart looks like a solid dark blob. Common fixes include making dots semi-transparent using an 'alpha' value, switching to a 2D density or hexbin plot that shows where points are most concentrated, or plotting a random sample of the data. Overplotting hides important patterns and makes dense areas look the same as sparse ones.

import matplotlib.pyplot as plt
# alpha=0.1 makes each dot 90% transparent
plt.scatter(x, y, alpha=0.1)
plt.show()
What is a bubble chart and what extra dimension does it add compared to a scatter plot?

A bubble chart is like a scatter plot but each dot (bubble) has a size that represents a third variable, allowing you to display three dimensions of data in a 2D chart. For example, a bubble chart of countries could plot GDP on the x-axis, life expectancy on the y-axis, and use bubble size to show population. This allows spotting complex patterns, but it can be harder to read since human eyes are not precise at comparing circle areas.

What is the difference between continuous data and categorical data, and which chart type suits each?

Continuous data can take any numeric value within a range—like height, temperature, or time—and is best shown with histograms, line charts, or scatter plots. Categorical data represents distinct groups or labels—like favorite colors or types of fruit—and is best shown with bar charts or pie charts. Using the wrong chart type for your data, like a pie chart for temperature readings, makes the visualization confusing and meaningless.

How can a 3D chart be misleading even when the data is accurate?

Three-dimensional charts (like 3D bar charts or 3D pie charts) can distort data because the perspective view makes some bars or slices appear bigger or smaller than they really are, depending on their position relative to the viewer. The extra visual dimension adds no actual data information—it is purely decorative 'chartjunk' that makes comparisons less accurate. Most data scientists and statisticians avoid 3D charts and prefer clean 2D charts instead.

What ethical issues can arise from deliberately poorly designed charts?

Charts can be deliberately designed to mislead viewers by using tricks like truncating the y-axis, cherry-picking time ranges, applying 3D distortion, or showing only partial data. These techniques can unfairly influence public opinion, mislead voters, exaggerate company results, or hide the true severity of a health or environmental problem. Honest data visualization requires showing complete data, starting axes at zero when appropriate, and being transparent about what data was included or excluded.

What is a choropleth map and what does it show?

A choropleth map uses color shading on geographic regions—like countries, states, or districts—to represent the value of a variable in each region. For example, a choropleth map of India could shade each state a different intensity of blue based on its literacy rate, with darker blue meaning higher literacy. They are powerful for showing geographic patterns, but you must be careful because large physical areas can visually dominate even when they have small populations.

What does a trend line (line of best fit) in a scatter plot tell you?

A trend line, also called a line of best fit or regression line, is a straight (or curved) line drawn through the middle of scatter plot points to show the overall direction and strength of the relationship between two variables. If the line slopes upward, there is a positive relationship (both variables tend to increase together); if it slopes downward, there is a negative relationship. The closer the points are to the line, the stronger the relationship.

What is color blindness and why must chart designers always consider it?

Color blindness is a condition where a person's eyes cannot distinguish between certain colors—most commonly red and green—due to differences in the cone cells of the eye. About 8% of males and 0.5% of females have some form of color blindness, meaning roughly 1 in 12 male readers may not be able to tell the difference between red and green elements in a chart. Designers should use colorblind-friendly palettes, add patterns or different shapes, and never rely on color alone to convey critical information.

What is interactive data visualization and how does it differ from a static chart?

An interactive data visualization allows the viewer to actively explore the data by hovering, clicking, filtering, or zooming—for example, hovering over a bar to see the exact value, or clicking a country on a map to see its detailed statistics. Unlike a static chart (like a printed image) that shows only one fixed view, interactive charts can display far more information without cluttering the display, since details appear only when requested. Tools like Plotly in Python and Tableau are popular for creating interactive charts.

What is a violin plot and what information does it show that a box plot does not?

A violin plot combines a box plot with a kernel density plot to show the full shape of the data distribution along with summary statistics. While a box plot only shows the quartiles and range, a violin plot reveals whether the data has one peak (unimodal) or two peaks (bimodal), and whether most values are bunched at the top or bottom of the range. It is very useful for comparing distributions across groups when the shape of the distribution matters, not just the median.

What is the 'small multiples' technique in data visualization?

Small multiples (also called 'trellis charts' or 'facet grids') is a technique where the same chart type is repeated many times in a grid, each panel showing a subset of the data for one category or time period. This makes it easy to compare patterns across many groups simultaneously without the single chart becoming cluttered or overloaded. For example, instead of one messy scatter plot with 10 overlapping colored groups, you would show 10 small scatter plots side by side, one per group.

import seaborn as sns
# Each panel shows one category
g = sns.FacetGrid(data, col='category')
g.map(sns.scatterplot, 'x', 'y')

Put it into practice with AI Learning

This topic — and hundreds more — comes from our free, offline AI Learning app. Practice Q&A, quizzes and cheat sheets anywhere, no account needed.

  • Free
  • No account
  • Works offline
Coming soon toGoogle Play