Ich möchte die obere Grenze der y-Achse auf "auto", aber ich möchte die untere Grenze der y-Achse ist immer Null. Ich habe 'Auto' und 'Autorange' versucht, aber das scheint nicht zu funktionieren. Vielen Dank im Voraus.Wie man "auto" für die obere Grenze setzt, aber eine feste untere Grenze mit matplotlib.pyplot
Hier ist mein Code:
import matplotlib.pyplot as plt
def plot(results_plt,title,filename):
############################
# Plot results
# mirror result table such that each parameter forms an own data array
plt.cla()
#print results_plt
XY_results = []
XY_results = zip(*results_plt)
plt.plot(XY_results[0], XY_results[2], marker = ".")
plt.title('%s' % (title))
plt.xlabel('Input Voltage [V]')
plt.ylabel('Input Current [mA]')
plt.grid(True)
plt.xlim(3.0, 4.2) #***I want to keep these values fixed"
plt.ylim([0, 80]) #****CHANGE**** I want to change '80' to auto, but still keep 0 as the lower limit
plt.savefig(path+filename+'.png')
Ich habe einen Fehler, wenn ich die linke für die set_ylim übergeben. Ich habe dies stattdessen verwendet: plt.gca(). Set_ylim (ymin = 0) Vielen Dank für Ihre Hilfe. – vietnastee
Sie können auch 'plt.xlim' oder' plt.ylim' verwenden, um die Grenzen für die aktuelle Achse festzulegen. – Chris
Wenn ich dies tue, bleibt der obere Grenzwert bei jedem Wert, in dem das Fenster instanziiert wird. Es bleibt nicht automatisch Skalierung. – Elliot