Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

horizontal line to the y axis in matplotlib

# importing the module
import matplotlib.pyplot as plt
  
# plotting line within the given range
plt.axhline(y = .5, xmin = 0.25, xmax = 0.9)
  
# line colour is blue
plt.axhline(y = 3, color = 'b', linestyle = ':', label = "blue line")
  
# line colour is white
plt.axhline(y = 1, color = 'w', linestyle = '--', label = "white line")
  
# line colour is red
plt.axhline(y = 2, color = 'r', linestyle = 'dashed', label = "red line")    
    
# adding axis labels    
plt.xlabel('x - axis')
plt.ylabel('y - axis')
  
# plotting the legend
plt.legend(bbox_to_anchor = (1.0, 1), loc = 'upper center')
  
# displaying the plot
plt.show()
Comment

PREVIOUS NEXT
Code Example
Python :: Panda Python - Calculating what percentage of values are true and false out of total in boolean column 
Python :: pytest snapshot update 
Python :: convert iso 8601 to milliseconds python 
Python :: encoding character or string to integer in python 
Python :: tkinter standard dialogs message 
Python :: most occurring element in array python 
Python :: importing a python file from another folder 
Python :: url routing in django 
Python :: find difference between two pandas dataframes 
Python :: Exiting from python Command Line 
Python :: 151 - Power Crisis 
Python :: algebraic pyramid python 
Python :: get image data cv2 
Python :: keras sequential layer without input shape 
Python :: pass query params django template 
Python :: python find all occurrence in string 
Python :: gene wilder pure imagination 
Python :: input a number and print even numbers up to that number 
Python :: * in python 
Python :: any() and all() 
Python :: rename files in python 
Python :: Python Tkinter CheckButton Widget 
Python :: python tkinter importieren 
Python :: How to calculate accuracy with two lists in python 
Python :: assigning crs using python pyproj 
Python :: python ip camera 
Python :: Customizing scatter plot with pyplot object 
Python :: Example pandas.read_hfd5() 
Python :: change excel value in python 
Python :: django log queryset 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =