Iplot treats pandas numeric column as categorical

    import cufflinks as cf
    import plotly.offline
    import numpy as np
    import pandas as pd
    cf.set_config_file(offline=False, world_readable=True)
    y_chr = np.resize(np.array(list('abc')),5)
    y_num = np.array([22000,1,3,5000,3])
    df = pd.DataFrame({'chr':y_chr,'num':y_num})

The num column of the plotted dataframe is treated as categorical: y-axis represents numbers in the order they appeared in the num column.
I’d like the β€˜num’ column to be plotted as numerical.
How can it be done?

Thank you!

I believe the problem is that you are sharing the yaxis from your β€˜chr’ column to your β€˜num’ column. β€˜a’,β€˜b’,β€˜c’ are all categorical, and because 22000, 1, 3, and 5000 share the same axes as it, they are being treated as categorical. I would advise against using df.iplot() in this case, and splitting the two plots apart.

1 Like