Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- PANDAS
- line width
- Default X points
- break
- MySQL
- pie charts
- PROJECT
- Python
- multiple lines
- Else
- Text mining
- line color
- start exercise
- train/test
- variables
- self parameter
- iterates
- matplotlib.pyplot
- polynomial regression
- error
- matplotlib
- continue
- For loops
- SQL
- Text Analytics
- Github
- AS
- __init__
- data distribution
- machine learning
Archives
- Today
- Total
Data Science Explorer
Matplotlib: Matplotlib Line 본문
반응형
- 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' | '-.' |
'None' | '' or ' ' |
- Line Color
You can use argument c to set the color of the line.
Example
import matplotlib.pyplot as plt
import numpy as np
ypoints = np.array ([2,3,6,9])
plt.plot(ypoints, color = 'r')
plt.show()
Result
- Line Width
We can also adjust the width of the line by using lw.
import matplotlib.pyplot as plt
import numpy as np
y =([3, 4, 5, 7])
plt.plot(y, lw = '20')
plt.show()
Result
- Multiple Lines
You can plot as many lines as you like by simply adding more plt.plot() functions.
import matplotlib.pyplot as plt
import numpy as np
y1 = np.array ([1, 3, 5, 9])
y2 = np.array([6, 2, 7, 11])
plt.plot(y1)
plt.plot(y2)
plt.show()
Result
'Python' 카테고리의 다른 글
Matplotlib Subplot (0) | 2023.11.07 |
---|---|
Matplotlib: Matplotlib Adding Grid Lines (0) | 2023.11.06 |
Matplotlib: Matplotlib Labels and Title (0) | 2023.11.05 |
Matplotlib: Matplotlib Markers (2) | 2023.11.04 |
Matplotlib: Matplotlib Plotting (0) | 2023.11.04 |