changed x-axis range in bar plot

This commit is contained in:
anjali
2021-05-14 12:06:17 +05:30
parent 23bafa7b34
commit 7b596c3f2f
2 changed files with 15 additions and 4 deletions

View File

@@ -83,8 +83,9 @@ class lf_bar_graph():
i = i + 1 i = i + 1
plt.xlabel(self.xaxis_name, fontweight='bold', fontsize=15) plt.xlabel(self.xaxis_name, fontweight='bold', fontsize=15)
plt.ylabel(self.yaxis_name, fontweight='bold', fontsize=15) plt.ylabel(self.yaxis_name, fontweight='bold', fontsize=15)
plt.xticks([r + self.bar_width for r in range(len(self.data_set[0]))], """plt.xticks([r + self.bar_width for r in range(len(self.data_set[0]))],
self.xaxis_categories) self.xaxis_categories)"""
plt.xticks(np.arange(0, len(self.xaxis_categories), step=5))
plt.legend() plt.legend()
fig = plt.gcf() fig = plt.gcf()

View File

@@ -25,6 +25,7 @@ import pandas as pd
import pdfkit import pdfkit
from lf_report import lf_report from lf_report import lf_report
from lf_graph import lf_bar_graph, lf_scatter_graph, lf_stacked_graph, lf_horizontal_stacked_graph from lf_graph import lf_bar_graph, lf_scatter_graph, lf_stacked_graph, lf_horizontal_stacked_graph
import random
# Unit Test # Unit Test
if __name__ == "__main__": if __name__ == "__main__":
@@ -72,10 +73,19 @@ if __name__ == "__main__":
report.set_table_dataframe(dataframe2) report.set_table_dataframe(dataframe2)
report.build_table() report.build_table()
set_xaxis = []
y_set1 = []
y_set2 = []
y_set3 = []
for i in range(0, 30):
set_xaxis.append(i)
y_set1.append(random.randint(1, 50))
y_set2.append(random.randint(1, 50))
y_set3.append(random.randint(1, 50))
# test lf_graph in report # test lf_graph in report
dataset = [[45, 67, 34, 22], [22, 45, 12, 34], [30, 55, 69, 37]] dataset = [y_set1, y_set2, y_set3]
x_axis_values = [1, 2, 3, 4] x_axis_values = set_xaxis
report.set_graph_title("Graph Title") report.set_graph_title("Graph Title")
report.build_graph_title() report.build_graph_title()