Hello Bokeh community,
I’m having an issue with a vertical bar plot with categorical data (x-axis).
What are you trying to do?
I’m trying to plot a list of names in the horizontal axis and a number of days for each name in the vertical axis.
What have you tried that did NOT work as expected?
I either get a blank output with no error message, or I get no plot with the following error message.
I’m also unable to find a good solution by Googling this issue.
ERROR:bokeh.core.validation.check:E-1019 (DUPLICATE_FACTORS): FactorRange must specify a unique list of categorical factors for an axis: duplicate factors found: ‘I’
I don’t see any duplicated category, nor pandas is finding any duplicated value.
Here is my code (I have extra imported packages not being used for the moment).
If anyone can point me in the right direction, much appreciated.
Bokeh version: 2.3.0
"|IMPORT PACKAGES|"
import numpy as np
import pandas as pd
import datetime
from bokeh.plotting import show, figure, output_file, save
from bokeh.io import show, output_notebook, curdoc, export_png
from bokeh.models import ColumnDataSource,LinearAxis, Range1d, NumeralTickFormatter, LabelSet, Label, BoxAnnotation, DatetimeTickFormatter, Text, Span
from bokeh.models.tools import HoverTool
from bokeh.models import Arrow, NormalHead, OpenHead, VeeHead
from bokeh.transform import dodge
from datetime import datetime as dt
"|IMPORT DATA|"
path = r'https://github.com/ncachanosky/research/blob/master/Economic%20Series/'
file = r'Resumen%20Estadistico%20-%20Argentina.xlsx?raw=true'
IO = path + file
sheet = 'DEFICIT FINANCIERO'
data = pd.read_excel(IO, sheet_name = sheet, usecols="AD,AG:AH", nrows=65, engine='openpyxl') # Be patient...
data = data[39:]
"|CHECK DATA|"
data
"|BUILD PLOT|"
cds = ColumnDataSource(data)
#BUILD FIGURE
p = figure(title = 'MINISTROS DE ECONOMÍA',
x_axis_label = '',
y_axis_label = 'Dias',
x_range = 'MINISTRO',
y_range = '',
plot_height = 400,
plot_width = 700)
p.toolbar_location = "above"
p.toolbar.autohide = True
#AXIS 1 (LEFT)
p.vbar(x='MINISTRO', top='DAYS', color='blue', width=0.25, fill_alpha=0.50, legend_label='Días por ministro', muted_alpha=0.2, source=cds)
#LEGEND
p.legend.location = "top_left"
p.legend.orientation = "horizontal"
p.legend.click_policy = "mute"
show(p)
#DUPLICATES?
data.MINISTRO.duplicated()