Mathematica中没有垂直线的直方图

tos*_*tos 11 wolfram-mathematica histogram

我试图制作没有垂直线的直方图.我想要一个看起来像功能的情节.像这样: 在此输入图像描述

R之前已经问过同样的问题(没有垂直线的直方图),但我在Mathematica上.

我一直在研究这些ChartStyle选择而没有成功.

abc*_*bcd 5

可能有一些方法可以通过摆弄EdgeForm[]FaceForm[]in来做到这一点Histogram,但我发现在需要时自己滚动一个更简单。这是一个非常简单快捷的示例:

histPlot[data_, bins_, color_: Blue] := Module[{
        countBorder = 
    Partition[Riffle[Riffle[#1, #1[[2 ;;]]], Riffle[#2, #2]], 2] & @@ 
     HistogramList[data, bins, "PDF"]
    },
    ListLinePlot[countBorder, PlotStyle -> color]
    ]
Run Code Online (Sandbox Code Playgroud)

histPlot[RandomReal[NormalDistribution[],{1000}],{-3,3,0.1}]给予

在此处输入图片说明

然后,您可以扩展它以采用任何选项,而不仅仅是"PDF",以及您想自动选择垃圾箱的情况。我不喜欢自动分箱,因为我喜欢控制我的分箱宽度和范围以实现可预测性和与其他图的轻松比较。


Hei*_*ike 5

你也可以使用ListPlot具有InterpolationOrder->0:

(* example data *)
data = RandomVariate[NormalDistribution[], 10^3];

hist = HistogramList[data, {.5}];

ListPlot[Transpose[{hist[[1]], ArrayPad[hist[[2]], {0, 1}, "Fixed"]}],
  InterpolationOrder -> 0, 
  Joined -> True, 
  AxesOrigin -> {hist[[1, 1]], 0}]
Run Code Online (Sandbox Code Playgroud)

直方图