1

I have 115 columns, I want to plot the column names on the x-axis. But the column names are overlapping with each other. The y-axis has single row values.

features = fdf.iloc[0] # single row 
features.sort_values(ascending=False).plot(kind='bar')
plt.xticks(rotation=90)
plt.show()

This is the graph, as you can see that the x-axis labels are not clear. barplot picturd

Taku
  • 31,927
  • 11
  • 74
  • 85
rk__
  • 31
  • 1
  • 6
  • You simply had too many X labels for the space provided. Solutions include making the chart wider or cutting down the number of labels or split it off into multiple charts. Can you give some example of the X labels? I can't read them from the picture. – Code Different Oct 23 '21 at 14:10
  • x-labels are columns of the data frame. i have 115 columns. each column string is aroound 15 character string. as single row contains vlaues of y-axis. ```[MI_dir_L3_weight MI_dir_L3_mean MI_dir_L3_variance MI_dir_L1_weight MI_dir_L1_mean MI_dir_L1_variance MI_dir_L0.1_weight MI_dir_L0.1_mean MI_dir_L0.1_variance MI_dir_L0.01_weight MI_dir_L0.01_mean] ``` these are the some x-label strings. – rk__ Oct 23 '21 at 15:31
  • Thanks for adding the column samples. I think it make most sense to split this into multiple charts. You can split by statistics (all `weight` go into one chart, all `mean` go into another) or by data series (`L3`, `L0.1`, ...) – Code Different Oct 23 '21 at 15:35

1 Answers1

2

You have few options :

  • make the figure wider using figsize argument in plot
features.sort_values(ascending=False).plot(kind='bar', figsize = (15, 7))
  • Reduce the size of xticks label on x axis using fontsize argument in `xticks'
plt.xticks(rotation=90, fontsize = 'xx-small')

read about more options for fontsize here

Ajay Verma
  • 610
  • 2
  • 12