-1

We are trying to plot a circle graph from a simple CSV file with two columns using Bokeh for data visualisation and Panda to read the CSV. Following is our CSV file data where we are planning to plot graph Label X-axis and Average Y-axis. However its plotting empty graph.

enter image description here

Following is our python script

from bokeh.plotting import figure, output_file, show
import pandas as pd
from bokeh.models import DatetimeTickFormatter, ColumnDataSource
from bokeh.models.tools import HoverTool

output_file('columndatasource_example.html')
df = pd.read_csv(r"E:/MySpace/pythonTest/aggregate3.csv")
sample= df.sample(5)
source = ColumnDataSource(sample)
#print(df.columns.tolist())
p = figure()
p.circle(x='Label', y='Average',
     source=source,
     size=5, color='green')
p.title.text = 'BPM Load test results'
p.xaxis.axis_label = 'Request name'
p.yaxis.axis_label = 'Response time in miliseconds'
hover = HoverTool()
hover.tooltips=[
('Request Name', '@Label'),
('Response Time', '@Average'),
('Throughput', '@Throughput')    
]
p.add_tools(hover)
show(p)
creativecreatorormaybenot
  • 114,516
  • 58
  • 291
  • 402
Saagar
  • 794
  • 3
  • 20
  • 41

1 Answers1

0

I think you need to restructure your 'label' column as a number in order to achieve what you need with bokeh. I mean if you try exactly the same with a numerical variable instead of df['label'] it will be plotted. In this case of course finally you need to relabel x axis with your desired values. If you provide the csv file you will get more help. But i think something equivalent to this must be done....

labels0 = df['Label'].tolist()
un_labels = list(sorted(set(df['Label'])))
labels_tran = []
for label in labels0:
    labels_tran.append(un_labels.index(label))
df['labels_tran'] = labels_tran

and then plot using df['labels_tran'] as x axis