- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to plot 1D data at a given Y-value with PyLab using Matplotlib?
63 Lectures 6 hours
To plot 1D data at a given Y-value with pyplot, we can take the following steps−
- Initialize y value.
- Create x and y data points using numpy. zeros_like helps to return an array of zeros with the same shape and type as a given array and add y-value for y data points.
- Plot x and y with linestyle=dotted, color=red, and linewidth=5.
- To display the figure, use show() method.
import numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True y_value = 1 x = np.arange(10) y = np.zeros_like(x) + y_value plt.plot(x, y, ls='dotted', c='red', lw=5) plt.show()
- How to plot single data with two Y-axes (two units) in Matplotlib?
- How to make a 4D plot with Matplotlib using arbitrary data?
- How to print the Y-axis label horizontally in a Matplotlib/Pylab chart?
- How to plot a line in Matplotlib with an interval at each data point?
- How to plot an image with non-linear Y-axis with Matplotlib using imshow?
- Plot a histogram with Y-axis as percentage in Matplotlib
- How to use different markers for different points in a Pylab scatter plot(Matplotlib)?
- How to plot a histogram using Matplotlib in Python with a list of data?
- Which is the recommended way to plot – matplotlib or pylab?
- Plot data from a .txt file using matplotlib
- How to extract data from a Matplotlib plot?
- How to add a shared x-label and y-label to a plot created with Pandas' plot? (Matplotlib)
- Evaluate a 2-D polynomial at points (x, y) with 1D array of coefficient in Python
- Evaluate a 2D Legendre series at points (x, y) with 1D array of coefficient in Python
- Evaluate a 2D Laguerre series at points (x,y) with 1D array of coefficient in Python