I\'m trying to implement a DateListBarChart
function that takes dated data and outputs a bar chart with the same placements as DateListPlot
. It\'s
Maybe using the ChartElementFunction option instead of BarSpacing helps. For example barplot
in the code would plot a bar chart such that each bar has margins of gapl
on the left and gapr
on the right where gapl
and gapr
are fractions of the total width of the bar
scale[{{xmin_, xmax_}, {ymin_, ymax_}}, {gapl_, gapr_}] :=
{{xmin (1 - gapl) + xmax gapl, ymin}, {xmax (1 - gapr) + xmin gapr, ymax}}
barplot[dists_, arList_, {gapl_, gapr_}, opts___] :=
RectangleChart[Transpose[{dists, arList }], opts,
Frame -> True,
GridLines -> Automatic, BarSpacing -> 0,
ChartElementFunction -> (Rectangle @@ scale[#, {gapl, gapr}] &)]
Usage:
To plot the original bar chart with no gaps
barplot[dists, arList, {0, 0}]
This would plot a bar chart with a margin of 0.2 on both sides which results in a bar chart with gaps of 0.4 times the total width of the bars. Note that the positions of the bars matches with those in the first figure.
barplot[dists, arList, {0.2, 0.2}]
You can plot multiple series by doing something like
Show[barplot[dists, arList 0.9, {0, 0.5}],
barplot[dists, arList 0.8, {0.5, 0}, ChartStyle -> LightGreen]]
You may relieve your complaint about FillingStyle
by using CapForm["Butt"]
.
list = {0.01, -0.81, 0.12, 0.81, 1.79, 1.1, 0.41, 1., 1.33, 1.08,
2.16, 1.13, 1.92, 1.64, 1.31, 1.94, 1.71, 0.91, 2.32, 0.95, 1.29,
1.28, 2.97, 4.45, 5.11}
DateListPlot[list, {2000, 8},
PlotStyle -> {AbsolutePointSize[6], Yellow}, Filling -> {1 -> 0},
FillingStyle -> {1 -> {{CapForm["Butt"], AbsoluteThickness[14],
Darker[Red, 0.25]}}}, PlotRange -> {0, 6}, ImageSize -> 400]