Ich habe vales mit sehr kleinen Unterschied wie ... 0.000001. Ich möchte sie auf logarithmischer Skala visualisieren. Ich frage mich, wie man es in Matplotlib macht.Wie visualisiert man Werte in logarithmischer Skala auf Matplotalib?
Vielen Dank
Ich habe vales mit sehr kleinen Unterschied wie ... 0.000001. Ich möchte sie auf logarithmischer Skala visualisieren. Ich frage mich, wie man es in Matplotlib macht.Wie visualisiert man Werte in logarithmischer Skala auf Matplotalib?
Vielen Dank
http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.axis
Fügen Sie einfach das Stichwort Argument log=True
Oder in einem Beispiel:
from matplotlib import pyplot
import math
pyplot.plot([x for x in range(100)],[math.exp(y) for y in range(100)])
pyplot.xlabel('arbitrary')
pyplot.ylabel('arbitrary')
pyplot.title('arbitrary')
#pyplot.xscale('log')
pyplot.yscale('log')
pyplot.show()
Sie dieses Stück verwenden können Code:
import matplotlib.pyplot
# to set x-axis to logscale
matplotlib.pyplot.xscale('log')
# to set y-axis to logscale
matplotlib.pyplot.yscale('log')
Statt plot
können Sie semilogy
verwenden:
import numpy as npy
import matplotlib.pyplot as plt
x=npy.array([i/100. for i in range(100)])
y=npy.exp(20*x)
plt.semilogy(x, y)
plt.show()
Aber ich bin mir nicht ganz sicher, was Sie von der Verwendung einer logarithmischen Skala zu gewinnen hoffen. Wenn Sie "kleine Differenz" sagen, meinen Sie, dass die Werte etwa 193.000001 und 193.000002 sein könnten? Wenn ja, könnte es helfen, 193.
abzuziehen off Da alle anderen Antworten nur den globalen pyplot.xscale("log")
Ansatz erwähnen: Sie können es auch pro Achse, aber dann ist die Syntax:
ax.set_yscale("log")
Mögliches Duplikat von [ Zeichnen Sie logarithmische Achsen mit Matplotlib in Python] (http://stackoverflow.com/questions/773814/plot-logarithmic-axes-with-matplotlib-in-python) – bluenote10