How to remove space cufflinks bar unnecessarily spaced where values are ints

I’m doing a pd.crosstab and trying to plot the values, but the cufflinks are returning a wrong chart;

Reproducible code:
data = dict()
data[‘article’] = [1, 2, 3, 60, 60, 3, 25, 25, 1]
data[‘Toxic’] = [‘Non-Toxic’, ‘Non-Toxic’, ‘Non-Toxic’, ‘Non-Toxic’, ‘Non-Toxic’, ‘Non-Toxic’,‘Toxic’, ‘Toxic’, ‘Non-Toxic’]

df = pd.DataFrame(data)

df.groupby(‘article’)[‘Toxic’].count().iplot(kind=‘bar’)

Result of the reproducible code:

I need to remove the spaces and set just the columns with values, like a categorical bar chart.

Could someone give me some light on this problem?

Thank you very much

Hi @kabure,

Could you add a reproducible example that shows the problem you’re running into? And just so you know, I’m not sure if there are many cufflinks users on these forums. But if you include some sample data and describe the plot you want to end up with folks still may be able to help out.

-Jon

1 Like

Hi Jmease, I included a reproducible code in my question.

Thank you very much for your attention.

Hi @kabure,

I think you’ll need to set the x axis type to 'category' (See https://plot.ly/python/reference/#layout-xaxis-type for property reference). I’m not sure if cufflnks exposes this as an option. If not, I think you could do something like

df = ...
fig = df.iplot(kind=‘bar’, asFigure=True)
fig.layout.xaxis.type = 'category'
iplot(fig)

-Jon

1 Like

It worked, jmmease. Thank you very much