Plotting and Visualization in Python
1. Enabling matplotlib
IPython in the most common Pylab mode (IPython --pylab)
2. matplotlib images are located in the Figure object.
Can be used to create a new Figure, can not draw through an empty Figure, must use add_subplot to create one or more subplot axes[0,1] can be sharedx and sharey to specify that the subplot should have the same x-axis or y-axis.
The spacing can be modified using Figure's subplots_adjust method. wspace and hspace are used to control the percentage of width and height that can be used as spacing between subplots.
3. Colors, markings and line patterns
(x,y,'g--')
4. Scale labels and examples
Chart decorations, implementation: use the procedural pyplot interface as well as the more object-oriented native matplotlib API.
5. Adding a legend (legend)
The legend is another important tool for identifying chart elements, and the easiest way to do this is to pass in the label parameter when adding a suplot:
fig = ();ax = add_subplot(1,1,1) (randn(1000).cumsum(),,'k',label='one')
6. Annotation and plotting on Subplot
Annotations can be added via functions such as text, arrow and annotate.
7. Save the chart to a file
Get a PNG image with a minimal white border and a resolution of 400 DPI.
('',dpi=400,bbox_inches='tight')
Where dpi dots per inch and bbox_inches cut out the blank space around the current chart.
8. matplotlib configuration
Using the rc method, ('figure',figuresize=(10,10)) the global default image size is 10x10
It can also be written as a dictionary:
font_options = {'family':'monospace','weight':'bold','size':'small'} ('font',**font_options)
9. Plotting functions in pandas
line graph:default situation histogram:bar;barh Histograms and density plots:Series(used form a nominal expression)histmethodologies、kin='kde' dispersion map:
Thanks for reading, I hope this helps, and thanks for supporting this site!