我将2d数据(30K)设置为txt文件.
X Y
2.50 135.89
2.50 135.06
2.50 110.85
2.50 140.92
2.50 157.53
2.50 114.61
2.50 119.53
2.50 154.14
2.50 136.48
2.51 176.85
2.51 147.19
2.51 115.59
2.51 144.57
2.51 148.34
2.51 136.73
2.51 118.89
2.51 145.73
2.51 131.43
2.51 118.17
2.51 149.68
2.51 132.33
Run Code Online (Sandbox Code Playgroud)
我用gnuplot绘制了一个散点图,但我想表示为heatmap2d或密度分布.我查看了MatPlotLib或R中的示例,他们似乎都已经开始使用随机数据来生成图像.
我尝试了这些代码并得到这样的错误
hist,edges = histogramdd([x,y],bin,range,normed,weights)
AttributeError:bin的维度必须等于样本x的维度.脚本已终止.
有没有方法可以打开txt文件并在gnuplot,matplotlib中绘制这些数据.我的散点图看起来像这样

我想将此图片显示为带有颜色代码条的等高线图或密度图.我的x轴在2.5-3.5范围内,y轴在110-180范围内,我有30k数据点
我在text.txt文件中有一个数字列表.
2.50
2.56
2.81
2.86
2.84
3.21
3.47
2.91
2.96
3.11
2.83
2.89
2.94
2.94
3.34
3.44
2.94
2.96
3.04
3.01
2.85
3.05
3.10
我想收集每组数量的范围.喜欢一个范围内的多少.
2.5-2.7
2.7-2.9
2.9-3.1
3.1-3.3
3.3-3.5
我试过这个.
from __future__ import division
from math import *
from numpy import *
from string import*
infile = open('text1.txt', 'r')
text = infile.read().split('\n')
infile.close()
text.remove('')
numbers = []
for i in text:
count = 0
if (numbers[i] > 2.49) and (numbers[i] < 2.59):
count += 1
print("Number of elements", count) …Run Code Online (Sandbox Code Playgroud)