About 511,000 results
Open links in new tab
  1. python - Plot a horizontal line on a given plot - Stack Overflow

    Jun 16, 2022 · How do I add a horizontal line to an existing plot? Use axhline (a horizontal axis line). For example, this plots a horizontal line at y = 0.5: If you want to draw a horizontal line in the axes, you might also try ax.hlines() method. You need to specify y position and xmin and xmax in the data coordinate (i.e, your actual data range in the x-axis).

  2. Plot a Horizontal line in Matplotlib - GeeksforGeeks

    Apr 2, 2025 · In Matplotlib, we can draw horizontal lines on a plot to indicate thresholds, reference points or important levels in the data. These lines can be used to highlight specific values for better visualization.

  3. matplotlib.pyplot.hlines — Matplotlib 3.10.1 documentation

    Plot horizontal lines at each y from xmin to xmax. Parameters: y float or array-like. y-indexes where to plot the lines. xmin, xmax float or array-like. Respective beginning and end of each line. If scalars are provided, all lines will have the same length. colors color or list of color , default: rcParams["lines.color"] (default: 'C0')

  4. How to Plot Horizontal Line in Python - Delft Stack

    Feb 2, 2024 · 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. When our goal is to produce 2D plots, we can use the Plot() function.

  5. Horizontal line matplotlib - Python Guides

    Oct 26, 2021 · In this tutorial, we will learn how to draw horizontal line matplotlib in python. Here we will cover different examples related to drawing horizontal lines.

  6. Plot Horizontal Line in Matplotlib - Matplotlib Color

    May 26, 2024 · In this tutorial, we will learn how to plot horizontal lines in Matplotlib, which is a popular Python library for creating static, animated, and interactive visualizations in Python.

  7. Matplotlib plot a line (Detailed Guide) - Python Guides

    Aug 10, 2021 · You can plot a horizontal line in matplotlib python by either using the plot () function and giving a vector of the same values as the y-axis value-list or by using the axhline () function of matplotlib.pyplot that accepts only the constant y value.

  8. How to Draw a Horizontal Line in Matplotlib (With Examples) - Statology

    Jun 11, 2021 · You can use the following syntax to draw a horizontal line in Matplotlib: #draw vertical line at y=10. plt.axhline(y=10) The following examples show how to use this syntax in practice with the following pandas DataFrame: #create DataFrame. df = pd.DataFrame({'x': [1, 2, 3, 4, 5, 6, 7, 8], 'y': [5, 7, 8, 15, 26, 39, 45, 40]}) #view DataFrame. df.

  9. Enhancing Data Visualizations with Horizontal Lines in Python

    You can directly create a horizontal line plot using the plt.plot() function, specifying x-coordinates and a constant y-coordinate: import matplotlib.pyplot as plt # ... (your existing plot code) # Plot a horizontal line from x=0 to x=5 at y=3 plt.plot([ 0 , 5 ], [ 3 , 3 ], color= 'r' , linestyle= '--' )

  10. Plotting with Seaborn and Matplotlib - GeeksforGeeks

    Mar 17, 2025 · Statistical Plots: Seaborn includes special plots like violin plots and KDE plots. More Flexibility: Matplotlib allows extra customization and combining multiple plots. Enhancing matplotlib with seaborn styles. Seaborn simplifies data visualization with built-in themes and high-level functions. Example 1. Applying seaborn style to matplotlib ...

  11. Some results have been removed
Refresh