Plotting and Data Visualization
Plotting and Data Visualization
•Key Benefits:
•Makes complex data easier to understand.
•Improves decision-making.
•Reveals relationships between variables.
•3. Histogram:
•Used for continuous data to show the distribution.
•Bins data into intervals.
•Example: A bar chart showing the number of students in different grade categories (A, B, C, etc.).
hours_studied = [1, 2, 3, 4, 5, 6, 7, 8, 9]
exam_scores = [55, 60, 65, 70, 72, 75, 78, 80, 85]
•Example: Box plot showing the test scores of students in multiple classes.
data = [ [70, 80, 90, 85, 88], [60, 65, 70, 75, 80], [85, 90, 95, 92, 98] ]
plt.boxplot(data, patch_artist=True, boxprops=dict(facecolor='skyblue', color='black'))
plt.xlabel('Classes')
plt.ylabel('Test Scores')
plt.title('Test Scores Distribution Across Three Classes')
plt.show()
Best Practices for Data Visualization
• Choose the right chart type: Select the visualization that best suits your data (e.g., bar chart for
categories, line plot for trends).
• Label everything: Axis labels, chart title, legend, and data points for clarity.
• Use color effectively: Ensure color contrast for readability and use colors that make sense.
• Be mindful of scale: Make sure the axis scales are appropriate for the data range.