我有以下柱状图:
现在,我相信你们中的很多人都会给我指出matplotlib库和其他资源的方向,但是出于某种原因,我想到的,以及随后从各种不同来源读取的内容与我的轴柱状图不太相符。(如果我错了,请纠正我!)在
我的问题是:
如何从(2,2,1)和(2,2,4)图中直方图上叠加的行分割的位置填充直方图。在
x直方图(位置2,2,1)在x = -0.222
处绘制了vline
,而y直方图在y = 0.49
处绘制了hline
。在
示例工作代码(仅针对原始数组中的任何数组进行了修改),如下所示:
import numpy as np
import scipy
import matplotlib as mpl
import matplotlib.pyplot as plt
import pylab
X = 0.32, 0.41, 0.45, 0.53, -0.23, 0.34, 0.35, 0.47, 0.48, 0.33, 0.49, -0.10, -0.23, 0.45, 0.19
Y = 0.56, 0.67, 0.49, 0.61, 0.00, -0.02, -0.12, 0.12, 0.23, 0.44, 0.56, 0.13, 0.56, 0.67, 0.28
binsize = 0.1
min_x_data, max_x_data = np.min(X), np.max(X)
num_x_bins = np.floor((max_x_data - min_x_data) / binsize)
min_y_data, max_y_data = np.min(Y), np.max(Y)
num_y_bins = np.floor((max_y_data - min_y_data) / bin size)
fig = plt.figure(221)
axScatter = fig.add_subplot(223)
axScatter.scatter(X, Y)
axScatter.set_xlim(-2.0, 1.5)
axScatter.set_ylim(-2.0, 2.5)
axHistX = fig.add_subplot(221)
axHistX.set_xlim(-2.0, 1.5)
axHistX.set_ylim(0, 10)
axHistY = fig.add_subplot(224)
axHistY.set_xlim(0, 10)
axHistY.set_ylim(-2.0, 2.5)
axHistX.hist(X, num_x_bins, ec='0.3', fc='none', histtype='step')
axHistY.hist(Y, num_y_bins, ec='0.3', fc='none', histtype='step', orientation='horizontal')
axScatter.axhline(y=0.49, xmin=0, xmax=1, linestyle='-.',c='k')
axScatter.axvline(x=-0.222, ymin=0, ymax=1, linestyle='-.',c='k')
axHistX.axvline(x=-0.222, ymin=0, ymax=1, linestyle='-.',c='k')
axHistY.axhline(y=0.49, xmin=0, xmax=1, linestyle='-.',c='k')
plt.show()
所以在这里我最后一次尝试,但强烈建议您学习python和 matplotlib。在
相关问题 更多 >
编程相关推荐