將 x 和 y 標籤添加到熊貓圖中 - Add x and y labels to a pandas plot

問題:

Suppose I have the following code that plots something very simple using pandas:假設我有以下代碼使用 Pandas 繪製一些非常簡單的內容:

import pandas as pd
values = [[1, 2], [2, 5]]
df2 = pd.DataFrame(values, columns=['Type A', 'Type B'], 
                   index=['Index 1', 'Index 2'])
df2.plot(lw=2, colormap='jet', marker='.', markersize=10, 
         title='Video streaming dropout by category')

輸出

How do I easily set x and y-labels while preserving my ability to use specific colormaps?如何輕鬆設置 x 和 y 標籤,同時保留使用特定顏色圖的能力? I noticed that the plot() wrapper for pandas DataFrames doesn't take any parameters specific for that.我注意到 Pandas DataFrames 的plot()包裝器沒有采用任何特定於此的參數。


解決方案:

參考一: https://stackoom.com/question/1S9pp
參考二: Add x and y labels to a pandas plot
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章