def plot_heatmap(network, network_mean_rssi):

    fig, ax = plt.subplots()  # note we must use plt.subplots, not plt.subplot
    i1netmode.plot_atmosphere(ax)

    cm = plt.cm.get_cmap("hot")
    my_cmap = cm(np.linspace(0, 1, len(network_mean_rssi)))
    rects = []
    simple_plot = True
    if simple_plot:
        sc = plt.scatter(x, y, c=network_mean_rssi, s=250, marker="s", cmap=cm)
        plt.colorbar(sc)

    else:  # better plot but freaking messy
        for i in range(len(x)):
            if i <= 13:
                rect = Rectangle((x[i] - 0.5, y[i] - 1), 1, 2.5, color=my_cmap[i])
            else:
                rect = Rectangle((x[i] - 0.5, y[i] - 0.5), 1, 1, color=my_cmap[i])
            rects.append(rect)
            ax.add_patch(rect)
        minx = min(network_mean_rssi)
        maxx = max(network_mean_rssi)
        N = len(network_mean_rssi)
        norm = mpl.colors.Normalize(vmin=minx, vmax=maxx)
        sm = plt.cm.ScalarMappable(cmap=cm, norm=norm)
        sm.set_array([])
        plt.colorbar(sm)

    plt.title("RSSI Map of {}".format(network))
    # plt.show()
    plt.draw()
    plt.waitforbuttonpress(0)  # this will wait for indefinite time
    plt.close(fig)
Example #2
0
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

import pprint
from sklearn.neighbors import KNeighborsClassifier as kNN
from i0positions import Positions
import i1netmode

plt.ion()
fig, ax = plt.subplots()  # note we must use plt.subplots, not plt.subplot
i1netmode.plot_atmosphere(ax)

dataset = pd.read_csv("data/i2processed_average_positions.csv", header=[0, 1, 2])
features = np.asarray(dataset.iloc[:, 3:])
labels = np.asarray(dataset["Relative Position"])

# MACs of networks in dataset
networks = [z for (_, _, z) in list(dataset)[3:]]

# If we want only selected wifis in dataset:
network_names = ["ap", "hub0", "hub1", "hub2"]
networks = [z for (x, _, z) in list(dataset)[3:] if x in network_names]
features = np.asarray(dataset[network_names])


found_networks = [0] * len(networks)

# a = dataset.hist()
# plt.plot(a)