DEV Experiment No.3
DEV Experiment No.3
EXPERIMENT NO. 3
Title:
Implementing Line Plots, Area Plots, Histograms, Bar Charts, Pie Charts, Bubble Plots, Waffle
Charts, and Word Clouds on Sample Data Points
Objective:
To create and interpret various types of plots including line plots, area plots, histograms, bar charts,
pie charts, bubble plots, waffle charts, and word clouds using sample data points.
Brief Theory:
Introduction: Visualization is a powerful tool for understanding data. Different types of plots can
reveal different aspects of the data. This experiment covers a wide range of plot types to provide a
comprehensive understanding of data visualization techniques.
text = "data science machine learning data visualization word cloud python matplotlib seaborn
numpy pandas"
plt.figure(figsize=(10, 6))
plt.fill_between(data['x'], data['y'], color="skyblue", alpha=0.4)
plt.plot(data['x'], data['y'], color="Slateblue", alpha=0.6)
plt.title('Area Plot')
plt.xlabel('X-axis')
plt.ylabel('Y-axis')
plt.show()
Step 5: Histogram
Create a histogram using the sample data points.
Code:-
plt.figure(figsize=(10, 6))
plt.hist(data['y'], bins=5, color='skyblue', edgecolor='black')
plt.title('Histogram')
plt.xlabel('Value')
plt.ylabel('Frequency')
plt.show()
plt.show()
plt.figure(figsize=(10, 6))
plt.pie(data['y'], labels=data['x'], autopct='%1.1f%%', startangle=140)
plt.title('Pie Chart')
plt.show()
plt.show()
categories = data['x']
values = data['y']
make_waffle_chart(categories, values, 10, 10, plt.cm.coolwarm)
Conclusion: -
In this experiment, we successfully implemented various types of plots including line plots, area plots,
histograms, bar charts, pie charts, bubble plots, waffle charts, and word clouds using sample data
points. Each type of plot provides unique insights and visual representations of the data, which are
essential for data analysis and interpretation.
Practice Questions:
1. Using the data below, create a bubble plot where the x-axis represents the GDP (in trillion
USD), the y-axis represents the population (in millions), and the size of the bubble represents
the carbon emissions (in million tons): Country A: GDP - 3, Population - 150,
Emissions - 500; Country B: GDP - 5, Population - 200, Emissions - 800;
Country C: GDP - 2, Population - 100, Emissions - 300; Country D: GDP - 4,
Population - 250, Emissions - 600. What insights can you gain from the bubble plot?
2. Given the following data for five products and their respective sales in units: Product A: 120,
Product B: 180, Product C: 140, Product D: 200, Product E: 160, create a bar chart
to represent the data. Which product had the highest and lowest sales?
3. A company’s revenue is divided into four categories: Product Sales: 40%, Services: 30%,
Investments: 20%, Other: 10%. Create a pie chart to represent the revenue distribution.
How well does the pie chart represent the proportion of revenue from each category?
4. Generate a histogram using random normal data points (mean = 0, standard deviation = 1) and
describe the shape of the distribution.
FAQs in Interviews
Q: What are the key factors to consider when choosing a type of chart or plot for data
visualization?
A: The key factors include the nature of the data (quantitative or categorical), the message you want to
convey, the complexity of the data, and the audience's familiarity with the chart types. For instance, line
plots are great for trends over time, while pie charts are best for showing parts of a whole.
A: To avoid misleading visualizations, ensure that the scale is appropriate, data points are not omitted,
colors and labels are clear, and the chart type chosen accurately reflects the data relationship. It’s also
important to provide context and avoid manipulating the visual to exaggerate findings.
Q: What challenges have you faced in data visualization, and how did you overcome them?
A: Common challenges include dealing with large datasets, choosing the correct visualization for
complex data, and ensuring that the visualization is accessible and understandable to the audience.
Overcoming these challenges often involves simplifying the data, using interactivity, or combining
multiple visualizations for clarity.
A: Important data points can be highlighted using markers, annotations, or different colors for specific
sections of the line. You can also add trend lines or emphasize peaks and troughs with callouts.
A: The shape of a histogram can indicate the distribution of the data (e.g., normal, skewed, bimodal).
A symmetrical bell-shaped histogram suggests a normal distribution, while a skewed histogram
indicates that the data has a longer tail on one side.