make scatter points smaller , add axhline centered at y=0 in python

To make scatter points smaller and add axhline centered at y=0 in python using matplotlib library, we can adjust the s parameter of the scatter plot to make the points smaller, and use the axhline function.

Here is an example code:

main.py
import matplotlib.pyplot as plt
import numpy as np

# Generate some data
np.random.seed(1)
x = np.random.rand(20)
y = np.random.randn(20)

# Plot the scatter plot
fig, ax = plt.subplots()
ax.scatter(x, y, s=20)

# Add horizontal line
ax.axhline(y=0, color='black')

plt.show()
277 chars
17 lines

In this example, s=20 adjusts the scatter plot point size, and ax.axhline(y=0, color='black') adds a horizontal line at y=0.

Adjust the values of s and y based on your preference.

gistlibby LogSnag