StatsPlots.jl
StatsPlots.jl copied to clipboard
Stacked groupedbar hides xtick labes for Dates
groupedbar
with dates as x-labels does not show xticks when bar_position=:stack
is selected.
This is the case both in gr and pgfplotsx. I haven't tested the others yet.
Hi, can you please provide a minimum working example demonstrating the problem?
here is a MWE
using StatsPlots
using Dates
# Sample Data
dates = [Date(2023, 1, 1), Date(2023, 2, 1), Date(2023, 3, 1)]
category1 = [10, 20, 30]
category2 = [15, 25, 35]
# Prepare data for grouped bar plot
data = hcat(category1, category2)
# Create the grouped bar plot with dates on the x-axis
groupedbar(dates, data, bar_position=:stack, label=["Category 1" "Category 2"])
fix would be very welcome. I am using GR backend
here is an imperfect workaround:
using StatsPlots
using Dates
# Sample Data
dates = [Date(2023, 1, 1), Date(2023, 2, 1), Date(2023, 3, 1)]
category1 = [10, 20, 30]
category2 = [15, 25, 35]
# Prepare data for grouped bar plot
data = hcat(category1, category2)
# Create the grouped bar plot with dates on the x-axis
groupedbar(dates, data, bar_position=:stack, label=["Category 1" "Category 2"])
groupedbar(data, bar_position=:stack, label=["Category 1" "Category 2"], xformatter= x-> begin println(x)
string(dates[min(ceil(Int,x),length(dates))])
end)