我正在尝试制作没有垂直线的直方图。我想有一个看起来像一个功能的情节。像这样: Mathematica中没有垂直线的直方图
同样的问题已被要求R之前(histogram without vertical lines),但我在Mathematica。
我一直在寻找ChartStyle
选项没有成功。
我正在尝试制作没有垂直线的直方图。我想有一个看起来像一个功能的情节。像这样: Mathematica中没有垂直线的直方图
同样的问题已被要求R之前(histogram without vertical lines),但我在Mathematica。
我一直在寻找ChartStyle
选项没有成功。
可能有办法通过EdgeForm[]
和FaceForm[]
在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]
]
做histPlot[RandomReal[NormalDistribution[],{1000}],{-3,3,0.1}]
给出
然后,您可以扩展此采取任何选项,而不是仅仅"PDF"
,和情况下,当你想自动选择垃圾箱。我不喜欢自动分箱,因为我喜欢控制我的分箱宽度和范围以实现可预测性,并且可以轻松与其他地块进行比较。
你也使用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}]
这里有两种方法,在7版本下工作,使用后处理:
rdat = RandomReal[NormalDistribution[0, 1], 200];
MapAt[
{Blue,
Line[# /. {{Rectangle[{x_, y_}, {X_, Y_}]}} :> Sequence[{x, Y}, {X, Y}]] } &,
Histogram[rdat, PerformanceGoal -> "Speed"],
{1, 2, 2, 2}
]
Cases[
Histogram[rdat, PerformanceGoal -> "Speed"],
Rectangle[{x_, y_}, {X_, Y_}] :> {{x, Y}, {X, Y}},
\[Infinity]
];
Graphics[Line[Join @@ %], AspectRatio -> 1/GoldenRatio, Axes -> True]
在升级之前,这与我在v7中使用的非常接近。我不认为这些将在第8版中起作用,因为“直方图”已经发生变化 – abcd 2012-01-13 02:02:58
谢谢尤达和海克对你有所帮助。尤达,你的独立功能运作良好。 – tos 2012-01-12 21:56:46