https://kolibril13.github.io/plywood-gallery-matplotlib-examples/
https://matplotlib.org/stable/plot_types/basic/index.html
Introduction to Data Visualization with Matplotlib
-
Pyplot Interface Introduction:
-
Adding Data to Axes:
-
Combining Multiple Data Sets:
-
Customizing Plots:
-
Axes Labels and Titles:
-
Creating Subplots:
-
Subplots Customization:
Time-series Data with Matplotlib
To create a DataFrame for climate_change
, you can follow a structure similar to this:
Replace the ellipses (...
) with your actual data. This code sets up a DataFrame with date, CO2, and temperature data, converting the date column to a datetime format and setting it as the index, which is typical for time-series data.
-
Plotting Basic Time-series Data:
-
Zooming into Specific Time Frames:
- Decade Zoom:
- Year Zoom:
-
Plotting Multiple Time-series Together:
-
Using Twin Axes for Different Variables:
-
Differentiating Variables by Color:
-
Customizing Annotations on Time-series Plots:
- Basic Annotation:
- With Text Positioning and Arrows:
-
Creating a Function for Time-series Plotting:
Each section provides practical instructions and code snippets for effectively visualizing and analyzing time-series data using Matplotlib in Python.
Quantitative Comparisons: Bar-Charts
- Olympic Medals Data: Presents a dataset on Olympic medals and demonstrates basic bar chart plotting.
- Rotating Tick Labels: Shows how to rotate axis labels for clarity.
- Visualizing Multiple Medal Types: Explains stacking bars for different medal types (Gold, Silver, Bronze).
- Adding a Legend: Illustrates how to add a legend to distinguish between different bars.
- Histograms: Discusses creating histograms to represent distribution of data.
- Error Bars in Bar Charts: Teaches how to add error bars to bar charts for statistical representation.
- Boxplots: Describes creating boxplots for data distribution analysis.
- Scatter Plots: Introduces scatter plots for comparing two quantitative variables.
Here are example codes for each key point from “Quantitative Comparisons: Bar-Charts”:
-
Olympic Medals Data:
-
Rotating Tick Labels:
-
Visualizing Multiple Medal Types:
-
Adding a Legend:
-
Histograms:
-
Error Bars in Bar Charts:
-
Boxplots:
-
Scatter Plots:
These examples provide a basic structure for each type of plot, which you can adapt and expand upon based on your specific data and visualization needs.
Preparing Your Figures to Share with Others
The document “Preparing Your Figures to Share with Others” discusses various aspects of refining and saving Matplotlib figures for presentation and sharing. Here are the key points with corresponding Python code examples:
-
Changing Plot Style:
-
Choosing a Style:
-
Saving the Figure to File:
-
Different File Formats:
- Saving as JPEG:
- Saving as SVG:
-
Resolution:
-
Size:
-
Automating Figures from Data:
Each section provides guidelines and examples for effectively preparing and customizing figures in Matplotlib to enhance their communicative power and suitability for various sharing formats.