0
我正在嘗試使用plotly
創建交互式圖並且在訂購X軸時遇到問題。下面是我使用的代碼:使用plotly降序排列X軸
import plotly.plotly as py
import cufflinks as cf
import pandas as pd
import plotly.tools as tls
tls.set_credentials_file(username='ladeeda', api_key='ladeeda')
cf.set_config_file(offline=False, world_readable=True, theme='pearl')
StudentModalityRetention[StudentModalityRetention['schoolyearsemester'] == 'Sem3']\
.iplot(kind='bubble', x='branch', y='retention', size='active_users', text='active_users',
xTitle='', yTitle='Retention',
filename='cufflinks/Sem3ModalityRetention')
,這裏是所生成的情節:
我想按降序或Y軸安排X軸。換句話說,我希望Y值最高的泡泡先出現,依此類推。
任何幫助將不勝感激。
非常感謝您的回答。我在'iplot'調用之前添加了'.sort_values(axis ='retention',ascending = False,inplace = True)',並且我得到以下錯誤:' TypeError:sort_values()至少需要2個參數)'。我甚至沒有4個參數。你會碰巧知道爲什麼會發生這種情況嗎? – Patthebug
@Patthebug非常抱歉,因爲我忘記提及sort_values函數工作所必需的'by'參數。對於列分類,軸始終爲0。您可以驗證結果。如有不便之處,敬請原諒。 –
原來,只需要'sort_values(by ='retention',ascending = False')。沒有道歉需要,你是巨大的幫助。非常感謝 :)。 – Patthebug