After trying for what felt like an eternity I can not find out how to do the following with the bar chart.
I have data which is sorted like this:
A B C Label
0 1 2 3 ‘0’
1 1.1 2.1 3.1 ‘1’
2 1.2 2.2 3.2 ‘2’
…
N X1 X2 X3 ‘N’
What I would like to do now is to have a bar chart with the Labels ‘0’, ‘1’ etc. and for each label three bars with the corresponding heights to column A, B and C. However, with the given grouping options I could not find a solution to get this to work. Do I miss something?
This may be a new feature to be developed. All the current capability is on display in the User's Guide. In particular, here is an example that shows what can be done with grouping:
After trying for what felt like an eternity I can not find out how to do the following with the bar chart.
I have data which is sorted like this:
A B C Label
0 1 2 3 '0'
1 1.1 2.1 3.1 '1'
2 1.2 2.2 3.2 '2'
..
N X1 X2 X3 'N'
What I would like to do now is to have a bar chart with the Labels '0', '1' etc. and for each label three bars with the corresponding heights to column A, B and C. However, with the given grouping options I could not find a solution to get this to work. Do I miss something?
I’ll see if I can get an example working, but if you have some sample data that would make things easier. At least for the new charts, it expects non-pre-aggregated (not pivot table) data. In your case, you are using the columns A, B, C as a categorical variable. Imagine if you stacked those values into a single column. You would this have a second column called variable that contains ‘A’, ‘B’, and ‘C’.
This operation of de-pivoting is something that pandas melt provides, but there will likely be some special case handling of this kind of data in charts in the future. For now, this is how you could produce what you are trying to build:
from bokeh.charts import Bar
from bokeh.plotting import output_file, show
import pandas as pd
data = {
‘A’: [1, 1.1, 1.2],
‘B’: [2, 2.1, 2.2],
‘C’: [3, 3.1, 3.2],
‘label’: [0, 1, 2]
}
df = pd.DataFrame.from_dict(data)
this combines A, B, C into two columns, ‘variable’ containing A, B, C and values
On Thursday, October 15, 2015 at 4:59:18 AM UTC-5, pf wrote:
After trying for what felt like an eternity I can not find out how to do the following with the bar chart.
I have data which is sorted like this:
A B C Label
0 1 2 3 ‘0’
1 1.1 2.1 3.1 ‘1’
2 1.2 2.2 3.2 ‘2’
…
N X1 X2 X3 ‘N’
What I would like to do now is to have a bar chart with the Labels ‘0’, ‘1’ etc. and for each label three bars with the corresponding heights to column A, B and C. However, with the given grouping options I could not find a solution to get this to work. Do I miss something?