Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stacked groupedbar hides xtick labes for Dates #497

Open
SirLukeSchande opened this issue Apr 25, 2022 · 3 comments
Open

Stacked groupedbar hides xtick labes for Dates #497

SirLukeSchande opened this issue Apr 25, 2022 · 3 comments

Comments

@SirLukeSchande
Copy link

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.

@sethaxen
Copy link
Member

Hi, can you please provide a minimum working example demonstrating the problem?

@thorek1
Copy link

thorek1 commented Jun 14, 2024

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

@thorek1
Copy link

thorek1 commented Jun 15, 2024

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants