The default display of bar charts is vertical. This is intuitive and easy to understand. Each category or item takes a separate position on the xx axis, and the heights of the bars represent a certain quantity on the yy axis. The same applies when the bars are displayed horizontally, only in this case, the width of the bars is what represents the quantity. Usually, with relatively fewer values, the vertical orientation is good. However, horizontal orientation can be more effective in two cases.

  • When we have many categories: In this case, the bars might not fit on the screen, and we might need to either make them much thinner than the default width. Or we might need to force horizontal scrolling, which is not as natural as vertical scrolling.
  • When the names of the categories are relatively long: This is not really a big problem, and the solution is easy. Plotly already handles this for us by automatically changing the angle at which the names (tick labels) are displayed. If needed, the names can be displayed vertically for maximum space utilization. Reading text displayed horizontally is the most natural though, and it’s the most suitable way for these situations.

Calculating and analyzing the Gini index

Let’s see this in action using our poverty DataFrame so we can see the effects of these options and also get to know our dataset a little better. We’ll take a look at one of the most widely used measures of income/wealth inequality, the Gini index. It is also referred to as the Gini ratio or coefficient.

To learn a bit about it, we can use the series DataFrame, which contains information about the indicators that we will be working with.

Get hands-on with 1200+ tech skills courses.