Data Visualization Matplotlib



Data Visualization (Matplotlib)

Data Visualization (Matplotlib)

Contents

1. Introduction ................................................................................................................................. 3 2. Python Visualization Tools ......................................................................................................... 4 3. Matplotlib..................................................................................................................................... 4 4. Import Matplotlib ........................................................................................................................ 4 5. Matplotlib ............................................................................................. 5

5.1 Plotting from a script............................................................................................................ 5 5.2 Plotting from an IPython shell ............................................................................................. 5 5.3 Plotting from a Jupyter notebook ....................................................................................... 5 6. Matplotlib Object Hierarchy ....................................................................................................... 5 7. Matplotlib API .............................................................................................................................. 6 8. Pyplot API .................................................................................................................................... 6 8.1 Formatting the style of plot ................................................................................................. 9 8.2 ................................................. 9 9. Object-Oriented API .................................................................................................................. 10 9.1 Objects and Reference.........................................................................................................11 9.2 Figure and Axes ....................................................................................................................11 10. Figure and Subplots ................................................................................................................ 12 12. Multiline Plots .......................................................................................................................... 13 13. Parts of a Plot.......................................................................................................................... 13 14. Saving the Plot ........................................................................................................................ 13 14.1 Supported file formats...................................................................................................... 14 15. Line Plot ................................................................................................................................... 14 16. Scatter Plot .............................................................................................................................. 14 17. Histogram ................................................................................................................................ 15 18. Bar Chart .................................................................................................................................. 16 19. Horizontal Bar Chart ............................................................................................................... 16 20. Error Bar Chart ........................................................................................................................ 16

Matplotlib Page-1

Data Visualization (Matplotlib)

21. Stacked Bar Chart....................................................................................................................17

22. Pie Chart...................................................................................................................................17

23. Boxplot ..................................................................................................................................... 18

24. Area Chart ................................................................................................................................ 18

25. Contour Plot.............................................................................................................................19

26. Styles with Matplotlib Plots .................................................................................................... 19

27. Grid (Adding a grid) ...................................................................................20

28. Handling axes...........................................................................................................................20

29. X Y (Handling X and Y ticks) ................................21

30. X Y (Adding labels).....................................................22

31. (Adding a title) ...................................................................................22

32. Legend ......................................................................................................................23

33. Control Colours ........................................................................................................................24

33.1 Colour abbreviation Colour name ........................................................................................24

34. Control Line Styles...................................................................................................................24

34.1 Style Styles......................................................................................................................... 25

34.2 Marker Styles ..................................................................................................................... 25

Matplotlib Page -2

Data Visualization (Matplotlib)

Data Visualization (Matplotlib)

Matplotlib Python programming language data visualization tool Matplotlib object hierarchy plot customization techniques

1. Introduction

X Y () X X Y Y

Matplot X Y plt.plot(x,y) plt.plot(x,y) plt .plot() x,y () plt matplotlib.pyplot Python package library .plot() function x, y X Y X Y .plot()function plt Python library plt.show() Python .show()

plt.plot(x,y)

import matplotlib.pyplot as plt x = [1,2,3,4,5] y = [2,5,6,9,10] plt.plot(x,y) plt.show()

Data Visualization Data Visualization (numerical data) input chart figure (table) output Data Visualization

Matplotlib Matplotlib Python programming language data visualization tool Python visualization tool Matplotlib

Matplotlib Page-3

Data Visualization (Matplotlib)

2. Python Visualization Tools

Python data scientist language . Python data

visualization Python data visualization

tools

Matplotlib

Seaborn

pandas

Bokeh

Plotly

ggplot

pygal

Data visualization tool Matplotlib

3. Matplotlib

Matplotlib Python programming language plotting library Python visualization package plotting library

Matplotlib like PDF, SVG, JPG, PNG, BMP and GIF format

Line plot, scatter plot, histogram, bar chart, error charts, pie chart, box plot, visualization 3D Matplotlib pandas Seabor Python library Matplotlib access

Matplotlib John Hunter Neurobiology Electrocorticography (ECoG) (visualize ) Python programming language open-source tool Matplotlib data visualization

4. Import Matplotlib

Python data visualization () Matplotlib import Import matplotlib.pyplot Terninal p ip list pip install matplotlib install Requirement already satisfied install import matplotlib

Matplotlib pyplot pyplot import

import matplotlib.pyplot pyplot import as keyword Matplotlib Page -4

import matplotlib.pyplot as plt

Data Visualization (Matplotlib)

import numpy as np import pandas as pd

# #

5. Matplotlib

Matplotlib plt.show() command Matplotlib plot () () command

? plotting from a script, ? plotting from an IPython shell or ? plotting from a Jupyter notebook. 5.1 Plotting from a script Python script Matplotlib plt.show() command Python session plt.show() command plot script

5.2 Plotting from an IPython shell IPython shell Matplotlib zoon (interactively)

IPython %matplotlib magic command Matplotlib mode

5.3 Plotting from a Jupyter notebook Jupyter Notebook ( IPython Notebook )

web brower %matplotlib command () Input output

? %matplotlib notebook ? interactive plot web brower embedded zoon

%matplotlib inline ? static image output static image zoon %matplotlib inline

6. Matplotlib Object Hierarchy Matplotlib Object Hierarchy

Matplotlib Python object (nested) Hierarchy

Matplotlib Page-5

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download