How to set a line color to orange, and specify line markers in Matplotlib?


To set a line color to orange, and specify line markers in matplotlib, we can take the following steps −

Steps

  • Set the figure size and adjust the padding between and around the subplots.

  • Create x and y data points using numpy.

  • Plot the x and y data points with the attributes color='orange' and marker='*'.

  • To display the figure, use show() method.

Example

import matplotlib.pyplot as plt
import numpy as np

# Set the figure size
plt.rcParams["figure.figsize"] = [7.50, 3.50]
plt.rcParams["figure.autolayout"] = True

# x and y data points
x = np.linspace(-5, 5, 100)
y = np.sin(x)

# Plot the data points with color and marker attributes
plt.plot(x, y, color='orange', marker="*")

# Display the plot
plt.show()

Output

It will produce the following output −

Updated on: 01-Feb-2022

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements