def main():
    plt.plotfile('prices.txt',
                 delimiter=' ',
                 cols=(0, 1, 2),
                 names=('t', 'untraded', 'correlated'),
                 marker='o')
    plt.show()
Beispiel #2
0
def plotter(fname, fdelimiter, foutput, fargument, fdir):
    """
    This function parse the data in csv file and then calls different 
    plotting functions"
    """
    try:
        fopen = open(fname,'r')
        csvreader = csv.reader(fopen, delimiter = ",")
        fields = csvreader.next()
    except:
        print "Can not open input csv file",fname
    fopen.close
    data = np.loadtxt(fname, delimiter = fdelimiter, unpack = True, skiprows = 1)
    mpl.plotfile(fname, cols = range(len(fields)/2), delimiter = fdelimiter, subplots = True, newfig = True)
    print "creating a example figure with ", len(fields)/2-1, "subplots"
    allfig = fdir + os.path.sep + "All_fig" + "." + foutput
    mpl.savefig(allfig)
    mpl.clf()
    i = 0;
    while i < len(fields):
        if fargument != i:
            mpl.plot(data[fargument], data[i])
            fieldname=fdir +os.path.sep + fields[fargument] +"_" + fields[i] + "." + foutput
            mpl.xlabel(fields[fargument])
            mpl.ylabel(fields[i])
            mpl.title(fields[fargument] + " vs " + fields[i])
            #Issues with transparent option when png is opted need fine tuning.
            #Check Howto section of matplotlib website
            #mpl.savefig(fieldname, transparent = True)
            mpl.grid(True)
            mpl.savefig(fieldname)
            print "Saving", fieldname
            mpl.clf()    
        i=i+1
Beispiel #3
0
def delta_od_L():
	pyplot.plotfile(dane_dir + 'delta_od_L.txt', delimiter=' ', names=['a', 'b'], cols=(0, 1), marker='.', color=niebieski, ls='')
	pyplot.plot((1, 5), (0.4, 0.4), 'k-')
	pyplot.text(1, 0.5, 'wartosc bulk')
	pyplot.xlabel('L [nm]')
	pyplot.ylabel(u'\u0394 [eV]')

	pyplot.savefig(wykresy_dir + 'delta_od_L.png')
Beispiel #4
0
def Tc_od_L():
	pyplot.plotfile(dane_dir + 'Tc_od_L.txt', delimiter=' ', names=['a', 'b'], cols=(0, 1), marker='.', color=niebieski, ls='')
	pyplot.plot((1, 5), (4, 4), 'k-')
	pyplot.text(1, 4, 'wartosc bulk')
	pyplot.xlabel('L [nm]')
	pyplot.ylabel(r'$T_c$ [K]')

	pyplot.savefig(wykresy_dir + 'Tc_od_L.png')
Beispiel #5
0
def delta_od_T():
	pliki = glob(dane_dir + 'delta_od_T*.txt')

	for nazwa in pliki:
			pyplot.plotfile(nazwa, delimiter=' ', names=['a', 'b'], cols=(0, 1), marker='.', color=niebieski, ls='')
			pyplot.xlabel('T [K]')
			pyplot.ylabel(u'\u03bc [eV]') # czy mev?

			pyplot.savefig(nazwa.replace('dane', 'wykresy').replace('txt', 'png'))
Beispiel #6
0
def queue_length():
    plt.clf()
    plt.plotfile(fname=DATA_ROOT_DIR + "queue_length.data",
                 cols=(0, 1),
                 skiprows=0,
                 delimiter=" ",
                 newfig=False,
                 label="Items")
    plt.title("Queue Length")
    plt.xlabel("Time (milliseconds)")
    plt.ylabel("Queue Length")
    plt.legend()
    plt.grid()
    plt.savefig(PLOT_SAVE_LOCATION + "queue_length")
Beispiel #7
0
def mem(serviceName):
    plt.clf()
    plt.plotfile(fname=DATA_ROOT_DIR + serviceName + "/" + "mem.data",
                 cols=(0, 1),
                 skiprows=0,
                 delimiter=" ",
                 newfig=False,
                 label="Memory")
    plt.title("Memory")
    plt.xlabel("Time (seconds)")
    plt.ylabel("Memory utilization (%)")
    plt.legend()
    plt.grid()
    plt.savefig(PLOT_SAVE_LOCATION + serviceName + "/" + "mem")
Beispiel #8
0
def cpu(serviceName):
    plt.clf()
    plt.plotfile(fname=DATA_ROOT_DIR + serviceName + "/" + "cpu0.data",
                 cols=(0, 1),
                 skiprows=0,
                 delimiter=" ",
                 newfig=False,
                 label="CPU 0")
    plt.plotfile(fname=DATA_ROOT_DIR + serviceName + "/" + "cpu1.data",
                 cols=(0, 1),
                 skiprows=0,
                 delimiter=" ",
                 newfig=False,
                 label="CPU 1")
    plt.plotfile(fname=DATA_ROOT_DIR + serviceName + "/" + "cpu2.data",
                 cols=(0, 1),
                 skiprows=0,
                 delimiter=" ",
                 newfig=False,
                 label="CPU 2")
    plt.plotfile(fname=DATA_ROOT_DIR + serviceName + "/" + "cpu3.data",
                 cols=(0, 1),
                 skiprows=0,
                 delimiter=" ",
                 newfig=False,
                 label="CPU 3")
    plt.title("CPU")
    plt.xlabel("Time (seconds)")
    plt.ylabel("CPU utilization (%)")
    plt.legend()
    plt.grid()
    plt.savefig(PLOT_SAVE_LOCATION + serviceName + "/" + "cpu")
Beispiel #9
0
def point_in_time_distribution():
    plt.clf()
    plt.plotfile(fname=DATA_ROOT_DIR + "rt_pit.data",
                 cols=(0, 1),
                 skiprows=0,
                 delimiter=" ",
                 newfig=False,
                 label="PIT Response Time")
    plt.title("Point in Time Distribution")
    plt.xlabel("Time (milliseconds)")
    plt.ylabel("PIT Response Time (milliseconds)")
    plt.legend()
    plt.grid()
    plt.savefig(PLOT_SAVE_LOCATION + "point_in_time_distribution")
Beispiel #10
0
def requests_per_sec():
    plt.clf()
    plt.plotfile(fname=DATA_ROOT_DIR + "requests_per_sec.data",
                 cols=(0, 1),
                 skiprows=0,
                 delimiter=" ",
                 newfig=False,
                 label="Requests")
    plt.title("Requests per Second")
    plt.xlabel("Time (seconds)")
    plt.ylabel("# Requests")
    plt.legend()
    plt.grid()
    plt.savefig(PLOT_SAVE_LOCATION + "reqs_per_sec")
 def stockstats_figures(self):
     for line in stockstats_files:
         print line
         try:
             faname = cbook.get_sample_data(line, asfileobj=False)
             faname = faname[71:]
             plt.style.use("Solarize_Light2")
             plt.plotfile(faname, ('date', '30', '70', 'rsi_12'),
                          subplots=False)
             plt.savefig(line + '_rsi.png')
             # plt.plotfile(faname, ('date','macdh','macd','macds'), plotfuncs={'macdh': 'bar'}, subplots=False)
             # plt.savefig(line+'_macd.png')
         except:
             pass
Beispiel #12
0
def plot_by_cpu(serviceName, i):
    plt.clf()
    plt.plotfile(fname=DATA_ROOT_DIR + serviceName + "/" + "cpu" + str(i) +
                 ".data",
                 cols=(0, 1),
                 skiprows=0,
                 delimiter=" ",
                 newfig=False,
                 label=str("CPU " + str(i)))
    plt.title("CPU " + str(i) + " Plot")
    plt.xlabel("Time (seconds)")
    plt.ylabel("CPU utilization (%)")
    plt.legend()
    plt.grid()
    plt.savefig(PLOT_SAVE_LOCATION + serviceName + "/" + "cpu-" + str(i))
Beispiel #13
0
def response_time_distribution():
    plt.clf()
    plt.plotfile(fname=DATA_ROOT_DIR + "rt_dist.data",
                 cols=(0, 1),
                 skiprows=0,
                 delimiter=" ",
                 newfig=False,
                 label="# Requests")
    plt.title("Response Time Distribution")
    plt.xlabel("Response Time (milliseconds)")
    plt.ylabel("# Requests")
    plt.xlim((-30, 3000))
    plt.yscale(value='log')
    plt.legend()
    plt.grid()
    plt.savefig(PLOT_SAVE_LOCATION + "response_time_distribution")
Beispiel #14
0
def plotgraph(filepath, imagefolder):
    p1 = filepath.split('/')
    p2 = p1[-1]
    iname = p2.strip('.txt')
    plt.plotfile(filepath,
                 delimiter=',',
                 cols=(0, 1),
                 names=('YYYY-MM', 'Total Hits'),
                 marker='o')
    new_graph_name = iname + str(time.time()) + ".png"
    for filename in os.listdir(imagefolder):
        if filename.startswith(iname):  # not to remove other images
            os.remove(imagefolder + filename)
    plt.savefig(imagefolder + new_graph_name)
    imagename = imagefolder + new_graph_name
    return imagename
    def plot(self, fromCsvFile, col1, col1Name, col2, col2Name):
        """ Plots out the csvFile. Takes 2 columns and their names. """
        plt.plotfile(fromCsvFile, delimiter=self.delimiter, cols=(col1, col2), skiprows=1,
                     names=(col1Name, col2Name), linestyle='None', marker='.')

        y = []
        x = []

        with open(fromCsvFile, 'rb') as csvFile:
            dat = csv.reader(csvFile, delimiter=self.delimiter)
            for row in dat:
                y.append(int(row[col2]))
                x.append(int(row[col1]))

        m, b = np.polyfit(x, y, 1)
        plt.plot(x, np.array(x) * m + b, color='red')
Beispiel #16
0
    def OnPlot(self, event):
        cursor= self.conn.execute("SELECT FILE_NAME FROM MOLECULE where MOL_NUMBER==?", (self.plot_list[0],))
        files = cursor.fetchall()
        #print files[0][0]
        tf = open(files[0][0],'r+')
	d = tf.readlines()
	tf.seek(0)
	for line in d:
    	     s=re.search(r'[a-zA-Z]',line)
             if s:
       	         tf.write('#'+line)
    	     else:
                 tf.write(line)
        tf.truncate()
        tf.close()
        plt.plotfile(str(files[0][0]), delimiter=' ',comments = '#', cols=(0, 1), 
                   names=('Raman Shift ($\mathregular{Cm^{-1}}$)', 'Intensity (arb. units)'), ) 
        plt.title('Raman Spectra of {}'.format(files[0][0]))
        plt.show()
def main(argv):
   inputfile = ''
   outputfile = ''
   try:
      opts, args = getopt.getopt(argv,"hi:o:",["ifile=","ofile="])
   except getopt.GetoptError:
      print ('test.py -i <inputfile> -o <outputfile>')
      sys.exit(2)
   for opt, arg in opts:
      if opt == '-h':
         print ('test.py -i <inputfile> -o <outputfile>')
         sys.exit()
      elif opt in ("-i", "--ifile"):
         inputfile = arg
      elif opt in ("-o", "--ofile"):
         outputfile = arg
   plt.plotfile('reinas-tiempo.txt', delimiter=' ', cols=(0, 1),
   names=('reinas', 'tiempo'), marker='o')
   plt.savefig(outputfile)
Beispiel #18
0
def plot():
	#reading data from two recent files
	list_of_files = glob.glob('/Users/anuja/Desktop/testing/signals/*') 
	recent_data = sorted(list_of_files, key=os.path.getmtime)

	#signal 1
	try:
	#reading data from file and ploting
		plt.plotfile(recent_data[-1],('time','dis','vel','acc'), delimiter=' ', marker='None',newfig=True, subplots=True)
	except IOError:
		print("Error reading file.")
		sys.exit(1)

	actual_time = strftime("%Y-%m-%d %H-%M-%S", gmtime())

	save_path = '/Users/anuja/Desktop/testing/plots'
	file_name = os.path.join(save_path, 'signal_1' + str(actual_time)+".png")

	pl.savefig(file_name, bbox_inches='tight')
	plt.show()
Beispiel #19
0
def disk(serviceName):
    plt.clf()
    plt.plotfile(fname=DATA_ROOT_DIR + serviceName + "/" + "diskread.data",
                 cols=(0, 1),
                 skiprows=0,
                 delimiter=" ",
                 newfig=False,
                 label="Read")
    plt.plotfile(fname=DATA_ROOT_DIR + serviceName + "/" + "diskwrite.data",
                 cols=(0, 1),
                 skiprows=0,
                 delimiter=" ",
                 newfig=False,
                 label="Write")
    plt.title("Disk")
    plt.xlabel("Time (seconds)")
    plt.ylabel("Disk I/O (in kB)")
    plt.legend()
    plt.grid()
    plt.savefig(PLOT_SAVE_LOCATION + serviceName + "/" + "disk")
Beispiel #20
0
def main(argv):
    inputfile = ''
    outputfile = ''
    try:
        opts, args = getopt.getopt(argv, "hi:o:", ["ifile=", "ofile="])
    except getopt.GetoptError:
        print('test.py -i <inputfile> -o <outputfile>')
        sys.exit(2)
    for opt, arg in opts:
        if opt == '-h':
            print('test.py -i <inputfile> -o <outputfile>')
            sys.exit()
        elif opt in ("-i", "--ifile"):
            inputfile = arg
        elif opt in ("-o", "--ofile"):
            outputfile = arg
    plt.plotfile('reinas-tiempo.txt',
                 delimiter=' ',
                 cols=(0, 1),
                 names=('reinas', 'tiempo'),
                 marker='o')
    plt.savefig(outputfile)
Beispiel #21
0
def main():
    """ dispatcher """

    xdata = []
    ydata = []
    with open (incvs, 'rb') as fin, open (tcsv, 'wb') as touf:
        print >>touf, "%s,%s,%s,%s" % ("dt", "cont", "cpu", "virtmem")
        for row in fin:
            r = row.split()
            print >>touf, "%s,%s,%s,%s" % (r[0] + ' ' + r[1], r[2][4:], r[3], r[4])
            print "%s,%s,%s,%s" % (r[0] + ' ' + r[1], r[2][4:], r[3], r[4])

    plt.plotfile (tcsv, cols = ("cont", "cpu"))
    plt.xlabel(u"число контейнеров")
#    plt.xlabel("number of containers")
    plt.ylabel(u"использование ЦПУ")
#    plt.ylabel("CPU usage")
    plt.ylim(0, 100)
    plt.grid()
    plt.xticks(rotation=45)
#    plt.xticks(rotation='vertical')
    plt.savefig ("docker-cpu.png", bbox_inches='tight')

    plt.plotfile (tcsv, cols = ("cont", "virtmem"))
#    plt.xlabel("number of containers")
    plt.xlabel(u"число контейнеров")
#    plt.ylabel("virtual memory")
    plt.ylabel(u"виртуальная память")
    plt.ylim(0, 100)
    plt.grid()
    plt.xticks(rotation=45)
#    plt.xticks(rotation='vertical')
    plt.savefig ("docker-virtmem.png", bbox_inches='tight')

    #~ plt.show()
    return 0
Beispiel #22
0
import glob
import os
import numpy as np
import array
import datetime
import time
import pandas as pd
import sklearn.cluster
import numpy as np
import matplotlib.pyplot as plt
import Node
import re
import csv

import matplotlib.cbook as cbook

file = os.getcwd() + 'topics.hist.csv'
fname = cbook.get_sample_data(file)

plt.plotfile(fname, cols=(0, 1), delimiter=',')




Beispiel #23
0
    def updatecanvas(self):
        incsv='test.csv'
        utcsv='create.csv'
##################################################
        print "starting"

        rownr = 5
        head = False
        headlist = False
        columns = False
        with open('test.csv') as inf:
            for line in inf:
                parts = line.split(",")
                partlen = len(parts)
                #print "partlen: ",partlen, " parts: ", parts
                if not headlist:
                    headlist = parts
                elif not columns:
                    columns = parts

        print "headlist: ", headlist
        print "columns : ", partlen
        new_cvs_file_list = []
        #new_cvs_file_list.append("empty")
        colum_with_values = []
        colum_with_no_values = []

        replace_append_data = ''

        for colum in range(partlen):
            print "COLUM NAME: ", headlist[colum]
            check_empty_data = True
            countlines = 0
            with open(incsv) as inf:
                for line in inf:
                    parts = line.split(",") # split line into parts
                    if len(parts) > 1:   # if at least 2 parts/columns
                        #print "NEW_CVS_FILE_LIST: ", new_cvs_file_list, " fethcning value: ", colum
                        if not head:
                            head = parts[colum]
                        else:
                            print parts[colum]   # print column 2
                    if parts[colum] == headlist[colum]:
                        print "header TOP"
                    elif parts[colum] != '"0"':
                        print "parts have value: ", parts[colum]
                        check_empty_data = False
                    countlines +=1
            if not check_empty_data:
                print "DATA in: ", headlist[colum]
                colum_with_values.append(headlist[colum])
            else:
                print "EMPTY IN: ", headlist[colum]
                colum_with_no_values.append(headlist[colum])

        print "These columes have legit valuse: ", colum_with_values
        for colum in range(partlen):
            print "COLUM NAME: ", headlist[colum]
            check_empty_data = True
            countlines = 0
            with open(incsv) as inf:
                for line in inf:
                    parts = line.split(",") # split line into parts
                    if len(parts) > 1:   # if at least 2 parts/columns
                        if colum == 0:
                            new_cvs_file_list.append(parts[colum])
                            #print "NEW_CVS_FILE_LIST: ", new_cvs_file_list, " fethcning value: ", colum
                        #elif headlist[colum] != parts[colum] and headlist[colum] in colum_with_values:
                        elif headlist[colum] in colum_with_values:
                            if colum != 0:
                                # reading new file structure
                                read_copy_of_row = new_cvs_file_list[countlines]
                                new_cvs_file_list[countlines] = read_copy_of_row + ',' + parts[colum]
                                countlines +=1

                            print headlist[colum]," -> ", parts[colum]


        myfile = open(utcsv,'w')
        for row in new_cvs_file_list:
            print row
            myfile.write(row + '\n')

        myfile.close()
        fname = open(utcsv)
        plt.plotfile(fname, (colum_with_values), subplots=False)
        plt.xlabel(r'$date$')
        plt.ylabel(r'$levels$')
        # #plt.show()
        plt.savefig('data/test.png')
        #
        # print "column with missing valuse: ", colum_with_no_values
##################################################
        self.image.source  = "data/test.png"
Beispiel #24
0
def simple_plot(csv_file, columns, headers):
    plt.clf()
    plt.close()
    plt.plotfile(csv_file, columns, names=headers, newfig=True)
    plt.show()
# When working with dates, additionally call
# `pandas.plotting.register_matplotlib_converters` and use the ``parse_dates``
# argument of `pandas.read_csv`::

pd.plotting.register_matplotlib_converters()

with cbook.get_sample_data('msft.csv') as file:
    msft = pd.read_csv(file, parse_dates=['Date'])


###############################################################################
# Use indices
# -----------

# Deprecated:
plt.plotfile(fname, (0, 5, 6))

# Use instead:
msft.plot(0, [5, 6], subplots=True)

###############################################################################
# Use names
# ---------

# Deprecated:
plt.plotfile(fname, ('date', 'volume', 'adj_close'))

# Use instead:
msft.plot("Date", ["Volume", "Adj. Close*"], subplots=True)

###############################################################################
Beispiel #26
0
import numpy as np
import matplotlib.pyplot as plt
import sys
import os

args = sys.argv[1:]

filenames = [f for f in os.listdir('./widths') if f.endswith(".out")]

for filename in filenames:
    try:
        plt.plotfile('./widths/' + filename,
                     delimiter=' ',
                     cols=(0, 1),
                     names=('y from resonance', 'winding number'),
                     marker='o')
        """plt.show()"""
        plt.savefig("./plots/" + filename.replace(".out", ".png"))
        print("Making plots for", filename)
        plt.close()
    except ValueError:
        print("There was nothing in", filename)
Beispiel #27
0
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
import numpy as np

#workUnits=pd.read_csv('C:\Users\lokesh_chandra\PycharmProjects\Streaming\work_units.csv',header=None,names=['date_trunc','count'],index_col=0)
# #print(workUnits)
# #plot1=workUnits[1:3]
#
# print (workUnits)
#workUnits.set_index(workUnits['date_trunc'],inplace=True)
#workUnits.plot()
#plt.show()
#plt.plot(workUnits)

# read_csv = pd.read_csv('C:/Users/lokesh_chandra/PycharmProjects/Streaming/work_units.csv')
# read_csv['date_trunc'] = pd.to_datetime(read_csv['date_trunc'])
# #print(read_csv['count'])
# plt.plot(read_csv["date_trunc"], read_csv["count"])
#
# plt.show()
# #plt.clf()
#workUnits=pd.read_csv('C:\Users\lokesh_chandra\PycharmProjects\Streaming\work_units.csv',parse_dates=[1],infer_datetime_format=True,keep_date_col=True)
#workUnits= pd.DatetimeIndex(workUnits['Date'],format='%Y-%m-%d')

#plt.plot_date(x='Date', y='count', fmt="r-")
plt.plotfile('work_units.csv', (0, 1))
plt.title("Workunits completed in a day")
plt.xlabel("Dates")
plt.ylabel("No. of Workunits")
#plt.grid(True)
plt.show()
                    if colum != 0:
                        # reading new file structure
                        read_copy_of_row = new_cvs_file_list[countlines]
                        new_cvs_file_list[countlines] = read_copy_of_row + ',' + parts[colum]
                        countlines +=1

                    print headlist[colum]," -> ", parts[colum]


myfile = open(utcsv,'w')

for row in new_cvs_file_list:
    print row
    myfile.write(row + '\n')

myfile.close()

fname = open(utcsv)
plt.plotfile(fname, (colum_with_values), subplots=False)
plt.xlabel(r'$date$')
plt.ylabel(r'$levels$')



plt.show()
plt.savefig('data_graph.png')

print "column with missing valuse: ", colum_with_no_values


plotdata()
Beispiel #29
0
import sys 
import matplotlib.pyplot as plt


for argument in range(1,len(sys.argv),2):
	plt.plotfile(sys.argv[argument],(0,int(sys.argv[argument+1])))

plt.show()


Beispiel #30
0
import sys
from matplotlib.ticker import FuncFormatter
import matplotlib.pyplot as plt
import numpy as np

import matplotlib.cbook as cbook

filename = sys.argv[1]

data = cbook.get_sample_data(filename, asfileobj=False)
plt.plotfile(data, ('time', 'rss', 'storage_used', 'je_allocated', 'je_resident', 'reclaim_pending', 'queue_size'), subplots=False, delimiter=',')

plt.xlabel(r'seconds')
plt.ylabel(r'memory_used')
yaxis = plt.twiny()
yaxis.yaxis.set_major_formatter(FuncFormatter(lambda y,_: '%1.f' % (y/(1024*1024))))

plt.plotfile(data, ('time', 'mainrecord', 'docrecords'), subplots=False, delimiter=',')
plt.show()


Beispiel #31
0
#!/usr/bin/env python

#import numpy as np
import matplotlib.pyplot as plot

plot.plotfile('sw_open.txt',delimiter=' ', cols=(0, 1), names=('col1', 'col2'), marker='o')
plot.show()
import matplotlib.pyplot as plt
import numpy as np

import matplotlib.cbook as cbook

fname = cbook.get_sample_data(
    '/home/akshaymshet/processed_data/events/bishop.csv', asfileobj=False)

# test 1; use ints
plt.plotfile(fname, (10, 12))

# test 2; use names
plt.plotfile(fname, ('weekday', 'pixel'))

# test 3; use semilogy for volume
#plt.plotfile(fname, ('weekday', 'pixel'),plotfuncs={'volume': 'semilogy'})

# test 4; use semilogy for volume
#plt.plotfile(fname, (10, 12), plotfuncs={5: 'semilogy'})

# test 5; single subplot
#plt.plotfile(fname, ('weekday', 'pixel'), subplots=False)

# test 6; labeling, if no names in csv-file
#plt.plotfile(fname2, cols=(0, 1, 2), delimiter=' ', names=['$x$', '$f(x)=x^2$', '$f(x)=x^3$'])

# test 7; more than one file per figure--illustrated here with a single file
#plt.plotfile(fname2, cols=(0, 1), delimiter=' ')
#plt.plotfile(fname2, cols=(0, 2), newfig=False,delimiter=' ')  # use current figure
#plt.xlabel(r'$x$')
#plt.ylabel(r'$f(x) = x^2, x^3$')
Beispiel #33
0
    print analysis
    if (x - 1) % 50000 == 0:
        chainsSSR = np.load(os.getcwd() + '/data/chainsSSRDual_' + str(x) + y +
                            '.npy')
    else:
        chainsSSR = np.load(os.getcwd() + '/data/chainsSSRDual_' +
                            str(x - x % 50000 + 1) + y + '.npy')

    fig = plt.figure()
    ax = fig.add_subplot(111, projection='3d')
    for chain in chains:
        chain = chain[chain[:, 0] >= 0]
        ax.plot(chain[:, 0], chain[:, 1], chain[:, 2])
    plt.savefig(os.getcwd() + '/data/3dplot_' + str(x) + y + ".pdf")

    plt.plotfile(os.getcwd() + '/data/energyDual_' + str(x) + y)
    plt.savefig(os.getcwd() + '/data/energyDual_' + str(x) + y + ".pdf")
    plt.close()

    binomial = []
    for k in xrange(0, 6):
        m = 5
        binomial += [an.choose(m, k) * (0.5**k) * (0.5**(m - k))]

    saved = np.save(os.getcwd() + '/data/savedSSRDual_' + str(x) + y, analysis)

    spectra = open(os.getcwd() + '/data/savedSpectraDual_' + str(x), 'a')
    spectra.write(str(analysis) + "\n")
    spectra.flush()
    spectra.close()
Beispiel #34
0
    for saw in chains:
    #    if saw[len(saw)-1, 0] == -1 or saw[len(saw)-1, 1] == -1:
    #       saw[::2, 0] += 0.5
    #       plt.plot(saw[0:int(len(saw)*.333)+1, 0], saw[0:int(len(saw)*.333)+1, 1])
    #    else:
            saw = saw[saw[:,0] >= 0]
            #saw[::2, 0] += 0.5
            plt.plot(saw[:, 0], saw[:, 1])
    plt.show()
    profile = lattice.sum(axis=0)
    plt.plot(profile[0:400])
    plt.show()
    plt.scatter(points[:,0],points[:,1])
   # plt.show()

    plt.plotfile('EnergiesHex42b')
    plt.show()

    binomial = []
    for k in xrange(0,4):
        n =3
        binomial += [choose(n,k)*(0.6**k)*(0.4**(n-k))]

    spectra = open('Saved_spectraHex40b','a')
    spectra.write(str(analysis)+"\n")

    ssr = SSR(analysis, binomial)
    SSR = open('Saved_SSRhex40b', 'a')
    SSR.write('+1\t' + str(ssr) + '\t' + '250000\n')
    SSR.close()
Beispiel #35
0
import sys
import matplotlib.pyplot as plt

for argument in range(1, len(sys.argv), 2):
    print(0,
          int(sys.argv[argument + 1]) * 2 + 1,
          int(sys.argv[argument + 1]) * 2 + 2)
    plt.plotfile(sys.argv[argument], (0, int(sys.argv[argument + 1]) * 2 + 1,
                                      int(sys.argv[argument + 1]) * 2 + 2))

plt.show()
import matplotlib.pyplot as plt 

plt.plotfile('datos1.csv', cols=(0,2), delimiter=',')
plt.plotfile('datos1.csv', cols=(0,3), delimiter=',', newfig=False)

plt.xlabel('x')
plt.ylabel('Derivada')
plt.savefig('datos1')
plt.show()


import matplotlib.pyplot as plt
import numpy as np

import matplotlib.cbook as cbook

fname = cbook.get_sample_data('/home/akshaymshet/processed_data/events/bishop.csv', asfileobj=False)

# test 1; use ints
plt.plotfile(fname, (10, 12))

# test 2; use names
plt.plotfile(fname, ('weekday', 'pixel'))

# test 3; use semilogy for volume
#plt.plotfile(fname, ('weekday', 'pixel'),plotfuncs={'volume': 'semilogy'})

# test 4; use semilogy for volume
#plt.plotfile(fname, (10, 12), plotfuncs={5: 'semilogy'})

# test 5; single subplot
#plt.plotfile(fname, ('weekday', 'pixel'), subplots=False)

# test 6; labeling, if no names in csv-file
#plt.plotfile(fname2, cols=(0, 1, 2), delimiter=' ', names=['$x$', '$f(x)=x^2$', '$f(x)=x^3$'])

# test 7; more than one file per figure--illustrated here with a single file
#plt.plotfile(fname2, cols=(0, 1), delimiter=' ')
#plt.plotfile(fname2, cols=(0, 2), newfig=False,delimiter=' ')  # use current figure
#plt.xlabel(r'$x$')
#plt.ylabel(r'$f(x) = x^2, x^3$')
Beispiel #38
0
parser.add_argument('-o',
                    dest='output',
                    type=str,
                    default='',
                    help='output file name')

args = parser.parse_args()

names = tuple(args.columns.split(','))
cols = tuple([int(x) for x in names])
for infile in args.datfile:
    label = "%s%s" % (os.path.basename(infile), cols)
    plt.plotfile(infile,
                 cols=cols,
                 names=names,
                 delimiter=args.delimiter,
                 marker=args.marker,
                 linestyle=args.linestyle,
                 label=label)
if args.xlabel:
    plt.xlabel(args.xlabel)
if args.ylabel:
    plt.ylabel(args.ylabel)
if args.xlog:
    plt.xscale('log')
if args.ylog:
    plt.yscale('log')
if args.legend:
    plt.legend(loc='best')
if args.output:
    plt.savefig(args.output)
Beispiel #39
0
parser.add_argument('--delm', dest='delimiter', type=str, default=' ', help='delimiter')
parser.add_argument('-l', '--legend', dest='legend', action='store_true', help='legend')
parser.add_argument('-m', '--marker', dest='marker', type=str, default='o', help='delimiter')
parser.add_argument('--ls', dest='linestyle', type=str, default='-', help='linestyle')
parser.add_argument('-c', '--columns', dest='columns', type=str, default='0,1', help='column index')
parser.add_argument('-f', '--format', dest='format', type=str, default='', help='output file format')
parser.add_argument('-o', dest='output', type=str, default='', help='output file name')

args = parser.parse_args()

names = tuple(args.columns.split(','))
cols = tuple([int(x) for x in names])
for infile in args.datfile:
    label = "%s%s" % (os.path.basename(infile), cols)
    plt.plotfile(infile,
            cols=cols, names=names,
            delimiter=args.delimiter, marker=args.marker, linestyle=args.linestyle,
            label=label)
if args.xlabel:
    plt.xlabel(args.xlabel)
if args.ylabel:
    plt.ylabel(args.ylabel)
if args.xlog:
    plt.xscale('log')
if args.ylog:
    plt.yscale('log')
if args.legend:
    plt.legend(loc='best')
if args.output:
    plt.savefig(args.output)
    print("file %s was written" % args.output)
else:
Beispiel #40
0
#!/usr/bin/python
import numpy as np
import matplotlib.pyplot as plt

plt.rcParams.update({'font.size': 14, 'font.family': 'sans'})

fig, ax = plt.subplots()

ax = plt.plotfile('./time.dat', cols=(0, 1), delimiter=' ')

#plt.plotfile(*np.loadtxt('time.dat', unpack=True))

#ax.plot(t, s, lw=2, color="red", ls = "-", alpha = 0.5,
#        marker = "o", markersize = 8.0,
#        )
#        #animated = True, aa = True, clip_on = True)

fig.savefig('fig.pdf')
#!/usr/bin/env python
import os
import sys
import matplotlib.pyplot as plt

print "Enter the number of grid points"
n=raw_input()
print "Enter the name of the Figure"
Fig=raw_input()
#plt.plotfile('Solar_VV.dat', cols=(1,2), label='Mercury', delimiter=' ')
#plt.plotfile('Solar_VV.dat', cols=(5,6),label='Venus', newfig=False, delimiter=' ')
#plt.plotfile('Solar_VV.dat', cols=(9,10),label='Earth', newfig=False, delimiter=' ')
#plt.plotfile('Solar_VV.dat', cols=(13,14),label='Mars', newfig=False, delimiter=' ')
plt.plotfile('Solar_VV.dat', cols=(17,18),label='Jupiter', newfig=False, delimiter=' ')
plt.plotfile('Solar_VV.dat', cols=(21,22),label='Saturn', newfig=False, delimiter=' ')
plt.plotfile('Solar_VV.dat', cols=(25,26),label='Uranus', newfig=False, delimiter=' ')
plt.plotfile('Solar_VV.dat', cols=(29,30),label='Neptune', newfig=False, delimiter=' ')
plt.plotfile('Solar_VV.dat', cols=(33,34),label='Pluto', newfig=False, delimiter=' ')
plt.title('y vs x  '+n)
plt.xlabel('x(au)')
plt.ylabel('y(au)')
plt.legend()
plt.grid()
plt.savefig(Fig)
plt.show()
Beispiel #42
0
import matplotlib.pyplot as plt
import numpy as np

import matplotlib.cbook as cbook

fname = cbook.get_sample_data('msft.csv', asfileobj=False)
fname2 = cbook.get_sample_data('data_x_x2_x3.csv', asfileobj=False)

# test 1; use ints
plt.plotfile(fname, (0, 5, 6))

# test 2; use names
plt.plotfile(fname, ('date', 'volume', 'adj_close'))

# test 3; use semilogy for volume
plt.plotfile(fname, ('date', 'volume', 'adj_close'),
             plotfuncs={'volume': 'semilogy'})

# test 4; use semilogy for volume
plt.plotfile(fname, (0, 5, 6), plotfuncs={5: 'semilogy'})

# test 5; single subplot
plt.plotfile(fname, ('date', 'open', 'high', 'low', 'close'), subplots=False)

# test 6; labeling, if no names in csv-file
plt.plotfile(fname2, cols=(0, 1, 2), delimiter=' ',
             names=['$x$', '$f(x)=x^2$', '$f(x)=x^3$'])

# test 7; more than one file per figure--illustrated here with a single file
plt.plotfile(fname2, cols=(0, 1), delimiter=' ')
plt.plotfile(fname2, cols=(0, 2), newfig=False,
Beispiel #43
0
import matplotlib.pyplot as plt
import numpy as np
import csv
import sys

file = 'Data2.csv'
fname = open(file, 'rt')
plt.plotfile(fname, ('angle', 'raw', 'median', 'harmonic', 'arithmetic'),
             subplots=False)
plt.show()
Beispiel #44
0
import matplotlib.pyplot as plt
import numpy as np

from csv import reader

data = np.genfromtxt('sample_data.csv',delimiter=',',names=['t','a','b','c','d'])



# test 1; use ints
plt.plot(data['t'])
plt.show()
'''
# test 2; use names
plt.plotfile(fname, ('date', 'volume', 'adj_close'))

# test 3; use semilogy for volume
plt.plotfile(fname, ('date', 'volume', 'adj_close'),
             plotfuncs={'volume': 'semilogy'})

# test 4; use semilogy for volume
plt.plotfile(fname, (0, 5, 6), plotfuncs={5: 'semilogy'})

# test 5; single subplot
plt.plotfile(fname, ('date', 'open', 'high', 'low', 'close'), subplots=False)

# test 6; labeling, if no names in csv-file
plt.plotfile(fname2, cols=(0, 1, 2), delimiter=' ',
             names=['$x$', '$f(x)=x^2$', '$f(x)=x^3$'])

# test 7; more than one file per figure--illustrated here with a single file
Beispiel #45
0
def plotfile(*args, **kwargs):
    r"""starkplot wrapper for plotfile"""
    return _pyplot.plotfile(*args, **kwargs)
Beispiel #46
0
def testPlot():
    plt.plotfile(fname, ('date', 'volume', 'adj_close'))
    plt.plot([1, 0, 0, 4])
    plt.ylabel('some numbers')
    plt.show()    
import matplotlib.pyplot as plt 

plt.plotfile('600_1%_532e_Mo F1_80sec.asc', delimiter=' ', cols=(0, 1), 
             names=('col1', 'col2'), )
plt.show()
#!/usr/bin/env python
import os
import sys
import matplotlib.pyplot as plt

with open(sys.argv[1],'r') as File, open(sys.argv[2],'r') as File2:
     print "Enter the number of grid points"
     n=raw_input()
     print "Enter the name of the Figure"
     Fig=raw_input()
     plt.plotfile(File, cols=(0,3), label='RK4', delimiter=' ')
     plt.plotfile(File2, cols=(0,3),label='Verlet', newfig=False, delimiter=' ')
     plt.title('Energy vs time  '+n)
     plt.xlabel('time(yr)')
     plt.ylabel(r'$ E_{tot} (au/yr)^2$')
     plt.legend()
     plt.grid()
     plt.savefig(Fig)
     plt.show()
Beispiel #49
0
import matplotlib.pyplot as plt
import numpy as np

debug_file = open("../debug.csv","r")
#headers = debug_file.readline()
#labels = headers.split()
#print labels
#for label in labels:
    

plt.plotfile(debug_file, (0, 1, 2),subplots=False,newfig=False)

plt.show()
Beispiel #50
0
# add some text for labels, title and axes ticks
ax.set_ylabel('---------------------------Scores----------------------------')
ax.set_title('Scores by group and gender')
ax.set_xticks(ind + width)
ax.set_yticklabels(('Ahh', '--G1--', 'G2', 'G3', 'G4', 'G5', 'G5',
                    'G5', 'G5'), rotation=90)
ax.legend((rects1[0], rects2[0]), ('Men', 'Women'))


def autolabel(rects):
    # attach some text labels
    for rect in rects:
        height = rect.get_height()
        ax.text(rect.get_x() + rect.get_width() / 2., 1.05 * height, '%d' %
                int(height), ha='center', va='bottom')

autolabel(rects1)
autolabel(rects2)

fname = cbook.get_sample_data('msft.csv', asfileobj=False)
plt.plotfile(fname, ('date', 'open', 'high', 'low', 'close'), subplots=False)
#plt.xlabel(r'$x$')
#plt.ylabel(r'$f(x) = x^2, x^3$')


plt.draw()
#fig1.set_size_inches(18.5, 10.5, forward = True)
plt.savefig("test.png")
plt.show()
Beispiel #51
0
#!/usr/bin/env python

from argparse import ArgumentParser
import matplotlib.pyplot as plt

if __name__ == '__main__' :
  parser = ArgumentParser(description="Plot a CSV file")
  parser.add_argument("datafile", help="The CSV file")
  # Require at least one column name
  parser.add_argument("columns", nargs="+",
                      help="Names of columns to plot")
  parser.add_argument("--save", help="Save the plot as ...")
  parser.add_argument("--no-show", action="store_true",
                      help="Don't show the plot")
  args = parser.parse_args()

  plt.plotfile(args.datafile, args.columns)
  if args.save:
    plt.savefig(args.save)
  if not args.no_show:
    plt.show()
Beispiel #52
0
import matplotlib.pyplot as plt
import numpy as np

#fname = open('msft.csv.org')
#fname = open('test.csv')
fname = open('create.csv')


#plt.plotfile(fname, ('date','emotion','headache','hipleft','hipright','shoulderleft','shoulderright','spinallow','spinalmiddle','spinalneck'), subplots=False)
plt.plotfile(fname, ('date','emotion','headache','hipleft','hipright','shoulderleft','spinallow','spinalneck'), subplots=False)
#Date,emotion,headache,hipleft,hipright,shoulderleft,spinallow,spinalneck


#plt.figtext("hello")
plt.xlabel(r'$date$')
plt.ylabel(r'$levels$')



plt.show()
plt.savefig('data_graph.png')
#!/usr/bin/env python
import os
import sys
import matplotlib.pyplot as plt

print "Enter the number of grid points"
n=raw_input()
print "Enter the name of the Figure"
Fig=raw_input()
plt.plotfile('Ea_Ju_VVE3.dat', cols=(1,2), label='Earth', delimiter=' ')
plt.plotfile('Ea_Ju_VVE3.dat', cols=(5,6),label='Jupiter', newfig=False, delimiter=' ')
plt.title('y vs x  '+n)
plt.xlabel('x(au)')
plt.ylabel('y(au)')
plt.legend()
plt.axis([-10,10,-10,10])
plt.grid()
plt.savefig(Fig)
plt.show()
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
sns.set_style('white')

import warnings
warnings.filterwarnings("ignore")

num_eq = 3
it_max = 100  # set to it_max run
fname = "coordinates.dat"  # data file name

# plot each coordinate (angular momentum) vs time
for i in range(num_eq):
    # note that i,j correspond to q_i, and not the column number in .dat file
    plt.plotfile(fname, delimiter=' ', cols=(0, i + 1), c='black')
    plt.title(
        '$q_{%d}$ as a function of time for torque-free motion (it_max = %d)' %
        (i, it_max))
    plt.xlabel('Time')
    plt.ylabel('$q_{%d}$' % i)
    plt.savefig('q_%d_vs_t_%d.pdf' %
                (i, it_max))  # plots are saved under q_i_vs_t.pdf
    plt.show(block=True)

# plot kinetic energy vs time
plt.plotfile(fname, delimiter=' ', cols=(0, 4), c='black')
plt.title(
    'Kinetic Energy as a function of time for torque-free motion (it_max = %d)'
    % it_max)
plt.xlabel("Time")
Beispiel #55
0
# test 1; use ints
#plt.plotfile(fname, (0, 5, 6))

# test 2; use names
#plt.plotfile(fname, ('date', 'volume', 'adj_close'))

# test 3; use semilogy for volume
#plt.plotfile(fname, ('date', 'volume', 'adj_close'),
#             plotfuncs={'volume': 'semilogy'})

# test 4; use semilogy for volume
#plt.plotfile(fname, (0, 5, 6), plotfuncs={5: 'semilogy'})

# test 5; single subplot
plt.plotfile(fname, ('date', 'pain', 'high', 'low', 'close'), subplots=True)

# test 6; labeling, if no names in csv-file
#plt.plotfile(fname2, cols=(0, 1, 2), delimiter=' ',
#             names=['$x$', '$f(x)=x^2$', '$f(x)=x^3$'])

# test 7; more than one file per figure--illustrated here with a single file
#plt.plotfile(fname2, cols=(0, 1), delimiter=' ')
#plt.plotfile(fname2, cols=(0, 2), newfig=False,
#             delimiter=' ')  # use current figure
plt.xlabel(r'$x$')
plt.ylabel(r'$f(x) = x^2, x^3$')

# test 8; use bar for volume
#plt.plotfile(fname, (0, 5, 6), plotfuncs={5: 'bar'})
Beispiel #56
0
#!/usr/bin/python
import numpy as np
import matplotlib.pyplot as plt

plt.rcParams.update({'font.size': 14, 'font.family': 'sans'})

fig, ax = plt.subplots()

ax = plt.plotfile('./time.dat', cols=(0, 1), delimiter = ' ')

#plt.plotfile(*np.loadtxt('time.dat', unpack=True))


#ax.plot(t, s, lw=2, color="red", ls = "-", alpha = 0.5,
#        marker = "o", markersize = 8.0, 
#        )
#        #animated = True, aa = True, clip_on = True)


fig.savefig('fig.pdf')

Beispiel #57
0
        an.acceptance_rate(i+1,count)

    an.chains_to_xyz(chains, 'ShortDual_'+str(n)+alph, lattice)

    analysis = an.sep_analysis(chains)
    analysis = tuple(x/float(sum(analysis)) for x in analysis)
    print analysis

    fig = plt.figure()
    ax = fig.add_subplot(111, projection='3d')
    for chain in chains:
        chain = chain[chain[:,0] >= 0]
        ax.plot(chain[:,0],chain[:,1],chain[:,2])
    #plt.show()

    plt.plotfile('EnergiesDual_'+str(n)+alph)
    plt.savefig("energyDual_" +str(n)+alph+".pdf")
    plt.close()

    binomial = []
    for k in xrange(0,6):
        m =5
        binomial += [an.choose(m,k)*(0.5**k)*(0.5**(m-k))]

    saved = np.save('Safe_SSRDual'+str(n)+alph, analysis)

    #spectra = open(r'C:\Users\Maggie\Documents\GitHub\scf-mc\Saved_spectra3D_'+str(n), 'w')
    #with spectra:
    spectra = open('Saved_spectraDual_'+str(n), 'a')
    spectra.write(str(analysis) +"\n")
    spectra.flush()
Beispiel #58
0
__author__ = 'Brian'

import csv
import matplotlib.pyplot as plt
import numpy as np

plt.plotfile('C:\Users\Brian\Desktop\Brian\Universitetet\Kandidat\Master Thesis\WeLoveGREEN-ENERGY\DATASET_FOR_GREEN_ENERGY_PLOTTING\wind_vs_prices.csv', delimiter=';', cols=(0, 1),
    names=('Wind Speed', 'Electricity Price'), linestyle='None', marker='.')

y=[]
x=[]

with open('C:\Users\Brian\Desktop\Brian\Universitetet\Kandidat\Master Thesis\WeLoveGREEN-ENERGY\DATASET_FOR_GREEN_ENERGY_PLOTTING\wind_vs_prices.csv', 'rb') as csvfile:
    dat = csv.reader(csvfile, delimiter=';')
    for row in dat:
        y.append(int(row[1]))
        x.append(int(row[0]))

m,b = np.polyfit(x,y,1)
plt.plot(x, np.array(x) * m +b, color='red')

plt.show()
Beispiel #59
0
import matplotlib.pyplot as plt

plt.plotfile("graph_ten_topics.txt", ("features", "accuracy"))
plt.title("Simple Plot")
plt.show()