Message Boards Message Boards

0
|
2050 Views
|
2 Replies
|
1 Total Likes
View groups...
Share
Share this post:

How to assign negative ticks for barchart?

Posted 2 years ago

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}}]
POSTED BY: Nan Zhang
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 BY: Martijn Froeling
Posted 2 years ago

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

POSTED BY: Nan Zhang
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