Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

matplotlib show percentage y axis

import matplotlib.pyplot as plt
import numpy as np
import matplotlib.ticker as mtick

data = [8,12,15,17,18,18.5]
perc = np.linspace(0,100,len(data))

fig = plt.figure(1, (7,4))
ax = fig.add_subplot(1,1,1)

ax.plot(perc, data)

fmt = '%.0f%%' # Format you want the ticks, e.g. '40%'
xticks = mtick.FormatStrFormatter(fmt)
ax.xaxis.set_major_formatter(xticks)

plt.show()
Comment

PREVIOUS NEXT
Code Example
Python :: matplotlib axes labels 
Python :: pandas add header to existing dataframe 
Python :: import pyttsx3 
Python :: get all count rows pandas 
Python :: get adjacent cells in grid 
Python :: how to read a pkl file in python 
Python :: pygame keys pressed 
Python :: python writing to csv file 
Python :: python keyboard press 
Python :: playsound module in python 
Python :: django all urls 
Python :: plot horizontal line in python 
Python :: forbidden (csrf cookie not set.) django rest framework 
Python :: run 2 loops simultaneously python 
Python :: print a random word from list python 
Python :: pandas convert date column to year and month 
Python :: how to convert a pandas series from int to float in python 
Python :: Python find inverse of matrix 
Python :: make coordinate cyclic in python 
Python :: python3 return a list of indexes of a specific character in a string 
Python :: python to golang 
Python :: python get lines from text file 
Python :: how to get the mouse input in pygame 
Python :: pandas convert float to int with nan null value 
Python :: python datetime with timezone 
Python :: cv2 videocapture program for python 
Python :: exit all threads from within a thread python 
Python :: python zfill 
Python :: django phone number field 
Python :: how to import iris dataset 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =