在我的研究中,我有一些理论计算。我想通过取理论值并从实验值中减去它们来表示此数据的准确性。这就留下了一些不同之处,我想用绘图来显示这些数据。
我已经模拟了我正在寻找的图的类型。红线是图的零,表示理论值和实验值之间没有差异。X轴有V1,V2,...,VN,它们是要计算的不同的东西。问题是,每个V都有两个或三个值,由我制作的模拟图形中的"X“表示。

我对如何做到这一点有点迷惑。我试着用Gnuplot查看多值直方图,但结果是空的。有没有人能对此给出一些见解,或者有一个工作的示例Gnuplot脚本?如果你知道用Python或其他方式做这件事的方法,我也愿意使用其他想法。问题是我对Python一无所知。
发布于 2014-08-26 01:37:38
使用gnuplot有几种方法可以实现这一点。这里有一个选择,我觉得很合理::
v-value的值存储在一个数据块中。两个数据块用两条新的线彼此分开。因此,示例数据文件可能是:V1 values -0.5 1.1 0.4 -0.2 # v2 values -0.1 -0.7 # v3 values 0.9 0.5 0.2labels = "v1 v2 v3“
-2,即using (column(-2))。此编号还可用于访问labels字符串中的相应标签。下面是一个示例脚本:
set xzeroaxis lc rgb 'red' lt 1 lw 2
set offset 0.2,0.2,0,0
set xtics 1
unset key
set linetype 1 linetype 2 lc rgb 'black' lw 2
labels = "v1 v2 v3"
plot 'data.dat' using (column(-2)):1:xtic(word(labels, column(-2)+1))4.6.5的结果是:

当然,根据您的实际需要,您可以选择修改或扩展此脚本。
发布于 2014-08-26 00:05:36
你似乎没有计算任何东西,所以你的图不是直方图。它是一堆水平排列的垂直一维散点图。
下面使用matplotlib来接近你的模型(出于习惯,我将“差异”重命名为相当传统的术语“残差”):
import numpy as np
import matplotlib.pyplot as plt
np.random.seed(123)
# Demo data consists of a list of names of the "variables",
# and a list of the residuals (in numpy arrays) for each variable.
names = ['V1', 'V2', 'V3', 'V4']
r1 = np.random.randn(3)
r2 = np.random.randn(2)
r3 = np.random.randn(3)
r4 = np.random.randn(3)
residuals = [r1, r2, r3, r4]
# Make the plot
for k, (name, res) in enumerate(zip(names, residuals)):
plt.plot(np.zeros_like(res) + k, res, 'kx',
markersize=7.0, markeredgewidth=2)
plt.ylabel("Residuals", fontsize=14)
plt.xlim(-1, len(names))
ax = plt.gca()
ax.set_xticks(range(len(names)))
ax.set_xticklabels(names)
plt.axhline(0, color='r')
plt.show()

https://stackoverflow.com/questions/25488770
复制相似问题