How to use create_bar_chart method in SeleniumBase

Best Python code snippet using SeleniumBase

[2018.04.04]python-26일차.py

Source:[2018.04.04]python-26일차.py Github

copy

Full Screen

...235'''236[문제192] 한주간 걸음걸이 그래프 그리기237step = []238labels = ['월','화','수','목','금','토','일']239create_bar_chart(step,lables,2)240'''241import matplotlib242import matplotlib.pyplot as plt243from matplotlib import rc #한글설정 1244rc('font', family='AppleGothic') #한글설정 2245plt.rcParams['axes.unicode_minus'] = False #한글설정 3246import pandas as pd247from pandas import Series, DataFrame248def create_bar_chart(step,labels,num):249 data = DataFrame(step,labels)250 if num == 1:251 bar = data.plot(kind = 'bar', grid = True)252 elif num == 2:253 bar = data.plot(kind = 'barh',grid = True)254 elif num == 3:255 data1 = data.sort_values(0,ascending = True)256 bar = data1.plot(kind = 'barh',grid = True)257 return bar258step = [3854,7014,5526,7779,6725,36,11480]259labels = ['월','화','수','목','금','토','일']260create_bar_chart(step,labels,1)261create_bar_chart(step,labels,2)262create_bar_chart(step,labels,3)263data1 = data.sort_values(0, ascending = True)264data1.plot(kind = 'barh', grid = True)265print(plt.style.available)266# 선생님 풀이267import matplotlib.pyplot as plt268from matplotlib import font_manager, rc269#font_name = font_manager.FontProperties(fname="c:/Windows/Fonts/malgun.ttf").get_name()270#rc('font', family=font_name)271rc('font', family='AppleGothic') 272plt.rcParams['axes.unicode_minus'] = False 273def create_bar_chart(data,labels,bar):274 num_bars = len(data)275 positions = range(1, num_bars+1)276 277 if bar == 1: 278 plt.bar(positions, data, align='center') # 세로 막대279 plt.xticks(positions, labels)280 plt.xlabel('요일')281 plt.ylabel('걸음수')282 283 else:284 plt.barh(positions, data, align='center') # 가로 막대285 plt.yticks(positions, labels)286 plt.xlabel('걸음수')287 plt.ylabel('요일')288 289 plt.title('한주간 동안 걸음수') 290 plt.grid()291 plt.show()292 293if __name__=='__main__':294 step = [1090,2000,3000,4000,10000,50000,2000]295 labels = ['월','화','수','목','금','토','일']296 create_bar_chart(step,labels,2)297'''298[문제193] 위 문제를 클래스화 -> 모듈화299'''300class walkGragh:301 302 def create_bar_chart(self,data,labels,bar):303 num_bars = len(data)304 positions = range(1, num_bars+1)305 306 if bar == 1: 307 plt.bar(positions, data, align='center')308 plt.xticks(positions, labels)309 plt.xlabel('요일')310 plt.ylabel('걸음수')311 312 else:313 plt.barh(positions, data, align='center')314 plt.yticks(positions, labels)315 plt.xlabel('걸음수')316 plt.ylabel('요일')317 plt.title('한주간 동안 걸음수') 318 plt.grid()319 plt.show()320w = walkGragh()321w.create_bar_chart(step,labels,2)322if __name__=='__main__':323 step = [1090,2000,3000,4000,10000,50000,2000]324 labels = ['월','화','수','목','금','토','일']325 create_bar_chart(step,labels,2)326 327 328plt.grid()329plt.barh(range(1,6), range(1,6))330'''import 실습'''331import sys332sys.path # /Users/hbk/data/ 존재여부 확인(스파이더 재부팅시 사라짐)333sys.path.append('/Users/hbk/data/')334from walkGragh import walkGragh335w = walkGragh()336w.create_bar_chart(step,labels,2)337from walkGragh import *338w = walkGragh()339w.create_bar_chart(step,labels,2)340# 선생님 풀이341import matplotlib.pylab as plt342from matplotlib import font_manager, rc343font_name = font_manager.FontProperties(fname="c:/Windows/Fonts/malgun.ttf").get_name()344rc('font', family=font_name)345class create_bar_chart:346 def __init__(self,data, labels, bar):347 self.data = data348 self.labels = labels349 self.bar = bar350 351 def create_bar_chart(self):352 353 num_bars = len(self.data)354 355 positions = range(1, num_bars+1)356 if self.bar == 1:357 plt.bar(positions, self.data, align='center')358 plt.xticks(positions, self.labels)359 plt.xlabel('요일')360 plt.ylabel('걸음수')361 362 else:363 plt.barh(positions, self.data, align='center')364 plt.yticks(positions, self.labels)365 plt.xlabel('걸음수')366 plt.ylabel('요일')367 368 369 plt.title('한주간 동안 걸음수') 370 plt.grid()371 plt.show()372 373if __name__=='__main__':374 step = [5000,6000,7500,10000,10000,20000,2000]375 labels = ['월','화','수','목','금','토','일']376 cbc = create_bar_chart(step,labels,2)377 cbc.create_bar_chart()378#!/usr/bin/env python3379# -*- coding: utf-8 -*-...

Full Screen

Full Screen

Lab5E_DiceSimulartions_JakeGadaleta.py

Source:Lab5E_DiceSimulartions_JakeGadaleta.py Github

copy

Full Screen

...6import matplotlib.pyplot as plt7import numpy as np8import random9import seaborn as sns10def create_bar_chart(results, title, x_title, y_title):11 values, frequencies = np.unique(results, return_counts=True)12 sns.set_style('whitegrid')13 axes = sns.barplot(x=values, y=frequencies, palette='bright')14 axes.set_title(title)15 axes.set(xlabel=x_title, ylabel=y_title)16 axes.set_ylim(top=max(frequencies) * 1.1)17 for bar, frequency in zip(axes.patches, frequencies):18 text_x = bar.get_x() + float(bar.get_width() / 2)19 text_y = bar.get_height()20 text = f'{frequency:,}\n{frequency/len(results):.3%}'21 axes.text(text_x, text_y, text, fontsize=11, ha='center', va='bottom')22 plt.show()23def test():24 rolls = [random.randrange(1,7) for i in range(1_000)]25 title = f'Rolling a Six-Sided Die {len(rolls):,} times'26 create_bar_chart(rolls, title, 'Die Value', 'Frequency')27def q1():28 rolls = []29 for i in range(1_000):30 count = 031 for h in range(5):32 if random.randint(1,6) == 1:33 count += 134 rolls.append(count)35 title = "Chance of rolling 1's"36 create_bar_chart(rolls, title, 'Amount of 1\'s', 'Frequency')37def q2():38 trails = []39 for i in range(1_000):40 count = 041 for h in range(25):42 if random.randint(1,6) == 1 and random.randint(1,6) == 1:43 count += 144 trails.append(count)45 title = "Chances of Snake Eyes (24 trials)"46 create_bar_chart(trails, title, 'Snake Eyes amount', 'Frequency')47def q3():48 X = [i for i in range(4,11) if i != 7]49 results = []50 for i in range(1_000):51 for x in X:52 while(True):53 if random.randint(1,6) + random.randint(1,6) == 7:54 results.append(7)55 break56 57 if random.randint(1,6) + random.randint(1,6) == x:58 results.append(x)59 break60 title = "Chances of Winning Craps"61 create_bar_chart(results, title, 'Rolled Amount', 'Frequency')62 63 64if __name__ == "__main__":65 # test()66 q1()67 q2()68 q3()...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run SeleniumBase automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful