【发布时间】:2021-07-09 11:26:06
【问题描述】:
我正在尝试从数组的第 1 列创建线图。如果同一数组的第 2 列中的某个条件已满,则线图的标记应更改(如果条件已满,则标记 ='o',如果条件为假,则标记 ='x'。但是,结果我的情节不正确。
import numpy as np
import matplotlib.pyplot as plt
import random
###These are 100 random numbers
randomlist = random.sample(range(0, 100), 100)
###This is an array with 50 rows and 2 columns
arr = np.array(randomlist)
arr_re = arr.reshape(50,2)
### This is a lineplot of column 1 with different markers dependent on the value of column 2
figure, ax = plt.subplots(figsize=(13, 6))
for i in range(0,50,1):
#figure, ax = plt.subplots(figsize=(13, 6))
if arr_re[i,1] > 50:
ax.plot(arr_re[i,0], color="black", marker='o', label='1880-1999')
else:
ax.plot(arr_re[i,0], color="black", marker='x', label='1880-1999')
plt.show()
也许有人可以给我一个提示。 干杯icorrect_result plot should look like this, however with changing markers according to the condition of column2
【问题讨论】:
标签: python python-3.x