How can I plot a single point in Matplotlib Python?

To plot a single data point in matplotlib, you can use the plot() method with specific marker parameters. This is useful for highlighting specific coordinates or creating scatter-like visualizations with individual points.

Basic Single Point Plot

Here's how to plot a single point with customized appearance ?

import matplotlib.pyplot as plt

# Define single point coordinates
x = [4]
y = [3]

# Set axis limits and add grid
plt.xlim(0, 5)
plt.ylim(0, 5)
plt.grid(True)

# Plot the single point
plt.plot(x, y, marker="o", markersize=15, 
         markeredgecolor="red", markerfacecolor="green")

plt.title("Single Point Plot")
plt.xlabel("X-axis")
plt.ylabel("Y-axis")
plt.show()

Using scatter() Method

Alternatively, you can use scatter() which is designed specifically for plotting individual points ?

import matplotlib.pyplot as plt

# Single point coordinates
x = 4
y = 3

# Create scatter plot
plt.scatter(x, y, s=200, c='blue', marker='*', edgecolors='black', linewidth=2)

plt.xlim(0, 5)
plt.ylim(0, 5)
plt.grid(True)
plt.title("Single Point using scatter()")
plt.xlabel("X-axis")
plt.ylabel("Y-axis")
plt.show()

Multiple Styling Options

You can customize the point appearance with various markers and colors ?

import matplotlib.pyplot as plt

# Create subplots for different styles
fig, axes = plt.subplots(1, 3, figsize=(12, 4))

# Style 1: Circle marker
axes[0].plot(2, 2, marker='o', markersize=20, color='red')
axes[0].set_title("Circle Marker")
axes[0].grid(True)
axes[0].set_xlim(0, 4)
axes[0].set_ylim(0, 4)

# Style 2: Square marker
axes[1].plot(2, 2, marker='s', markersize=20, color='blue')
axes[1].set_title("Square Marker")
axes[1].grid(True)
axes[1].set_xlim(0, 4)
axes[1].set_ylim(0, 4)

# Style 3: Star marker
axes[2].plot(2, 2, marker='*', markersize=25, color='green')
axes[2].set_title("Star Marker")
axes[2].grid(True)
axes[2].set_xlim(0, 4)
axes[2].set_ylim(0, 4)

plt.tight_layout()
plt.show()

Key Parameters

Parameter Description Example Values
marker Point shape 'o', 's', '*', '^', 'D'
markersize Size of the point 10, 15, 20
markerfacecolor Fill color 'red', 'blue', '#FF5733'
markeredgecolor Border color 'black', 'white', 'none'

Conclusion

Use plot() with marker parameters for single points within line plots, or scatter() for dedicated point visualization. Both methods allow extensive customization of point appearance and styling.

Updated on: 2026-03-25T19:45:07+05:30

69K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements