Mathematica 造轮子系列 图元直方图
来自群友,数据长这样
0.031415928 0.062831856 0.010138588
0.062831856 0.094247788 0.017316771
0.094247788 0.1256637 0.02326941
0.1256637 0.1570796 0.030749996
0.1570796 0.1884956 0.037005047
0.1884956 0.2199115 0.042878111
前两个数是每组数据的范围,第三个是频率,没有直接的函数,遂自己写
思路:
1.画横线(直方图顶)
{{#1,#3},{#2,#3}}&@@data[[1]]
2.画很多条横线,并连接(先用四条试试)
Flatten[{{#1,#3},{#2,#3}}&@@@data[[;;4]],1]
3.开始画并美化
Graphics[
[email protected][{{#1,#3},{#2,#3}}&@@@data,1],
AspectRatio->0.4,
Axes->True,
PlotRange->{{-0.2,1.8},Automatic},
LabelStyle->Directive[Black,
FontSize->14,
FontFamily->"Times New Roman"],
GridLines->{None,Automatic},
GridLinesStyle->LightGray
]