Пример #1
0
def generate_plot_from_file(fname, web_dir):
    print("generating plot for %s" % (fname))
    name = fname[:fname.rfind('_')]

    procs = []
    with open(fname, 'r') as f:
        reader = csv.reader(f, delimiter=' ')
        for row in reader:
            procs.append(int(row[0]))

    procs = list(set(procs))

    pylab.plotfile(fname,
                   cols=(0, 1, 2, 3),
                   delimiter=' ',
                   names=['$n_p$', 'min', 'avg', 'max'],
                   subplots=False,
                   plotfuncs={
                       1: 'semilogy',
                       2: 'semilogy',
                       3: 'semilogy'
                   },
                   marker='s',
                   linewidth=3)
    pylab.title("%s Performance" % (name))
    pylab.ylabel("time [s]")
    pylab.xticks(procs)
    pylab.savefig("%s/plots/%s.png" % (web_dir, fname))
    return "%s.png" % (fname)
def methodFirst():

    fname = cbook.get_sample_data(
        r'D:\Python\数据可视化\yahoo stoke API\amzn_2014-1-1_today.csv',
        asfileobj=False)
    plotfile(fname, ('date', 'high', 'low', 'close'), subplots=False)
    show()
    plotfile(fname, (0, 1, 5), plotfuncs={5: 'bar'})
    show()
Пример #3
0
def generate_plot_from_file(fname, web_dir):
    print("generating plot for %s" % (fname))
    name = fname[:fname.rfind('_')]

    procs = []
    with open(fname, 'r') as f:
        reader = csv.reader(f, delimiter=' ')
        for row in reader:
            procs.append(int(row[0]))

    procs = list(set(procs))

    pylab.plotfile(fname, cols=(0,1,2,3), delimiter=' ',
            names=['$n_p$', 'min', 'avg', 'max'], subplots=False,
            plotfuncs={1:'semilogy', 2:'semilogy', 3:'semilogy'},
            marker='s', linewidth=3)
    pylab.title("%s Performance" % (name))
    pylab.ylabel("time [s]")
    pylab.xticks(procs)
    pylab.savefig("%s/plots/%s.png" % (web_dir, fname))
    return "%s.png" % (fname)
Пример #4
0
def plotmythings_lines():
    if len(sys.argv) == 1:
        print 'Too few arguments'
        sys.exit()

        if len(sys.argv) > 2 and sys.argv[2] == 'using':
            j = int(sys.argv[3])
            k = int(sys.argv[4])
            i = sys.argv[1]
            plt.plotfile(i, delimiter=' ', cols=(j - 1, k - 1))

        else:
            for i in sys.argv:
                if i == sys.argv[1]:
                    plt.plotfile(i, delimiter=' ', cols=(0, 1))
                if (i != sys.argv[1] and i != sys.argv[0]):
                    plt.plotfile(i, delimiter=' ', newfig=False, cols=(0, 1))
def plotmythings_lines( ):
    if len(sys.argv)==1:
        print 'Too few arguments'
        sys.exit()


        if len(sys.argv)>2 and sys.argv[2]=='using':
            j=int(sys.argv[3])
            k=int(sys.argv[4])
            i=sys.argv[1]
            plt.plotfile(i, delimiter=' ', cols=(j-1,k-1))

        else:
            for i in sys.argv:
                if i==sys.argv[1]:
                    plt.plotfile(i, delimiter=' ', cols=(0,1))
                if (i!=sys.argv[1] and i!=sys.argv[0]):
                    plt.plotfile(i, delimiter=' ',newfig=False,cols=(0,1))
Пример #6
0
#!/usr/bin/env python

# Documentation of 'plotfile' see -
# http://matplotlib.org/api/pyplot_api.html#module-matplotlib.pyplot

# This script is used to plot the data generated by - 'test_airsea'

from pylab import plotfile, show, gca, savefig

fname = "fort.200"
plotfile(fname, (
    0,
    1,
    2,
), delimiter=' ', subplots=False)
gca().set_xlabel(r'Wind speed')
gca().set_title(r'Momentum bulk transfer coefficient')
savefig('cdd.png')
show()

plotfile(fname, (
    0,
    3,
    4,
), delimiter=' ', subplots=False)
gca().set_xlabel(r'Wind speed')
gca().set_title(r'Latent heat bulk transfer coefficient')
savefig('ced.png')
show()

plotfile(fname, (
Пример #7
0
#!/usr/bin/env python

# Documentation of 'plotfile' see -
# http://matplotlib.org/api/pyplot_api.html#module-matplotlib.pyplot

# This script is used to plot the data generated by - 'test_airsea'

from pylab import plotfile, show, gca, savefig

fname="fort.100"
plotfile(fname, (0, 1, 2, 3, 4), delimiter=' ',subplots=False)
gca().set_xlabel(r'hour')
gca().set_title(r'Solar zenith angle (1 day)')
savefig('solar_zenith_angle_day.png')
show()

fname="fort.101"
plotfile(fname, (0, 1, 2, 3, 4), delimiter=' ',subplots=False)
gca().set_xlabel(r'hour')
gca().set_title(r'Short wave radiation (1 day)')
savefig('short_wave_radiation_day.png')
show()

fname="fort.200"
plotfile(fname, (0, 1, 2, 3, 4), delimiter=' ',subplots=False)
gca().set_xlabel(r'day')
gca().set_title(r'Solar zenith angle (1 year)')
savefig('solar_zenith_angle_year.png')
show()

fname="fort.201"
Пример #8
0
#!/usr/bin/env python
# Alberto Rodriguez Sanchez
import pylab
import numpy as np
import sys

if __name__ == '__main__':
    assert len(sys.argv) > 1, "Argumentos insuficientes"
    try:
        pylab.plotfile(sys.argv[1],
                       delimiter=' ',
                       cols=(0, 1),
                       names=('f1', 'f2'))
        pylab.show()
    except IOError as e:
        print "I/O error({0}):{1}".format(e.errno, e.strerror)
Пример #9
0
__data__ = '2015-09-23 16:28'

__mail__ = '[email protected]/[email protected]'

__weibo__ = 'http://weibo.com/ganchaojiang'


from pylab import plotfile, show, gca
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
plotfile(fname, (0,5,6))

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

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

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

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

# test 6; labeling, if no names in csv-file
plotfile(fname2, cols=(0,1,2), delimiter=' ',
"""
  Name     : 4375OS_07_27_volume_and_price_2_plots.py
  Book     : Python for Finance
  Publisher: Packt Publishing Ltd. 
  Author   : Yuxing Yan
  Date     : 12/26/2013
  email    : [email protected]
             [email protected]
"""

from pylab import plotfile, show
import matplotlib.finance as finance
ticker = 'IBM'
begdate = datetime.date(2013,1,1)
enddate = datetime.date.today()
x= finance.fetch_historical_yahoo(ticker, begdate, enddate)
plotfile(x, (0,5,6))
show()


Пример #11
0
from pylab import plotfile, show
import matplotlib.cbook as cbook  
fname = cbook.get_sample_data('/Users/MacBook/Downloads/Book_code/Chapter4/amzn.csv', asfileobj=False) 
plotfile(fname, (0,1,5), plotfuncs={5:'bar'}) 
show()

Пример #12
0
def plot(filename):
    print('Plotting %s' % filename)
    pylab.plotfile(filename, cols=(0, 1), delimiter=' ', subplots=False)
    pylab.show()
Пример #13
0
from pylab import plotfile, show

fname = 'data/msft.csv'

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

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

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

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

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

show()
Пример #14
0
from pylab import plotfile, show, gca
import matplotlib.cbook as cbook

fname = cbook.get_sample_data('/home/wuqili/datavis/amzn.csv', asfileobj=False)
plotfile(fname, (0,4,6 ), plotfuncs={'Volume':'bar'})
show()
Пример #15
0
from pylab import plotfile, show

fname = 'data/msft.csv'    

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

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

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

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

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

show()


Пример #16
0
from pylab import plotfile, show, gca
import matplotlib.cbook as cbook
fname = cbook.get_sample_data(
    '/Users/MacBook/Downloads/Book_Code/Chapter4/amzn.csv', asfileobj=False)
plotfile(fname, ('date', 'high', 'low', 'close'), subplots=False)
show()
Пример #17
0
from pylab import plotfile, show, gca
import matplotlib.cbook as cbook

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

plotfile(fname,(0,5,6))
plotfile(fname,('date','volume','adj_close'))

show()
Пример #18
0
from pylab import plotfile, show, gca
import matplotlib.cbook as cbook

fname = cbook.get_sample_data('/home/dual/cs5120284/Desktop/TCP_/bic.csv', asfileobj=False)
#fname2 = cbook.get_sample_data('data_x_x2_x3.csv', asfileobj=False)

# test 1; use ints
plotfile(fname, (1,2,0))
'''
# test 2; use names
plotfile(fname, ('date', 'volume', 'adj_close'))

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

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

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

# test 6; labeling, if no names in csv-file
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
plotfile(fname2, cols=(0, 1), delimiter=' ')
plotfile(fname2, cols=(0, 2), newfig=False, delimiter=' ') # use current figure
gca().set_xlabel(r'$x$')
gca().set_ylabel(r'$f(x) = x^2, x^3$')
Пример #19
0
#!/usr/bin/env python

# Documentation of 'plotfile' see -
# http://matplotlib.org/api/pyplot_api.html#module-matplotlib.pyplot

# This script is used to plot the data generated by - 'test_airsea'

from pylab import plotfile, show, gca, savefig

fname = "fort.100"
plotfile(fname, (0, 1, 2, 3, 4), delimiter=' ', subplots=False)
gca().set_xlabel(r'hour')
gca().set_title(r'Solar zenith angle (1 day)')
savefig('solar_zenith_angle_day.png')
show()

fname = "fort.101"
plotfile(fname, (0, 1, 2, 3, 4), delimiter=' ', subplots=False)
gca().set_xlabel(r'hour')
gca().set_title(r'Short wave radiation (1 day)')
savefig('short_wave_radiation_day.png')
show()

fname = "fort.200"
plotfile(fname, (0, 1, 2, 3, 4), delimiter=' ', subplots=False)
gca().set_xlabel(r'day')
gca().set_title(r'Solar zenith angle (1 year)')
savefig('solar_zenith_angle_year.png')
show()

fname = "fort.201"
Пример #20
0
import sys
from pylab import plotfile, show, gca
import matplotlib
import matplotlib.cbook as cbook

fn = sys.argv[1]
print "fn=",fn

matplotlib.rcParams['examples.directory'] = '.'
fname = cbook.get_sample_data(fn,asfileobj=True )

plotfile(fname, ('date', 'pylmm1', 'pylmm2'), subplots=False)

show()
"""
  Name     : 4375OS_07_27_volume_and_price_2_plots.py
  Book     : Python for Finance
  Publisher: Packt Publishing Ltd. 
  Author   : Yuxing Yan
  Date     : 12/26/2013
  email    : [email protected]
             [email protected]
"""

from pylab import plotfile, show
import matplotlib.finance as finance
ticker = 'IBM'
begdate = datetime.date(2013, 1, 1)
enddate = datetime.date.today()
x = finance.fetch_historical_yahoo(ticker, begdate, enddate)
plotfile(x, (0, 5, 6))
show()
Пример #22
0
#!/usr/bin/env python

# Documentation of 'plotfile' see -
# http://matplotlib.org/api/pyplot_api.html#module-matplotlib.pyplot

# This script is used to plot the data generated by - 'test_albedo'

from pylab import plotfile, show, gca, savefig

fname="fort.100"
plotfile(fname, (0, 1, 2, 3, 4, 5), delimiter=' ',subplots=False)
gca().set_xlabel(r'angle')
gca().set_title(r'Albedo as function of zenith angle')
savefig('albedo_zenith.png')
show()

fname="fort.101"
plotfile(fname, (0, 1, 2, 3, 4, 5, 6, 7, 8 ), delimiter=' ',subplots=False)
gca().set_xlabel(r'year day')
gca().set_title(r'Albedo as function of year day')
savefig('albedo_yearday.png')
show()
Пример #23
0
def plot(filename):
    print 'Plotting %s' % filename
    pylab.plotfile(filename, cols=(0,1), delimiter=' ', subplots=False)
    pylab.show()
Пример #24
0
#!/usr/bin/env python

import pylab as pl

pl.plotfile("./everything_vs_kT.dat", cols=range(5), delimiter='\t')
pl.savefig("everything_vs_kT.png")

pl.plotfile("./everything_vs_system_size.dat", cols=range(5), plotfuncs={2:'plot',3:'semilogy'}, delimiter='\t')
pl.savefig("everything_vs_system_size.png")
Пример #25
0
from pylab import plotfile, show, gca
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
plotfile(fname, (0, 5, 6))

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

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

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

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

# test 6; labeling, if no names in csv-file
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
plotfile(fname2, cols=(0, 1), delimiter=' ')
plotfile(fname2, cols=(0, 2), newfig=False,
Пример #26
0
from pylab import plotfile, show, gca
import matplotlib.cbook as cbook

fname = cbook.get_sample_data('/Users/joy/Dropbox/utsa/research/mascots/results/var_interval-1.csv.csv', asfileobj=False)
#fname2 = cbook.get_sample_data('data_x_x2_x3.csv', asfileobj=False)

# test 1; u

plotfile(fname, (0, 1), subplots=False)
show()