5.4 Categorical Data
Bar Chart
1. Sorted Bar
# Here is a list of categorical values (or factors)
names = ['Jane', 'David', 'Julian', 'Jonas', 'Macro', 'Barbara']
scores = [8, 9, 8, 5, 7, 6]# sorting the bars means sorting the range factors
sorted_names = sorted(names, key=lambda x: scores[names.index(x)])p = figure(x_range=sorted_names, plot_height=300, title="Sorted Student Scores")
# Categorical values can also be used as coordinates
p.vbar(x=names, top=scores, width=0.75)
# Set some properties to make the plot look better
p.xgrid.grid_line_color = None
p.y_range.start = 0
show(p)
2. Filled Bar

3. Stacked Bar

4. Grouped Bar

Color Mapping

Factor Mapping

5. Stacked and Grouped Bar

6. Mixed Factors

7. Intervals

Scatter Chart

Last updated