# Scatter plot with bar markers

I'm trying to essentially make a scatter plot where instead of points, the markers are bars that connect the point to the bottom of the graph (like a histogram). My problem is that my graph has something like 30 points and the x-axis labels are smashed together. I tried doing it with Histograms to no avail, and tried doing it with BarChart with a bit more success, but there are so many markers on the x-axis that you can't read them. My problems would be solved if I could specify only a few markers at certain positions. Can anyone help?

Below is what the graph looks like: I think it's pretty self-explanatory what the problem is even just by looking at it.

-
Have you looked at the Filling option of ListPlot[]? – J. M. Feb 19 at 6:25
What @J.M. suggested plus make your own x axis tick labels or tick function – Mike Honeychurch Feb 19 at 6:28
Try plotting your data with ListStepPlot, use the "Center" arguement. – Quantum_Oli Feb 19 at 8:56

It's a good question and something I've dealt with recently when essentially trying to plot a histogram but when I already have the data binned. After using ListLinePlot with InterpolationOrder->0 I discovered the very useful ListStepPlot function. Allow me to demonstrate.

If we have some samples we can just use Histogram:

    samples = RandomVariate[SkewNormalDistribution[4, 1, 2], 100000];
Histogram[samples, {0, 10, 0.1}, "Probability"]


However, if you already have the data points corresponding to the elements of the histogram, as in your case.

    {binEdges, counts} = HistogramList[samples, {0, 10, 0.1}, "Probability"];
dataPoints = Transpose[{MovingAverage[binEdges, 2], counts}];


Then as you say, BarChart is not so good:

    BarChart[dataPoints[[;; , 2]], ChartLabels -> dataPoints[[;; , 1]]]


However, ListStepPlot makes things very easy!

    ListStepPlot[dataPoints, "Center", Filling -> Axis]


And you can use all the normal plot styling functionality

    ListStepPlot[dataPoints, "Center",
PlotStyle -> RGBColor[0.982864, 0.7431472, 0.3262672],
Filling -> Axis,
FillingStyle -> Opacity[1],
Frame -> True,
GridLines -> Automatic]


Good Luck!

-
Thank you so much! – user37840 Feb 21 at 19:16

One way would be like the following. Assume that this is your list:

lst = Table[{i, i^(1/2)*Exp[-i]}, {i, 0, 4, 0.05}];


And here is you histogram-like plot:

 Show[Graphics[{Blue,
Rectangle[{#[[1]] - 0.025, 0}, {#[[1]] + 0.025, #[[2]]}]},
AspectRatio -> 1, Axes -> True] & /@ lst]
`

looking as follows:

Have fun!

-