point plot in python code example

Example 1: python add a point to a plot

# Basic syntax
plt.plot(x, y, 'marker')

# Example usage:
import matplotlib.pyplot as plt
import numpy as np

# Data to plot
x = np.linspace(0, 10, 100)

# Plot figure
fig = plt.figure()
plt.plot(x, np.sin(x), '-')

# Add point
plt.plot(5, 0, 'ro')

# Note, see all marker styles here:
#    https://matplotlib.org/stable/api/markers_api.html

Example 2: how to plot a scatter plot in matplotlib

# Import matplotlib
import matplotlib.pyplot as plt

# Set plot space as inline for inline plots and qt for external plots
%matplotlib inline


# Set the figure size in inches
plt.figure(figsize=(10,6))

plt.scatter(x, y, label = "label_name" )

# Set x and y axes labels
plt.xlabel('X Values')
plt.ylabel('Y Values')

plt.title('Scatter Title')
plt.legend()
plt.show()

Example 3: scatter plot python

df.plot('x_axis', 'y_axis', kind='scatter')

Tags:

Misc Example