Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyPlot reverse y-axis and logarithmic

Is there a way to both reverse the y-axis with PyPlot and make it logarithmic? I know that one of the two options can be done with

plt.gca().invert_yaxis()

and

plt.yscale('log')

However, the combination does not work. Any ideas? Thanks a lot!

like image 855
Tomas Avatar asked Aug 08 '14 08:08

Tomas


People also ask

How do you invert Y axis in Pyplot?

By using the plt. gca() method we get the current axes of the plot. Then we use the invert_yaxis() method to flip the y-axis of the plot.

What is PLT CLF () in Python?

matplotlib.pyplot.clf() Function. The clf() function in pyplot module of matplotlib library is used to clear the current figure.


1 Answers

The best way to do this is simply to use this in the following order:

plt.scatter(x, y)
plt.yscale('log')
plt.gca().invert_yaxis()
plt.show()
like image 147
GCien Avatar answered Oct 07 '22 10:10

GCien