A, matplotlib data visualization

Reference Source: "Python Data Science Handbook," Chapter 4

Description: Notes

table of Contents:

1, Matplotlib General Tips

  1.1 Import Matplotlib

  1.2 provided drawing style

  1.3 with no show ()? How to display graphics

  1.4 Save the graphics file

2 Both interfaces Paint

  2.1 MATLAB Interface style

  2.2 Object-Oriented Interface

3, a simple line graph

  3.1 Adapting Graphics: line color and style

  3.2 adjusting pattern: the lower limit coordinate axes

  3.3 Setting Graphic labels

4, simple scatter plot

  4.1 Scatter painting with plt.plot

  4.2 Scatter painting with plt.scatter

  4.3 plot and scatter: Efficiency Comparison

5, exception handling Visualization

  5.1 Basic error line

  5.2 Continuous Error bars

6, and FIG density contour plots

  Three-dimensional view visualization 6.1

7, frequency histogram, and the distribution density data interval into

8, configuration legend

  8.1 Select the legend elements displayed

  8.2 points of different sizes displayed in the legend

  Simultaneously displaying a plurality of legends 8.3

9, a color bar configuration

  9.1 Configuring color bar

  Case 9.2: Digital Handwriting

10, the multi subgraph

  10.1 plt.axes: Manually create a child diagram

  10.2 plt.subplot: Simple Grid subgraph

  10.3 plt.subplots: create a grid with a single line of code

  10.4 plt.GridSpec: more complex arrangement

11, text and notes

  11.1 Case: Holidays on the US birth rate

  11.2 coordinate transformation and text position

  11.3 arrows and notes

12, custom axis scale

  12.1 major scale and a minor scale

  12.2 hide the scale and label

  12.3 increase or decrease the number of tick

  12.4 fancy scale format

  12.5 format generation with locator Summary

13, Matplotlib custom: the configuration file and stylesheets

  13.1 Manually configure graphics

  13.2 modify the default configuration: rcParams

  13.3 stylesheet

14, a three-dimensional drawing Matplotlib

  14.1 dimensional data points and lines

  14.2 dimensional contour

  FIG wireframe and surface 14.3

  14.4 curved triangular part

15, with the geographic data visualization Basemap

  15.1 Map Projection

  15.2 Draw a map background

  15.3 picture data on the map

  15.4 Case: California city data

  15.5 Case: Surface temperature data

16, for data visualization with Seaborn

  16.1 Seaborn与Matplotlib

  16.2 Seanborn graphical presentation

  16.3 Case: Exploring marathon performance data

17 references

  17.1 Matplotlib resources

  17.2 Other Paint Python library

 

1, Matplotlib General Tips

  1.1 Import Matplotlib

      

  1.2 provided drawing style

            

  1.3 with no show ()? How to display graphics

      Three kinds of development environments: script, IPython shell and IPython Notebook

      In the script , use matplotlib, display graphics must plt.show (), plt.show () will start an event loop (event loop), and find all the currently available graphical objects, and then open one or more interactive window display graphics, to note that, a python session can only be used once plt.show (), it is often regarded it placed at the end of the script.

      In ipython shell in , you need to start matplotlib mode, matplotlib start by way of magic%. No longer need to use plt.show (). Can force an update by plt.draw ().

      In ipython notebook in , we need to start matplotlib mode.

      

  1.4 Save the graphics file

      

      

 

 

       

2 Both interfaces Paint

  2.1 MATLAB Interface style

      This interface is the most important feature of the state (stateful): it keeps track of the "current" graphics and axes, all plt command can be applied, available plt.gcf () to get the current graphics, plt.gca () get the current axis.

      Disadvantages: inconvenient to switch the sub FIG.

      

      

  2.2 Object-Oriented Interface

      Object-oriented interfaces are no longer limited by the current "active" or pattern axis, it becomes an explicit method and Axes of Figure.

      

      To draw more complex graphics, opposite the object method will be more convenient.

3, a simple line graph

  3.1 Adapting Graphics: line color and style

      

      

  3.2 adjusting pattern: the lower limit coordinate axes

      

 

 

       

      

 

      

 

      

       

 

 

     

  3.3 Setting Graphic labels

      

 

 

      

 

      

 

 

       matplotlib trap

         

 

       

4, simple scatter plot

  4.1 Scatter painting with plt.plot

       

      

 

 

      

 

 

      

 

 

 

  4.2 Scatter painting with plt.scatter

      

 

 

      

 

 

 

 

 

 

 

  4.3 plot and scatter: Efficiency Comparison

      

 

 

 

5, exception handling Visualization

  5.1 Basic error line

      

 

 

 

  5.2 Continuous Error bars

      To resolve the error displayed by a continuous variable and plt.plot plt.fill_between. The lower limit on the parameters passed plt.fill_between drawing, painting and graphics by plt.plot do comparison to visualize the error.    

      

6, and FIG density contour plots

    In the two-dimensional map represented by the three-dimensional contour data or color maps FIG.

    With plt.contour drawing contour maps, contour maps (filled contourplot) filled with color by color plt.contourf Videos, graphics display with plt.imshow.

  Three-dimensional view visualization 6.1

    Plt.contour contour map can be used to create a function, it takes three parameters: x axis, y axis, z-axis grid data of the three axes. x-axis and y-axis represents the position of the pattern, and the z-axis level will be represented by contour lines.

    

 

 

     When only one color graphics, dashed lines represent negative default, a solid line denotes a positive number.

     

 

 

      matplotlib color scheme can view the information in the corresponding module plt.cm ipython using the tab key. 

      

 

 

       

      By analyzing the color bar: black area is the peak (peak), the red region is a valley (valley).

      Description: The color change is a discrete rather than a continuous process, it does not look so clean  

      

 

 

      

       

7, frequency histogram, and the distribution density data interval into

  7.1 Frequency histogram

      

 

 

       

 

 

       The above is a one-dimensional array is divided into sections to create a one-dimensional frequency histograms .

  7.2 two-dimensional histogram and frequency data interval division

      The two-dimensional array in accordance with the two-dimensional segmentation section, to create a two-dimensional frequency histograms.

      

 

 

   7.3 Kernel Density Estimation

      Kernel density estimation (kernel density estimation, KDE), a common method of multi-dimensional data distribution density assessment.

      

           

8, configuration legend  

    Legend represents a discrete graphical elements by discrete label.

  8.1 Select the legend elements displayed

    Legend want to use in a visual pattern, graphic elements may be assigned different labels.

    

 

 

    

 

 

    

 

 

     The legend is displayed by default label all the elements, but ignores those elements without labels

    

 

 

     

        

  Simultaneously displaying a plurality of legends 8.2

      By creating a new scratch artists objects legend (legend artist), and () method adds a second legend on the view of the bottom (lower-level) ax.add_artist.

      

 

       

     

9, a color bar configuration

    For drawing a colored dot, line, surface constituting the continuous label, color bar to indicate the effect is better.

    In matplotlib, the color bar is an independent axis, can indicate the meaning of colors in the graphic.

    

 

 

  9.1 Configuring color bar

     

 

      Color bar itself can be seen as only a plt.Axes example, the format may be adapted and arranged about the axis scale values (e.g. plt.clim ()) .

 

10, the multi subgraph

  10.1 plt.axes: Manually create a child diagram

      Function plt.axes (), to create a default standard coordinate axis, to fill the entire FIG.

      It has an optional parameter value pattern has four coordinate system configuration, respectively, is a graph showing a coordinate system [bottom, left, width, height] (the end coordinates, the left coordinate, width, height), the numerical value range lower-left corner (origin) to 0, the upper right corner is 1.

      

      

 

 

  10.2 plt.subplot: Simple Grid subgraph

  10.3 plt.subplots: create a grid with a single line of code

  10.4 plt.GridSpec: more complex arrangement

11, text and notes

  11.1 Case: Holidays on the US birth rate

  11.2 coordinate transformation and text position

  11.3 arrows and notes

12, custom axis scale

  12.1 major scale and a minor scale

  12.2 hide the scale and label

  12.3 increase or decrease the number of tick

  12.4 fancy scale format

  12.5 format generation with locator Summary

13, Matplotlib custom: the configuration file and stylesheets

  13.1 Manually configure graphics

  13.2 modify the default configuration: rcParams

  13.3 stylesheet

14, a three-dimensional drawing Matplotlib

  14.1 dimensional data points and lines

  14.2 dimensional contour

  FIG wireframe and surface 14.3

  14.4 curved triangular part

15, with the geographic data visualization Basemap

  15.1 Map Projection

  15.2 Draw a map background

  15.3 picture data on the map

  15.4 Case: California city data

  15.5 Case: Surface temperature data

16, for data visualization with Seaborn

  16.1 Seaborn与Matplotlib

  16.2 Seanborn graphical presentation

  16.3 Case: Exploring marathon performance data

17 references

  17.1 Matplotlib resources

  17.2 Other Paint Python library

Guess you like

Origin www.cnblogs.com/nuochengze/p/12466583.html