| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | |||
| 5 | 6 | 7 | 8 | 9 | 10 | 11 |
| 12 | 13 | 14 | 15 | 16 | 17 | 18 |
| 19 | 20 | 21 | 22 | 23 | 24 | 25 |
| 26 | 27 | 28 | 29 | 30 |
- variables
- pie charts
- PROJECT
- For loops
- break
- line width
- iterates
- train/test
- polynomial regression
- Default X points
- __init__
- error
- multiple lines
- start exercise
- line color
- data distribution
- machine learning
- Text Analytics
- matplotlib.pyplot
- Python
- Else
- continue
- SQL
- matplotlib
- Text mining
- MySQL
- AS
- PANDAS
- Github
- self parameter
- Today
- Total
목록Python (42)
Data Science Explorer
The subplot() function takes three arguments that describe the layout of the figure. The layout is organized in rows and columns which are represented by the first and second agrument. Example plot.subplot(1, 3, 2) # the figure has 1 row, 3 columns and this plot is the second plot. Example import matplotlib.pyplot as plt import numpy as np x = np.array([0, 1, 2, 3]) y = np.array([3, 8, 1, 10]) p..
Add Grid Lines to a Plot You can use the grid() function to add grid lines to the plot. Example import matplotlib.pyplot as plt import numpy as np x = np.array([80, 85, 90, 95, 100, 105, 110, 115, 120, 125]) y = np.array([240, 250, 260, 270, 280, 290, 300, 310, 320, 330 plt.title ("The Office Watch Data") plt.xlabel("Average Pulse") plt.ylabel("Calorie Burnage") plt.plot(x, y) plt.grid() plt.sho..
Linestyle If you want to change the style of the line, you can use ls. Example import matplotlib.pyplot as plt import numpy as np ypoints = np.array ([2,6,7,0]) plt.plot(ypoints, ls = 'dotted') plt.show() Shorter Syntax linestyle can be written as ls. dotted can be written as :. dashed can be written as --. Line Styles Style Or 'solid' (default) '-' 'dotted' ':' 'dashed' '--' 'dashdot' '-.' 'Non..
Create Labels for a Plot You can use title(), xlabel(), and ylabel() functions give names for title, x-axis, and y-axis. Example import matplotlib.pyplot as plt import numpy as np x = np.array([80, 85, 90, 95, 100, 105, 110, 115, 120, 125]) y = np.array([240, 250, 260, 270, 280, 290, 300, 310, 320, 330]) plt.plot (x, y) plt.title("Heights Data") plt.xlabel("Average Height") plt.ylabel("Average W..
Markers When you want to emphasize each point with a specified marker, you can use the argument marker. Example Mark each point with a circle. import matplotlib.pyplot as plt import numpy as np ypoints =([5, 8, 0, 8]) plt.plot (ypoints, marker = 'o') plt.show() Result Mark each point with a star. Result Marker Reference Marker Description 'o' Circle '*' Star '.' Point ',' Pixel 'x' X 'X' X (fill..
The plot() function is used to draw points (markers) in a diagram. Parameter 1 is an array containing the points on the x-axis. Parameter 2 is an array containing the points on the y-axis. Plotting Without Line You can use shortcut string notation parameter 'o', which means rings. Example Draw two points in the diagram, one at position (1,1) and one in position (6,10). # Draw two points in the d..
Pyplot Most of the Matplotlib utilies lies under the pyplot submodule, and are usually imported under the plt alias: import matplotlib.pyplot as plt Example Draw a line in a diagram from position (0,0) to position (5, 10). import matplotlib.pyplot as plt import numpy as np xpoints = np.array([0,5]) ypoints = np.array([0,10]) plt.plot (xpoints, ypoints) plt.show() Result
What is Matplotlib? It is a low level graph plotting library in python that serves as a visualization utility. Let's get started with installation of Matplotlib. pip install matplotlib Import Matplotlib import matplotlib Check Matplotlib Version import matplotlib print (matplotlib.__version__)
If you want to discover duplicates on the dataset, we can use duplicated() method. It gives you a boolean values (True or False). Example print (df.duplicated()) Removing Duplicates To remove duplicates, use the drop_duplicates() method. Example df.drop_duplicates(inplace = True) Exercises Explain the following code. # Count duplicate student names duplicate_count = df[df.duplicated(subset=["Stu..
Wrong data is just a wrong data like if someone registered 90 instead of 9.0. Replacing Values One way to fix wrong values is to replace them with something else. Example Set "Duration" = 80 in row 2. df.loc[2, 'Duration'] = 80 Removing Rows Another way of handling wrong data is to remove the rows that contains wrong data. Example Delete rows where "Duration" is higher than 130. for x in df.inde..