cover
Title Page
Copyright
Matplotlib 2.x By Example
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Why subscribe?
Customer Feedback
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
Hello Plotting World!
Hello Matplotlib!
What is Matplotlib?
What's new in Matplotlib 2.0?
Changes to the default style
Color cycle
Colormap
Scatter plot
Legend
Line style
Patch edges and color
Fonts
Improved functionality or performance
Improved color conversion API and RGBA support
Improved image support
Faster text rendering
Change in the default animation codec
Changes in settings
New configuration parameters (rcParams)
Style parameter blacklist
Change in Axes property keywords
Setting up the plotting environment
Setting up Python
Windows
Using Python
macOS
Linux
Installing the Matplotlib dependencies
Installing the pip Python package manager
Installing Matplotlib with pip
Setting up Jupyter notebook
Why Jupyter notebook?
Installing Jupyter notebook
Using Jupyter notebook
Starting a Jupyter notebook session
Editing and running code
Jotting down notes in Markdown mode
Viewing Matplotlib plots
Saving the notebook project
All set to go!
Plotting our first graph
Loading data for plotting
Data structures
List
Numpy array
pandas dataframe
Loading data from files
The basic Python way
The Numpy way
The pandas way
Importing the Matplotlib pyplot module
Plotting a curve
Viewing the figure
Saving the figure
Setting the output format
PNG (Portable Network Graphics)
PDF (Portable Document Format)
SVG (Scalable Vector Graphics)
Post (Postscript)
Adjusting the resolution
Summary
Figure Aesthetics
Basic structure of a Matplotlib figure
Glossary of objects in a Matplotlib figure
Setting colors in Matplotlib
Single letters for basic built-in colors
Names of standard HTML colors
RGB or RGBA color code
Hexadecimal color code
Depth of grayscale
Using specific colors in the color cycle
Aesthetic and readability considerations
Adjusting text formats
Font
Font appearance
Font size
Font style
Font weight
Font family
Checking available fonts in system
LaTeX support
Customizing lines and markers
Lines
Choosing dash patterns
Setting capstyle of dashes
Advanced example
Markers
Choosing markers
Adjusting marker sizes
Customizing grids ticks and axes
Grids
Adding grids
Ticks
Adjusting tick spacing
Removing ticks
Drawing ticks in multiples
Automatic tick settings
Setting ticks by the number of data points
Set scaling of ticks by mathematical functions
Locating ticks by datetime
Customizing tick formats
Removing tick labels
Fixing labels
Setting labels with strings
Setting labels with user-defined functions
Formatting axes by numerical values
Setting label sizes
Trying out the ticker locator and formatter
Rotating tick labels
Axes
Nonlinear axis
Logarithmic scale
Changing the base of the log scale
Advanced example
Symmetrical logarithmic scale
Logit scale
Using style sheets
Applying a style sheet
Resetting to default styles
Customizing a style sheet
Title and legend
Adding a title to your figure
Adding a legend
Test your skills
Summary
Figure Layout and Annotations
Adjusting the layout
Adjusting the size of the figure
Adjusting spines
Adding subplots
Adding subplots using pyplot.subplot
Using pyplot.subplots() to specify handles
Sharing axes between subplots
Adjusting margins
Setting dimensions when adding subplot axes with figure.add_axes
Modifying subplot axes dimensions via pyplot.subplots_adjust
Aligning subplots with pyplot.tight_layout
Auto-aligning figure elements with pyplot.tight_layout
Stacking subplots of different dimensions with subplot2grid
Drawing inset plots
Drawing a basic inset plot
Using inset_axes
Annotations
Adding text annotations
Adding text and arrows with axis.annotate
Adding a textbox with axis.text
Adding arrows
Labeling data values on a bar chart
Adding graphical annotations
Adding shapes
Adding image annotations
Summary
Visualizing Online Data
Typical API data formats
CSV
JSON
XML
Introducing pandas
Importing online population data in the CSV format
Importing online financial data in the JSON format
Visualizing the trend of data
Area chart and stacked area chart
Introducing Seaborn
Visualizing univariate distribution
Bar chart in Seaborn
Histogram and distribution fitting in Seaborn
Visualizing a bivariate distribution
Scatter plot in Seaborn
Visualizing categorical data
Categorical scatter plot
Strip plot and swarm plot
Box plot and violin plot
Controlling Seaborn figure aesthetics
Preset themes
Removing spines from the figure
Changing the size of the figure
Fine-tuning the style of the figure
More about colors
Color scheme and color palettes
Summary
Visualizing Multivariate Data
Getting End-of-Day (EOD) stock data from Quandl
Grouping the companies by industry
Converting the date to a supported format
Getting the percentage change of the closing price
Two-dimensional faceted plots
Factor plot in Seaborn
Faceted grid in Seaborn
Pair plot in Seaborn
Other two-dimensional multivariate plots
Heatmap in Seaborn
Candlestick plot in matplotlib.finance
Visualizing various stock market indicators
Building a comprehensive stock chart
Three-dimensional (3D) plots
3D scatter plot
3D bar chart
Caveats of Matplotlib 3D
Summary
Adding Interactivity and Animating Plots
Scraping information from websites
Non-interactive backends
Interactive backends
Tkinter-based backend
Interactive backend for Jupyter Notebook
Plot.ly-based backend
Creating animated plots
Installation of FFmpeg
Creating animations
Summary
A Practical Guide to Scientific Plotting
General rules of effective visualization
Planning your figure
Do we need the plot?
Choosing the right plot
Targeting your audience
Crafting your graph
The science of visual perception
The Gestalt principles of visual perception
Getting organized
Ordering plots and data series logically
Grouping
Giving emphasis and avoiding clutter
Color and hue
Size and weight
Spacing
Typography
Use minimal marker shapes
Styling plots for slideshows posters and journal articles
Display time
Space allowed
Distance from the audience
Adaptations
Summary of styling plots for slideshows posters and journal articles
Visualizing statistical data more intuitively
Stacked bar chart and layered histogram
Replacing bar charts with mean-and-error plots
Indicating statistical significance
Methods for dimensions reduction
Principal Component Analysis (PCA)
t-distributed Stochastic Neighbor Embedding (t-SNE)
Summary
Exploratory Data Analytics and Infographics
Visualizing population health information
Map-based visualization for geographical data
Combining geographical and population health data
Survival data analysis on cancer
Summary
更新时间:2021-07-02 19:35:17