轴在图上不按顺序
Axes not in order on plot
我一直在尝试使用坐标显示区域。
当我将坐标直接输入列表时,它会显示该区域。
但是,当我使用变量时,它不会。
#plotting a triangle using coordinates
print('Enter the coordinates')
Na = input('Northings of A = ')
Ea = input('Eastings of A = ')
Nb = input('Northings of B = ')
Eb = input('Eastings of B = ')
Nc = input('Northings of C = ')
Ec = input('Eastings of C = ')
import matplotlib.pyplot as plt
x = [Ea, Eb, Ec, Ea]
y = [Na, Nb, Nc, Na]
plt.plot(x, y, 'yellow')
plt.show()
x = [1500, 1720, 1244.52, 1500]
y = [5930.15, 6230.25, 3254.62, 5960.15]
plt.plot(x, y, 'purple')
plt.show()
我认为从输入转换为 int 是个问题,缺少 Nd 和 Ed 变量。
print('Enter the coordinates')
Na = input('Northings of A = ')
Ea = input('Eastings of A = ')
Nb = input('Northings of B = ')
Eb = input('Eastings of B = ')
Nc = input('Northings of C = ')
Ec = input('Eastings of C = ')
Nd = input('Northings of D = ')
Ed = input('Eastings of D = ')
import matplotlib.pyplot as plt
x = [int(Ea), int(Eb), int(Ec), int(Ed)]
y = [int(Na), int(Nb), int(Nc), int(Nd)]
plt.plot(x, y, 'green')
plt.show()
x = [1500, 1720, 1244.52, 1500]
y = [5930.15, 6230.25, 3254.62, 5960.15]
plt.plot(x, y, 'purple')
plt.show()
我一直在尝试使用坐标显示区域。 当我将坐标直接输入列表时,它会显示该区域。 但是,当我使用变量时,它不会。
#plotting a triangle using coordinates
print('Enter the coordinates')
Na = input('Northings of A = ')
Ea = input('Eastings of A = ')
Nb = input('Northings of B = ')
Eb = input('Eastings of B = ')
Nc = input('Northings of C = ')
Ec = input('Eastings of C = ')
import matplotlib.pyplot as plt
x = [Ea, Eb, Ec, Ea]
y = [Na, Nb, Nc, Na]
plt.plot(x, y, 'yellow')
plt.show()
x = [1500, 1720, 1244.52, 1500]
y = [5930.15, 6230.25, 3254.62, 5960.15]
plt.plot(x, y, 'purple')
plt.show()
我认为从输入转换为 int 是个问题,缺少 Nd 和 Ed 变量。
print('Enter the coordinates')
Na = input('Northings of A = ')
Ea = input('Eastings of A = ')
Nb = input('Northings of B = ')
Eb = input('Eastings of B = ')
Nc = input('Northings of C = ')
Ec = input('Eastings of C = ')
Nd = input('Northings of D = ')
Ed = input('Eastings of D = ')
import matplotlib.pyplot as plt
x = [int(Ea), int(Eb), int(Ec), int(Ed)]
y = [int(Na), int(Nb), int(Nc), int(Nd)]
plt.plot(x, y, 'green')
plt.show()
x = [1500, 1720, 1244.52, 1500]
y = [5930.15, 6230.25, 3254.62, 5960.15]
plt.plot(x, y, 'purple')
plt.show()