4.2. Chart Scatter
Used to show correlation
4.2.1. Syntax
import matplotlib.pyplot as plt
x = [1, 2, 3, 4]
y = [1, 2, 3, 4]
plt.scatter(x, y)
plt.show() # doctest: +SKIP
4.2.2. Simple Points
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 10, 50)
y = np.sin(x)
plt.scatter(x, y)
plt.show() # doctest: +SKIP
4.2.3. Markers
marker
s
- size
import matplotlib.pyplot as plt
x = [1, 2, 3, 4, 5, 6, 7, 8]
y = [5, 2, 4, 2, 1, 4, 5, 2]
plt.scatter(x, y, marker='*', s=100)
plt.show() # doctest: +SKIP
import matplotlib.pyplot as plt
import numpy as np
x = [1, 2, 3, 4, 5, 6, 7, 8]
y = [5, 2, 4, 2, 1, 4, 5, 2]
plt.scatter(x, y, marker='x', s=100)
plt.show() # doctest: +SKIP
import matplotlib.pyplot as plt
import numpy as np
x = [1, 2, 3, 4, 5, 6, 7, 8]
y = [4, 7, 6, 2, 7, 4, 5, 2]
plt.scatter(x, y, marker='*', s=500)
plt.scatter(y, x, marker='o', s=500)
plt.show() # doctest: +SKIP