def buildChart(sensorid): r = device.getValue(sensorid) if (len(r) > 0): fig3 = figure() fig3.title = 'Weather over Days' fig3.ylabel = 'Temperature' fig3.height = 800 fig3.width = 1200 xVals = ['时间'] yVals = ['温度'] for value in r: xVals.append(value[3][11:19]) yVals.append(value[2]) fig3.plot(xVals, yVals) return None
import os from gpcharts import figure resultDict = {} files = [ f for f in os.listdir('.') if os.path.isfile(f) and f.endswith('.log') ] for f in files: ratio, amount, name = f[:-4].split('-') with open(f, 'r') as file: data = [ eval(fps.strip('\r\n')) for fps in file.readlines() if len(fps.strip('\r\n')) > 1 ] avgFps = sum(data[5:]) / float(len(data) - 5) if (amount not in resultDict): resultDict[amount] = [avgFps] else: resultDict[amount].append(avgFps) print("Amount: {}, Strategy: {}, fps: {}".format(amount, name, avgFps)) amountList = [ '1000', '2000', '4000', '8000', '16000', '24000', '32000', '36000', '48000' ] fig = figure(title="Test Result", ylabel="Avg Fps") xVals = ['Amount'] + amountList yVals = [['ac', 'msemic']] + [resultDict[amount] for amount in amountList] fig.plot(xVals, yVals)
if (amount not in resultDict): resultDict[ratio] = [avgFps] else: resultDict[ratio].append(avgFps) print("Amount: {}, Strategy: {}, fps: {}".format(amount, name, avgFps)) list1 = [sum(resultDict[ratio])/float(len(resultDict[ratio])) for ratio in ratioList] resultDict = {} files = [f for f in os.listdir('.') if os.path.isfile(f) and f.endswith('ac.log')] for f in files: ratio, amount, name = f[:-4].split('-') with open(f, 'r') as file: data = [eval(fps.strip('\r\n')) for fps in file.readlines() if len(fps.strip('\r\n')) > 1] avgFps = sum(data[5:]) / float(len(data) - 5) if (amount not in resultDict): resultDict[ratio] = [avgFps] else: resultDict[ratio].append(avgFps) print("Amount: {}, Strategy: {}, fps: {}".format(amount, name, avgFps)) list2 = [sum(resultDict[ratio])/float(len(resultDict[ratio])) for ratio in ratioList] fig = figure(title="Performance decrease", ylabel="Ratio") xVals = ['Component number'] + ratioList[:-1] yVals = [['Server', 'Browser']] + [[(list1[i] - list1[i + 1]) / float(list1[i]), (list2[i] - list2[i + 1]) / float(list2[i])] for i in range(len(list1) - 1)] # yVals = ['Browser'] + [list1[i] - list1[i + 1] for i in range(len(list1) - 1)] print(yVals) fig.plot(xVals, yVals)
from gpcharts import figure import random # my_fig = figure() my_fig.title = 'Random Histrogram' my_fig.xlabel = 'Random Values' vals = [10, 40, 30, 50, 80, 100] my_fig.hist(vals)
from gpcharts import figure #bar graph fig1 = figure('Percent Alcohol Consumption') fig1.bar(['Percentage','Beer','Wine','Liquor'],['Type',40,50,10]) #histogram fig2 = figure('Distribution',xlabel='value') fig2.hist([1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,3,3,3,3,4,4,5,6,7,8,8,8,8,8,9,9,9,10,11,12,13,13,13,13,14])
# coding:utf-8 ''' Created on 2016/11/1 @author: sunyihuan ''' from gpcharts import figure my_plot = figure(title='Demo') my_plot.plot([1, 2, 10, 15, 12, 23])
from gpcharts import figure # 获取图像对象并设置x,y轴的值 fig3 = figure() xVals = ['Temps','2016-03-20','2016-03-21','2016-03-25','2016-04-01'] yVals = [['Shakuras','Korhal','Aiur'],[10,30,40],[12,28,41],[15,34,38],[8,33,47]] # 添加标题和Y轴标注,画条形图 fig3.title = 'Weather over Days' fig3.ylabel = 'Dates' fig3.bar(xVals, yVals)
from gpcharts import figure #simple line graph, as described in the readme. fig1 = figure() fig1.plot([1, 2, 3, 4, 5], [8, 7, 6, 5, 4]) #another line graph, but with two data types. Also adding title fig2 = figure(title='Two lines', xlabel='Days', ylabel='Count', height=600, width=600) xVals = ['Mon', 'Tues', 'Wed', 'Thurs', 'Fri'] yVals = [[5, 4], [8, 7], [4, 8], [10, 10], [3, 12]] fig2.plot(xVals, yVals) #a graph with dates and times. Title is assigned afterwards, and data is given headers fig3 = figure() fig3.title = 'Weather over Days' fig3.ylabel = 'Temperature' #modify size of graph fig3.height = 800 fig3.width = 1200 # X data can take either of the following formats: "yyyy-mm-dd HH:MM:SS" or "yyyy-mm-dd" (but be consistent) #xVals = ['Dates','2016-03-20 00:00:00','2016-03-21 00:00:00','2016-03-25 00:00:00','2016-04-01 00:00:00'] xVals = ['Dates', '2016-03-20', '2016-03-21', '2016-03-25', '2016-04-01'] yVals = [['Shakuras', 'Korhal', 'Aiur'], [10, 30, 40], [12, 28, 41], [15, 34, 38], [8, 33, 47]] fig3.plot(xVals, yVals)
# # Creating Graphs with Python and GooPyCharts # Source: [datascience+](https://datascienceplus.com/creating-graphs-with-python-and-goopycharts/) # %% [markdown] # ## Install gpcharts library # # ```python # pip install gpcharts # ``` # %% [markdown] # ## Our First Graph # # %% from gpcharts import figure my_plot = figure(title='Demo') my_plot.plot([1, 2, 10, 15, 12, 23]) # %% [markdown] # ## Creating a Bar Graph # %% fig3 = figure() xVals = ['Temps', '2016-03-20', '2016-03-21', '2016-03-25', '2016-04-01'] yVals = [['Shakuras', 'Korhal', 'Aiur'], [10, 30, 40], [12, 28, 41], [15, 34, 38], [8, 33, 47]] fig3.title = 'Weather over Days' fig3.ylabel = 'Dates' fig3.bar(xVals, yVals)
import os from gpcharts import figure resultDict = {} files = [f for f in os.listdir('.') if os.path.isfile(f) and f.endswith('msemic.log')] for f in files: ratio, amount, name = f[:-4].split('-') with open(f, 'r') as file: data = [eval(fps.strip('\r\n')) for fps in file.readlines() if len(fps.strip('\r\n')) > 1] avgFps = sum(data[5:]) / float(len(data) - 5) if (amount not in resultDict): resultDict[amount] = [avgFps] else: resultDict[amount].append(avgFps) print("Amount: {}, Strategy: {}, fps: {}".format(amount, name, avgFps)) amountList = ['1000', '2000', '4000', '8000', '16000', '24000', '32000', '36000', '48000'] ratioList = ['10', '15', '20', '5', '8'] fig = figure(title="Test Result Strategy 4", ylabel="Avg Fps") xVals = ['Amount'] + amountList yVals = [ratioList] + [resultDict[amount] for amount in amountList] print(yVals) fig.plot(xVals, yVals)
#!/usr/bin/env python # -*- coding: utf-8 -*- from gpcharts import figure grafico1 = figure() grafico1.plot([3, 4, 5, 4, 3])
api = tweepy.API(auth) all_tweets = [] all_tweets.extend(api.search("max landis mary sue", rpp=100)) date_dict = dict() for tweet in all_tweets: date = get_date(tweet) if date in date_dict: date_dict[date] += 1 else: date_dict[date] = 1 print(tweet._json["text"]) print(date_dict) dates = [] counts = [] for item in date_dict.items(): dates.append(str(item[0])) counts.append(item[1]) print(len(dates)) print(dates) print(len(counts)) print(counts) fig1 = figure() fig1.plot(dates, counts)