Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create non linear axis in plot

I'm using matplotlib to plot a series of datas and get a result as below

enter image description here

But I'm expecting to have a non linear axis as below.

enter image description here

How can I make that kind of plot? Thanks in advance.

like image 243
highsun16 Avatar asked Dec 25 '22 02:12

highsun16


1 Answers

You can set the y-axis to logaritmic by writing plt.yscale('log')

full example:

import matplotlib.pyplot as plt
example = [pow(2,i) for i in range(10)]
plt.plot(example)
plt.yscale('log')
plt.show()
like image 92
Laurens Koppenol Avatar answered Dec 26 '22 15:12

Laurens Koppenol