11625060
(Nan Zhang)
August 20, 2021, 3:48am
1
Hi all, I am trying to plot a distribution graph and bar chart together, but I did not find any documents on how to change ticks for bar chart, especially for negative numbers.
Does anyone know how to solve this problem? The range for x is -5 to 5。
Thanks in advance for any help!
The code is :
data = Table[PDF[ NormalDistribution[0, 1], x], {x, -5, 5, 0.5}];
l1 = ListLinePlot[data, InterpolationOrder -> 2];
b1 = BarChart[data, LabelStyle -> Small, BarSpacing -> None];
Show[l1, b1, Frame -> True,
FrameTicks -> {{True, None}, {True, None}}]
mfroeling
(Martijn Froeling)
August 20, 2021, 11:11am
2
This does the trick
xdata = Range[-5, 5, 0.5];
data = Table[PDF[NormalDistribution[0, 1], x], {x, xdata}];
tcs = Thread[{Range[Length[xdata]], xdata}][[;; ;; 2]];
l1 = ListLinePlot[data, InterpolationOrder -> 2]
b1 = BarChart[data, LabelStyle -> Small, BarSpacing -> None,
Axes -> False]
Show[l1, b1, Frame -> True,
FrameTicks -> {{Automatic, None}, {tcs, None}}]
11625060
(Nan Zhang)
August 20, 2021, 2:52pm
3
Thanks man!!!
Exactly what I need!
Appreciated!!