✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
⚡️ Concerned about the grid? Kyle Baranko teaches how to predicting peak loads using XGBoost. Register for the August webinar!

Limiting the Number of Bars Displayed

Hello,

I have a stacked bar chart with city names for the labels and population numbers for the y-axis. The issue is that there are a lot of cities in the graph and I want to just display the top 15 cities with the highest population.

Is there an option to set the number of labels displayed on the X axis? I read there is a range option for the X axis and have tried to do something with it but no luck. Is this something that can be done as an argument in the layout or do I have to fix it on the code to just show the top 15 cities? Fixing the code would be fairly simply to do if it were not a stacked chart but I’m having a bit of trouble with limiting the colums displayed through the code.

Thank you,

Hi @riskfree,

Probably it’ll be just more easier to filter the rows in the dataframe first and then plotting it on a graph.

2 Likes