0

Using the example from the documentation, the heatmap is built and displays the total_price in each cell. I want to add data from another column, e.g. 'fruit' to be displayed below the total_price in each cell. How do I do that?

Adding screenshot of where, ideally, the data would be displayed: enter image description here

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'))  
msoderstrom
  • 537
  • 1
  • 7
  • 14

1 Answers1

0

Unfortunately there's not an easy solution at the moment, but I'll add an issue to make it easier to solve for this use case in the future.

You can access the Bokeh figure from ch.figure then use bokeh's text plot to achieve what you're looking for. Take a look at the source code for an example here. https://github.com/spotify/chartify/blob/master/chartify/_core/plot.py#L26

chalpert
  • 252
  • 1
  • 8