我使用的是R,我有两个数据框:胡萝卜和黄瓜.每个数据框都有一个数字列,列出了所有测量胡萝卜(总计:100k胡萝卜)和黄瓜(总计:50k黄瓜)的长度.
我希望在同一块情节上绘制两个直方图 - 胡萝卜长度和黄瓜长度.它们重叠,所以我想我也需要一些透明度.我还需要使用相对频率而不是绝对数字,因为每组中的实例数不同.
像这样的东西会很好,但我不明白如何从我的两个表创建它:

我使用文件中的数据创建了直方图,没有问题.现在我想在同一个直方图中叠加来自另一个文件的数据,所以我做了类似的事情
n,bins,patchs = ax.hist(mydata1,100)
n,bins,patchs = ax.hist(mydata2,100)
Run Code Online (Sandbox Code Playgroud)
但问题是,对于每个区间,只显示具有最高值的条,而另一个区间是隐藏的.我想知道如何用不同的颜色同时绘制两个直方图.
我知道如果我的.dat文件已经正确装箱数据,如何在gnuplot中创建直方图(只需使用"带框").有没有办法获取数字列表并让gnuplot根据用户提供的范围和bin大小提供直方图?
我正在使用matplotlib来制作直方图.
基本上,我想知道是否有任何方法可以手动设置垃圾箱的大小而不是垃圾箱的数量.
任何有任何想法的人都非常感谢.
谢谢
有没有办法用边缘直方图创建散点图,就像下面的示例一样ggplot2?在Matlab中它是scatterhist()函数,并且R也存在等价物.但是,我还没有看到ggplot2.

我开始尝试创建单个图形,但不知道如何正确排列它们.
require(ggplot2)
x<-rnorm(300)
y<-rt(300,df=2)
xy<-data.frame(x,y)
xhist <- qplot(x, geom="histogram") + scale_x_continuous(limits=c(min(x),max(x))) + opts(axis.text.x = theme_blank(), axis.title.x=theme_blank(), axis.ticks = theme_blank(), aspect.ratio = 5/16, axis.text.y = theme_blank(), axis.title.y=theme_blank(), background.colour="white")
yhist <- qplot(y, geom="histogram") + coord_flip() + opts(background.fill = "white", background.color ="black")
yhist <- yhist + scale_x_continuous(limits=c(min(x),max(x))) + opts(axis.text.x = theme_blank(), axis.title.x=theme_blank(), axis.ticks = theme_blank(), aspect.ratio = 16/5, axis.text.y = theme_blank(), axis.title.y=theme_blank() )
scatter <- qplot(x,y, data=xy) + scale_x_continuous(limits=c(min(x),max(x))) + scale_y_continuous(limits=c(min(y),max(y)))
none <- qplot(x,y, data=xy) + geom_blank()
Run Code Online (Sandbox Code Playgroud)
并使用 …
在阅读numpy时,我遇到了这个功能numpy.histogram().
它是什么,它是如何工作的?在文档中他们提到了垃圾箱:它们是什么?
所以我有一点问题.我有一个scipy的数据集已经是直方图格式,所以我有bin的中心和每个bin的事件数.我现在如何绘制直方图.我试着做
bins, n=hist()
Run Code Online (Sandbox Code Playgroud)
但它不喜欢那样.有什么建议?
查看和理解TensorBoard中的标量值非常简单.但是,目前还不清楚如何理解直方图.
例如,它们是我的网络权重的直方图.
(由于sunside修复了一个bug)
解释这些的最佳方法是什么?第1层重量看起来大致平坦,这意味着什么?
我在这里添加了网络构造代码.
X = tf.placeholder(tf.float32, [None, input_size], name="input_x")
x_image = tf.reshape(X, [-1, 6, 10, 1])
tf.summary.image('input', x_image, 4)
# First layer of weights
with tf.name_scope("layer1"):
W1 = tf.get_variable("W1", shape=[input_size, hidden_layer_neurons],
initializer=tf.contrib.layers.xavier_initializer())
layer1 = tf.matmul(X, W1)
layer1_act = tf.nn.tanh(layer1)
tf.summary.histogram("weights", W1)
tf.summary.histogram("layer", layer1)
tf.summary.histogram("activations", layer1_act)
# Second layer of weights
with tf.name_scope("layer2"):
W2 = tf.get_variable("W2", shape=[hidden_layer_neurons, hidden_layer_neurons],
initializer=tf.contrib.layers.xavier_initializer())
layer2 = tf.matmul(layer1_act, W2)
layer2_act = tf.nn.tanh(layer2)
tf.summary.histogram("weights", W2)
tf.summary.histogram("layer", layer2)
tf.summary.histogram("activations", layer2_act)
# Third layer of weights
with tf.name_scope("layer3"): …Run Code Online (Sandbox Code Playgroud) R中是否有适合直方图曲线的函数?
假设您有以下直方图
hist(c(rep(65, times=5), rep(25, times=5), rep(35, times=10), rep(45, times=4)))
Run Code Online (Sandbox Code Playgroud)
它看起来很正常,但它是偏斜的.我想要拟合一条倾斜的正常曲线来包裹这个直方图.
这个问题相当基本,但我似乎无法在互联网上找到R的答案.
据我所知,直方图函数中的选项Log = True仅指y轴.
P.hist(d,bins=50,log=True,alpha=0.5,color='b',histtype='step')
Run Code Online (Sandbox Code Playgroud)
我需要垃圾箱在log10中等间隔.有什么东西能做到吗?
histogram ×10
python ×5
matplotlib ×4
numpy ×3
r ×3
plot ×2
binning ×1
ggplot2 ×1
gnuplot ×1
r-faq ×1
scatter-plot ×1
scipy ×1
tensorboard ×1
tensorflow ×1