Also habe ich versucht, Textdateien auf mehrere Unterplots zu laden, aber die Plots scheinen immer als eine Textdatei zu kommen. Kann mir jemand in die richtige Richtung zeigen, wie ich das anstellen soll?Unterpläne aus mehreren Textdateien in einer Schleife erstellen
import numpy as np
import matplotlib.pyplot as plt
RiverData1 = np.loadtxt('Gray1961.txt', skiprows = 2)
RiverData2 = np.loadtxt('Hack1957.txt', skiprows = 2)
RiverData3 = np.loadtxt('Rignon1996.txt', skiprows = 2)
RiverData4 = np.loadtxt('Robert1990.txt', skiprows = 2)
RiverData5 = np.loadtxt('Langbein1947_p145.txt', skiprows = 2)
RiverData6 = np.loadtxt('Langbein1947_p146.txt', skiprows = 2)
RiverData7 = np.loadtxt('Langbein1947_p149.txt', skiprows = 2)
RiverData8 = np.loadtxt('Langbein1947_p152.txt', skiprows = 2)
plotnums = 1
for plotnums in range (1,9):
plt.subplot(2,4,plotnums)
plt.plot((RiverData1[:,0]), (RiverData1[:,1]),'ko')
plt.plot((RiverData2[:,0]), (RiverData2[:,1]),'ko')
plt.plot((RiverData3[:,0]), (RiverData3[:,1]),'ko')
plt.plot((RiverData4[:,0]), (RiverData4[:,1]),'ko')
plt.plot((RiverData5[:,0]), (RiverData5[:,1]),'ko')
plt.plot((RiverData6[:,0]), (RiverData6[:,1]),'ko')
plt.plot((RiverData7[:,0]), (RiverData7[:,1]),'ko')
plt.plot((RiverData8[:,0]), (RiverData8[:,1]),'ko')
plt.xlabel('River Length (km)')
plt.ylabel('Area (Km$^2$)')
plt.xscale('log')
plt.yscale('log')
plotnums=plotnums+1
plt.show()
Entfernen Sie die 'plotnums = plotnums + 1' in der for-Schleife – Thiru