Beispiel #1
0
 def redo_axes_ticks(self, axes:matplotlib.axes.Axes, x_len:int, y_len:int):
     downsample = self.w_downsample.value()
     x_stops = np.linspace(0, x_len, 6)
     x_stops_downsampled = x_stops / downsample
     axes.set_xticks(x_stops_downsampled)
     axes.set_xticklabels(["%d" % x for x in x_stops])
     y_stops = np.linspace(0, y_len, 6)[::-1]
     y_stops_downsampled = y_stops / downsample
     axes.set_yticks(y_stops_downsampled)
     axes.set_yticklabels(["%d" % y for y in y_stops])
Beispiel #2
0
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.axes as ax
import pylab

# change to proper directory
os.chdir('C:\Users\Matt\Desktop\Python Projects\Exploratory Data Analysis')

# load file, select proper date range, convert row to numeric dtypes
hpc = pd.read_csv('household_power_consumption.txt',
                  sep=';',
                  index_col=['Date'],
                  usecols=['Global_active_power', 'Date'])
# hpc = hpc.drop(['Date', 'Time'], axis=1).set_index('DT')
hpc = hpc['1/2/2007':'3/2/2007'].convert_objects(convert_numeric=True)
hpc = hpc[0:2881]
# create plotting variables
x = pd.date_range('2/1/2007', '2/3/2007 00:00', freq='T')
y = hpc['Global_active_power']
#plt.plot(y, color='k')

fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
ax.plot(x, y, color='k')
ax.set_xticklabels(['Thur', '', '', '', 'Fri', '', '', '', 'Sat'])
ax.set_yticklabels(['0', '', '2', '', '4', '', '6'])
#plt.xlabel('Global Active Power (kilowatts)')
ax.set_ylabel('Global Active Power (kilowatts)')
#plt.title('Global Active Power')
pylab.show()
Beispiel #3
0
domain_x = 20
domain_y = 20
iterations = 200

# Should not need to adjust anything below here
domain = np.genfromtxt(domain_file, skip_header=2)
pos_data = np.zeros(14)

dom_x, dom_y = domain.shape

for time in range(0, iterations):
    print(time)
    plt.figure()
    plt.title("Time = {0}".format(time))
    ax = plt.gca()
    ax.set_xticks(np.arange(-.5, 20, 1))
    ax.set_yticks(np.arange(-.5, 20, 1))
    ax.set_xticklabels(np.arange(0, 20, 1))
    ax.set_yticklabels(np.arange(0, 20, 1))
    plt.imshow(domain, cmap=cm.jet, interpolation='nearest')
    for i in range(0, cores):
        for j in range(0, int(seekers / cores)):

            filename = "PositionalData/pos_procseeker{0}_Iter{1}.dat".format(
                1000 * i + j, time)
            temp_plot = np.genfromtxt(filename)
            plt.plot(temp_plot[:, 0], temp_plot[:, 1], 'x')
    #plt.show()
    plt.savefig("PositionalData/Positions_{0}.png".format(time), dpi=200)
    plt.close()
import matplotlib.axes as ax
from matplotlib.animation import FuncAnimation
from random import uniform, choice
import os

speeds = [
    0.08, -0.08, 0.07, -0.07, 0.06, -0.06, 0.05, -0.05, 0.04, -0.04, 0, 0
]

# ---------------------------CREATE FIGURES/PLOTS------------------------------

# Create upper graph
fig = plt.figure(figsize=(10, 8))
ax = plt.subplot(211)  # (rows, columns, plot index)
ax.set_xticklabels([])
ax.set_yticklabels([])
ax.set_xticks([])
ax.set_yticks([])

x_max = 10
y_max = 6
xy_min = 0

ax.set_xlim(right=x_max)
ax.set_ylim(top=y_max)

# Create bottom graph
ax2 = plt.subplot(212)
ax2.set_xlim(right=1000)
ax2.set_ylim(top=70)
ax2.set_xlabel('Time')
import matplotlib.pyplot as plt
import matplotlib.axes as ax
import pylab

# change to proper directory
os.chdir('C:\Users\Matt\Desktop\Python Projects\Exploratory Data Analysis')

# load file, select proper date range, convert row to numeric dtypes
hpc = pd.read_csv('household_power_consumption.txt', sep=';', index_col=['Date'], usecols=['Sub_metering_1', 'Sub_metering_2', 'Sub_metering_3', 'Date'])
# hpc = hpc.drop(['Date', 'Time'], axis=1).set_index('DT')
hpc = hpc['1/2/2007':'3/2/2007'].convert_objects(convert_numeric=True)
hpc = hpc[0:2881]
# create plotting variables
x = pd.date_range('2/1/2007', '2/3/2007 00:00', freq='T')
y1 = hpc.Sub_metering_1
y2 = hpc.Sub_metering_2
y3 = hpc.Sub_metering_3

fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
ax.plot(x, y1, color='k', label='Sub_metering_1')
ax.plot(x, y2, color='r', label='Sub_metering_2')
ax.plot(x, y3, color='b', label='Sub_metering_3')
ax.legend(loc='best')
ax.set_xticklabels(['Thur', '', '', '', 'Fri', '', '', '','Sat'])
ax.set_yticklabels(['0', '',  '10', '', '20', '', '30'])

#plt.xlabel('Global Active Power (kilowatts)')
ax.set_ylabel('Energy sub metering')
#plt.title('Global Active Power')
pylab.show()
# import needed libraries
import os
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.axes as ax
import pylab

# change to proper directory
os.chdir('C:\Users\Matt\Desktop\Python Projects\Exploratory Data Analysis')

# load file, select proper date range, convert row to numeric dtypes
hpc = pd.read_csv('household_power_consumption.txt', sep=';', index_col=['Date'], usecols=['Global_active_power', 'Date'])
# hpc = hpc.drop(['Date', 'Time'], axis=1).set_index('DT')
hpc = hpc['1/2/2007':'3/2/2007'].convert_objects(convert_numeric=True)
hpc = hpc[0:2881]
# create plotting variables
x = pd.date_range('2/1/2007', '2/3/2007 00:00', freq='T')
y = hpc['Global_active_power']
#plt.plot(y, color='k')

fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
ax.plot(x, y, color='k')
ax.set_xticklabels(['Thur', '', '', '', 'Fri', '', '', '','Sat'])
ax.set_yticklabels(['0', '',  '2', '', '4', '', '6'])
#plt.xlabel('Global Active Power (kilowatts)')
ax.set_ylabel('Global Active Power (kilowatts)')
#plt.title('Global Active Power')
pylab.show()
# change to proper directory
os.chdir('C:\Users\Matt\Desktop\Python Projects\Exploratory Data Analysis')

# load file, select proper date range, convert row to numeric dtypes
hpc = pd.read_csv(
    'household_power_consumption.txt',
    sep=';',
    index_col=['Date'],
    usecols=['Sub_metering_1', 'Sub_metering_2', 'Sub_metering_3', 'Date'])
# hpc = hpc.drop(['Date', 'Time'], axis=1).set_index('DT')
hpc = hpc['1/2/2007':'3/2/2007'].convert_objects(convert_numeric=True)
hpc = hpc[0:2881]
# create plotting variables
x = pd.date_range('2/1/2007', '2/3/2007 00:00', freq='T')
y1 = hpc.Sub_metering_1
y2 = hpc.Sub_metering_2
y3 = hpc.Sub_metering_3

fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
ax.plot(x, y1, color='k', label='Sub_metering_1')
ax.plot(x, y2, color='r', label='Sub_metering_2')
ax.plot(x, y3, color='b', label='Sub_metering_3')
ax.legend(loc='best')
ax.set_xticklabels(['Thur', '', '', '', 'Fri', '', '', '', 'Sat'])
ax.set_yticklabels(['0', '', '10', '', '20', '', '30'])

#plt.xlabel('Global Active Power (kilowatts)')
ax.set_ylabel('Energy sub metering')
#plt.title('Global Active Power')
pylab.show()