如何在相关图上划分或切割范围

问题描述 投票:0回答:1
import matplotlib.pyplot as plt

a = [83, 83, 83.5, 83.8, 83.9, 83.7, 84.3, 84.6, 85.2, 85.7, 85.7, 85.7, 86.3, 86.8, 87.4, 87.4, 87.4, 87.4, 87.6, 88.2, 88.8, 89.4, 89.7, 89.9, 90.5, 91.1, 92, 92.7, 93.3, 93.8, 94.7, 95.4, 96, 96.4, 96.4, 95.8, 95.7, 95.8, 95.7, 95.7, 95.7, 96, 96.6, 97.2, 98.1, 98.8, 98.9, 98.6, 98.3, 98.5, 98.7, 98.6, 98.9, 99.4, 100.1, 100.2, 100.3, 100.3, 100, 99.6, 99.8, 100.1, 100.2, 100.2, 99.9, 99.7, 99.6, 100.8, 102.2, 102.4, 101.6, 100.8, 100.3, 99.9, 99.2, 99, 98.8, 99.1, 99.6, 99.9, 100.3, 100.8, 101.7, 102.7, 103.4, 104.7, 105.5, 105.5, 106.3, 108.3, 110.7, 112, 112.9, 114.4, 117, 119.8, 122.9, 125.1, 126.7, 128.3, 130.5, 133.4, 136.5, 139.7, 142.3, 143.8, 143, 141.6, 140.7, 140.6, 141.1, 141.8, 140.5, 139.8, 136.1, 133.4, 130.6, 126.2, 121.1]
b = [2.75, 2.75, 2.75, 2.75, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.25, 2.25, 2, 2, 2, 2, 2, 1.75, 1.75, 1.75, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.25, 1.25, 1.25, 1.25, 1.25, 1.25, 1.25, 1.25, 1.25, 1.25, 1.25, 1.25, 1.25, 1.25, 1.25, 1.25, 1.25, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.75, 1.75, 1.75, 1.75, 1.75, 1.75, 1.75, 1.75, 1.5, 1.5, 1.5, 1.25, 1.25, 1.25, 1.25, 1.25, 0.75, 0.75, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.75, 0.75, 0.75, 1, 1, 1.25, 1.25, 1.25, 1.5, 1.75, 1.75, 2.25, 2.5, 2.5, 3, 3.25]
   
plt.scatter(a, b) 

enter image description here

在这个数据中,我们可以用Python从技术上提取范围吗?

python matplotlib correlation
1个回答
0
投票

假设您的意思是如何找到给定范围内的所有点,您可以使用列表理解来实现

a = [83, 83, 83.5, 83.8, 83.9, 83.7, 84.3, 84.6, 85.2, 85.7, 85.7, 85.7, 86.3, 86.8, 87.4, 87.4, 87.4, 87.4, 87.6, 88.2, 88.8, 89.4, 89.7, 89.9, 90.5, 91.1, 92, 92.7, 93.3, 93.8, 94.7, 95.4, 96, 96.4, 96.4, 95.8, 95.7, 95.8, 95.7, 95.7, 95.7, 96, 96.6, 97.2, 98.1, 98.8, 98.9, 98.6, 98.3, 98.5, 98.7, 98.6, 98.9, 99.4, 100.1, 100.2, 100.3, 100.3, 100, 99.6, 99.8, 100.1, 100.2, 100.2, 99.9, 99.7, 99.6, 100.8, 102.2, 102.4, 101.6, 100.8, 100.3, 99.9, 99.2, 99, 98.8, 99.1, 99.6, 99.9, 100.3, 100.8, 101.7, 102.7, 103.4, 104.7, 105.5, 105.5, 106.3, 108.3, 110.7, 112, 112.9, 114.4, 117, 119.8, 122.9, 125.1, 126.7, 128.3, 130.5, 133.4, 136.5, 139.7, 142.3, 143.8, 143, 141.6, 140.7, 140.6, 141.1, 141.8, 140.5, 139.8, 136.1, 133.4, 130.6, 126.2, 121.1]
b = [2.75, 2.75, 2.75, 2.75, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, 2.25, 2.25, 2, 2, 2, 2, 2, 1.75, 1.75, 1.75, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.25, 1.25, 1.25, 1.25, 1.25, 1.25, 1.25, 1.25, 1.25, 1.25, 1.25, 1.25, 1.25, 1.25, 1.25, 1.25, 1.25, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.75, 1.75, 1.75, 1.75, 1.75, 1.75, 1.75, 1.75, 1.5, 1.5, 1.5, 1.25, 1.25, 1.25, 1.25, 1.25, 0.75, 0.75, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.75, 0.75, 0.75, 1, 1, 1.25, 1.25, 1.25, 1.5, 1.75, 1.75, 2.25, 2.5, 2.5, 3, 3.25]

left_bound = 105
right_bound = 137

res = [[x, b[i]] for i, x in enumerate(a) if x >= left_bound and x <= right_bound]
© www.soinside.com 2019 - 2024. All rights reserved.