[英]How do I set the order of a grouped bar chart with Chartify?
條形圖方法有一個categorical_order_by
參數,可用於更改順序。 如文檔中所指定,將其設置為values
或labels
以按相應的維度排序。
對於自定義排序,您可以將值列表傳遞給categorical_order_by
參數。 由於條形按兩個維度分組,因此列表應包含元組,如下例所示:
from itertools import product
outside_groups = ['Apple', 'Orange', 'Banana', 'Grape']
inner_groups = ['US', 'JP', 'BR', 'CA', 'GB']
sort_order = list(product(outside_groups, inner_groups))
# Plot the data
ch = chartify.Chart(blank_labels=True, x_axis_type='categorical')
ch.plot.bar(
data_frame=quantity_by_fruit_and_country,
categorical_columns=['fruit', 'country'],
numeric_column='quantity',
categorical_order_by=sort_order)
ch.show('png')
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.