How do I set the order of a grouped bar chart with Chartify?
up vote
3
down vote
favorite
How can users change the order of the grouped bars in the example below?
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')
ch.show('png')
python data-visualization chartify
add a comment |
up vote
3
down vote
favorite
How can users change the order of the grouped bars in the example below?
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')
ch.show('png')
python data-visualization chartify
add a comment |
up vote
3
down vote
favorite
up vote
3
down vote
favorite
How can users change the order of the grouped bars in the example below?
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')
ch.show('png')
python data-visualization chartify
How can users change the order of the grouped bars in the example below?
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')
ch.show('png')
python data-visualization chartify
python data-visualization chartify
edited Nov 9 at 17:17
matt b
109k56249318
109k56249318
asked Nov 9 at 17:16
chalpert
1227
1227
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
3
down vote
The bar plot method has a categorical_order_by
parameter that can be used to change the order. As specified in the documentation, set it equal to values
or labels
to sort by those corresponding dimensions.
For a custom sort, you can pass a list of values to the categorical_order_by
parameter. Since the bar is grouped by two dimensions, the list should contain tuples as in the example below:
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')
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
The bar plot method has a categorical_order_by
parameter that can be used to change the order. As specified in the documentation, set it equal to values
or labels
to sort by those corresponding dimensions.
For a custom sort, you can pass a list of values to the categorical_order_by
parameter. Since the bar is grouped by two dimensions, the list should contain tuples as in the example below:
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')
add a comment |
up vote
3
down vote
The bar plot method has a categorical_order_by
parameter that can be used to change the order. As specified in the documentation, set it equal to values
or labels
to sort by those corresponding dimensions.
For a custom sort, you can pass a list of values to the categorical_order_by
parameter. Since the bar is grouped by two dimensions, the list should contain tuples as in the example below:
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')
add a comment |
up vote
3
down vote
up vote
3
down vote
The bar plot method has a categorical_order_by
parameter that can be used to change the order. As specified in the documentation, set it equal to values
or labels
to sort by those corresponding dimensions.
For a custom sort, you can pass a list of values to the categorical_order_by
parameter. Since the bar is grouped by two dimensions, the list should contain tuples as in the example below:
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')
The bar plot method has a categorical_order_by
parameter that can be used to change the order. As specified in the documentation, set it equal to values
or labels
to sort by those corresponding dimensions.
For a custom sort, you can pass a list of values to the categorical_order_by
parameter. Since the bar is grouped by two dimensions, the list should contain tuples as in the example below:
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')
answered Nov 9 at 17:16
chalpert
1227
1227
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53230465%2fhow-do-i-set-the-order-of-a-grouped-bar-chart-with-chartify%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown