Matplotlib How To Plot Horizontal Line - Example 1: Draw One Horizontal Line The following code shows how to draw one horizontal line on a Matplotlib plot: import matplotlib.pyplot as plt #create line plot plt.plot(df.x, df.y) #add horizontal line at y=10 plt.axhline(y=10, color='red', linestyle='--') Example 2: Draw Multiple Horizontal Lines There are many methods available to plot a horizontal line which is as follows Plotting horizontal line by the plot function Plotting horizontal lines by the hlines function Plotting horizontal line by the axhline function Use the plot Function in Python When our goal is to produce 2D plots we can use the Plot function
Matplotlib How To Plot Horizontal Line

Matplotlib How To Plot Horizontal Line
Plot horizontal lines at each y from xmin to xmax. Parameters: yfloat or array-like y-indexes where to plot the lines. xmin, xmaxfloat or array-like Respective beginning and end of each line. If scalars are provided, all lines will have the same length. colorscolor or list of colors, default: rcParams ["lines.color"] (default: 'C0') In this tutorial, we will introduce two methods to draw horizontal and vertical lines in Matplotlib. These two methods use different coordinates in Matplotlib. axhline () / axvline () hlines () / vlines () axhline and axvline to Plot Horizontal and Vertical Lines in Matplotlib axhline to Plot a Horizontal Line
Plot Horizontal Line in Python Delft Stack

How To Plot Horizontal Bar Chart In Matplotlib TutorialKart
Matplotlib How To Plot Horizontal LineExample 1: Draw One Horizontal Line The following code shows how to draw one horizontal line on a Matplotlib plot: import matplotlib.pyplot as plt #create line plot plt.plot(df.x, df.y) #add horizontal line at y=10 plt.axhline(y=10, color='red', linestyle='--') Example 2: Draw Multiple Horizontal Lines Plotting a horizontal line is fairly simple Using axhline The axhline function in pyplot module of matplotlib library is used to add a horizontal line across the axis Syntax matplotlib pyplot axhline y color xmin xmax linestyle Parameters y Position on Y axis to plot the line It accepts integers
Using plot () Using hlines () Using axhline () By using plot () function In matplotlib, the plot () method is used to generate 2D plots. The syntax of the plot () method is as given below: matplotlib.pyplot.plot (x_points, y_points) The parameters used above are: x_points: x-axis points to plot. How To Plot Horizontal Bar Graph In Seaborn AiHints How To Plot An Horizontal Line In Pandas Charts
Plot Horizontal and Vertical Line in Matplotlib Delft Stack

Matplotlib Horizontal Bar Chart
Here, you can see that we have drawn a simple horizontal line. To do so, we have called the plt.axhline() function, and inside that function, we have set the y-axis first, then also set the color as green, and also style the horizontal line. We can also draw multiple horizontal lines in a single plot and also leveled them. Dashed Lines From Points To Axes In Matplotlib Linux4one
Here, you can see that we have drawn a simple horizontal line. To do so, we have called the plt.axhline() function, and inside that function, we have set the y-axis first, then also set the color as green, and also style the horizontal line. We can also draw multiple horizontal lines in a single plot and also leveled them. Python Matplotlib How To Plot World Map OneLinerHub Plotly How To Plot Horizontal Line Between 2 Points Where Points On

How To Plot A Horizontal Line In Matplotlib Python Oraask

Plot Horizontal And Vertical Line In Matplotlib

How Do You Plot A Horizontal Line Across The Chart At The Highest And

Python Matplotlib How To Plot Dotted Line OneLinerHub

Plot Horizontal And Vertical Line In Matplotlib

How To Plot A Bar Graph In Matplotlib w 9 Examples 2023

How To Plot Horizontal Bar Chart In Matplotlib TutorialKart

Dashed Lines From Points To Axes In Matplotlib Linux4one

How To Plot A Horizontal Line In Matplotlib Python Oraask

Thin Line Scatter Plot Matplotlib Realtygerty