import seaborn as sns
sns.scatterplot(data=df, x="x_var", y="y_var")
import matplotlib.pyplot as plt
height = [66, 64, 30, 67, 32, 3.9, 3.1, 8.9, 7.7]
diameter = [10.2, 11, 6.9, 12, 2.8, 3.9, 3.1, 8.9, 7.7]
plt.scatter(height, diameter)
plt.show()
import numpy as npimport matplotlib.pyplot as plt
# Create data
N = 500x = np.random.rand(N)
y = np.random.rand(N)
colors = (0,0,0)
area = np.pi*3
# Plot
plt.scatter(x, y, s=area, c=colors, alpha=0.5)
plt.title('Scatter plot pythonspot.com')
plt.xlabel('x')
plt.ylabel('y')
plt.show()
import numpy as np
import matplotlib.pyplot as plt
# Fixing random state for reproducibility
np.random.seed(19680801)
N = 50
x = np.random.rand(N)
y = np.random.rand(N)
colors = np.random.rand(N)
area = (30 * np.random.rand(N))**2 # 0 to 15 point radii
plt.scatter(x, y, s=area, c=colors, alpha=0.5)
plt.show()
# Convert cyl column from a numeric to a factor variable
mtcars$cyl <- as.factor(mtcars$cyl)
head(mtcars)