Message Boards Message Boards

GROUPS:

How to assign negative ticks for barchart?

Posted 3 months ago
520 Views
|
2 Replies
|
1 Total Likes
|

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}}]
2 Replies

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}}]
Posted 3 months ago

Thanks man!!! Exactly what I need! Appreciated!!

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract