簡體   English   中英

如何顯示圖表熱圖中的兩列數據?

[英]How to display data from two columns in chartify heatmap?

使用文檔中的示例,構建熱圖並在每個單元格中顯示total_price 我想從另一列添加數據,例如“水果”,以顯示在每個單元格的total_price下面。 我怎么做?

添加屏幕截圖,理想情況下將顯示數據: 在此處輸入圖片說明

import chartify

# Generate example data
data = chartify.examples.example_data()

average_price_by_fruit_and_country = (data.groupby(
    ['fruit', 'country'])['total_price'].mean().reset_index())

# Plot the data
(chartify.Chart(
    blank_labels=True,
    x_axis_type='categorical',
    y_axis_type='categorical')
 .plot.heatmap(
    data_frame=average_price_by_fruit_and_country,
    x_column='fruit',
    y_column='country',
    color_column='total_price',
    text_column='total_price',
    text_color='white')
 .axes.set_xaxis_label('Fruit')
 .axes.set_yaxis_label('Country')
 .set_title('Heatmap')
 .set_subtitle("Plot numeric value grouped by two categorical values")
 .show('png'))  

不幸的是,目前還沒有一個簡單的解決方案,但是我將添加一個問題,以便將來更輕松地解決此用例。

您可以從ch.figure訪問Bokeh圖形,然后使用bokeh的文本圖實現所需的內容。 在這里查看示例源代碼。 https://github.com/spotify/chartify/blob/master/chartify/_core/plot.py#L26

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM