亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Plotly 無法正確顯示 y 軸標簽

Plotly 無法正確顯示 y 軸標簽

慕斯709654 2021-11-09 14:51:27
我在使用 plotly 正確顯示 y 軸標簽時遇到問題。這是我的索引:index = ['2015-11','2015-12','2016-01','2016-02','2016-03','2016-04','2016-05',         '2016-06','2016-07','2016-08','2016-09','2016-10','2016-11']數據data = [[0.115, 0.077, 0.0, 0.038, 0.0, 0.038, 0.038, 0.077, 0.0, 0.077, 0.077, 0.038],  [0.073, 0.055, 0.083, 0.055, 0.018, 0.055, 0.073, 0.037, 0.028, 0.037, 0.009, 0.0],  [0.099, 0.027, 0.036, 0.045, 0.063, 0.153, 0.027, 0.045, 0.063, 0.027, 0.0, 0.0],  [0.076, 0.038, 0.053, 0.061, 0.098, 0.068, 0.038, 0.061, 0.023, 0.0, 0.0, 0.0],  [0.142, 0.062, 0.027, 0.08, 0.097, 0.044, 0.071, 0.027, 0.0, 0.0, 0.0, 0.0],  [0.169, 0.026, 0.026, 0.026, 0.013, 0.013, 0.091, 0.0, 0.0, 0.0, 0.0, 0.0],  [0.138, 0.121, 0.052, 0.017, 0.034, 0.017, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],  [0.297, 0.081, 0.054, 0.054, 0.054, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],  [0.095, 0.016, 0.024, 0.04, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],  [0.102, 0.023, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],  [0.054, 0.027, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],  [0.087, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],  [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]]我使用以下代碼創建了一個熱圖:import plotly.figure_factory as fffrom plotly.offline import iplotimport recols = range(12)index = indexdf = pd.DataFrame(data, columns = cols)df.index = indexx = df.columns.tolist()y = df.index.tolist()z = df.valuesannotation_text = np.char.mod('%.0f%%', df*100).tolist()annotation_text = [[re.sub('^0%$','', x) for x in l] for l in annotation_text]colorscale=[[0.0, 'rgb(248, 248, 255)'],             [0.04, 'rgb(224, 228, 236)'],             [0.08, 'rgb(196, 210, 226)'],             [0.12, 'rgb(158, 178, 226)'],            [0.16, 'rgb(134, 158, 227)'],            [0.2, 'rgb(122, 146, 227)'],            [1.0, 'rgb(65, 105, 225)'],            ]當我將索引更改為較短的值'5-11'時index = [x[3:] for x in index]標簽出現。我不明白這背后的邏輯,想知道如何解決它。
查看完整描述

1 回答

?
千巷貓影

TA貢獻1829條經驗 獲得超7個贊

Plotly.py 在幕后使用 plotly.js,它將您的日期字符串轉換為數字日期格式,并將它們錯放在您的非數字軸上。

要明確分類軸,您只需添加:

fig.layout.yaxis.type = 'category'


查看完整回答
反對 回復 2021-11-09
  • 1 回答
  • 0 關注
  • 131 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號