コード例 #1
0
 def task():
     fig = mtp.new_figure((6,4))
     ax = fig.add_subplot(1,1,1)
     x = [0, self.model.days, self.model.days, self.model.days*1.1]
     y = [1,1,0,0]
     ax.plot(x, y)
     ax.set(xlabel=_text["days"], ylabel=_text["int"], xlim=[0, self.model.days*1.1], ylim=[-0.1,1.1])
     return fig
コード例 #2
0
 def task():
     fig = mtp.new_figure((6,4))
     ax = fig.add_subplot(1,1,1)
     x = np.linspace(0, self.model.scale*5, 100)
     kernel = self.model.make_kernel()
     ax.plot(x, kernel(x))
     ax.set(xlabel=_text["days"], ylabel=_text["int"], xlim=[0, self.model.scale*5], ylim=[0,1])
     return fig
コード例 #3
0
 def task():
     fig = mtp.new_figure((6,6))
     ax = fig.add_subplot(1,1,1)
     xcs, ycs = coords
     self.sample_kernel(kernel_provider, [xcs, ycs], ax)
     ax.set_aspect(1)
     fig.set_tight_layout("tight")
     return fig
コード例 #4
0
ファイル: retro.py プロジェクト: wsteenbeek/PredictCode
def _plot_weight(weight, bandwidth):
    fig = mtp.new_figure((5, 5))
    ax = fig.add_subplot(1, 1, 1)
    xc = np.linspace(-bandwidth, bandwidth, 50)
    yc = weight(xc, [0] * len(xc))
    ax.plot(xc, yc, color="black")
    ax.set(xlabel="Distance in metres")
    ax.set(ylabel="Relative risk")
    fig.set_tight_layout(True)
    return fig
コード例 #5
0
 def make_fig():
     fig = mtp.new_figure((20, 20))
     ax = fig.add_subplot(1, 1, 1)
     prediction = self.model.current_prediction
     if level == -1:
         plot_risk(prediction, ax, adjust_task)
     else:
         plot_coverage(prediction, level, ax, adjust_task)
     ax.set_aspect(1)
     fig.set_tight_layout(True)
     return fig
コード例 #6
0
 def task():
     fig = mtp.new_figure(size=(8, 8))
     ax = fig.add_subplot(1, 1, 1)
     self._try_add_patch(ax, geo)
     ax.scatter(coords[0],
                coords[1],
                marker="+",
                color="black",
                alpha=0.5)
     ax.set_aspect(1)
     fig.set_tight_layout("tight")
     return fig
コード例 #7
0
 def task():
     xmin, ymin, xmax, ymax = geo.bounds
     xdelta = (xmax - xmin) / 100 * 2
     ydelta = (ymax - ymin) / 100 * 2
     fig = mtp.new_figure(size=(8, 8))
     ax = fig.add_subplot(1, 1, 1)
     self._try_add_patch(ax, geo)
     ax.set(xlim=[xmin - xdelta, xmax + xdelta],
            ylim=[ymin - ydelta, ymax + ydelta])
     ax.set_aspect(1)
     fig.set_tight_layout("tight")
     return fig
コード例 #8
0
 def _plot_task(self):
     fig = mtp.new_figure((5,5))
     ax = fig.add_subplot(1,1,1)
     dist_obj = self._model.grid_distance()
     xcs = np.array([-3, -2, -1, 0, 1, 2, 3, 4])
     ycs = np.array([-3, -2, -1, 0, 1, 2, 3, 4])
     dists = np.empty((len(ycs)-1,len(xcs)-1))
     for ix, x in enumerate(xcs[:-1]):
         for iy, y in enumerate(ycs[:-1]):
             dists[iy][ix] = dist_obj(0,0,x,y)
     pcm = ax.pcolormesh(xcs, ycs, dists, cmap="rainbow")
     fig.colorbar(pcm)
     ax.set(xlabel=_text["dgx"], ylabel=_text["dgy"])
     fig.set_tight_layout(True)
     return fig
コード例 #9
0
 def _plot_task(self):
     fig = mtp.new_figure((5,5))
     ax = fig.add_subplot(1,1,1)
     weight = self._model.weight()
     xcs = np.arange(0, self._model.space_bandwidth + 1)
     ycs = np.arange(0, self._model.time_bandwidth + 1)
     dists = np.empty((len(ycs)-1,len(xcs)-1))
     for ix, d_space in enumerate(xcs[:-1]):
         for iy, d_time in enumerate(ycs[:-1]):
             dists[iy][ix] = weight(d_time,d_space)
     num, unit = ProHotspotView.timeunit(self._parent_model.time_window_length)
     pcm = ax.pcolormesh(xcs, ycs * num, dists, cmap="rainbow")
     fig.colorbar(pcm)
     yl = _text["time_bin_choices"][unit]
     ax.set(xlabel=_text["kgx"], ylabel=yl)
     fig.set_tight_layout(True)
     return fig
コード例 #10
0
 def _plot_task(self):
     fig = mtp.new_figure((5, 5))
     ax = fig.add_subplot(1, 1, 1)
     weight = self._model.weight()
     xcs = np.linspace(0, self._model.space_bandwidth, 100)
     ycs = np.linspace(0, self._model.time_bandwidth, 100)
     dists = np.empty((len(ycs) - 1, len(xcs) - 1))
     for ix, d_space in enumerate(xcs[:-1]):
         for iy, d_time in enumerate(ycs[:-1]):
             dists[iy][ix] = weight(d_time, d_space)
     xscale = self._parent_model.space_length
     yscale = self._parent_model.time_window_length / datetime.timedelta(
         hours=1)
     pcm = ax.pcolormesh(xcs * xscale, ycs * yscale, dists, cmap="rainbow")
     fig.colorbar(pcm)
     ax.set(xlabel=_text["kgx"], ylabel=_text["kgy"])
     fig.set_tight_layout(True)
     return fig
コード例 #11
0
 def _plot_task(self):
     fig = mtp.new_figure((5, 5))
     ax = fig.add_subplot(1, 1, 1)
     dist_obj = self._model.grid_distance()
     bandwidth = self._model.model.space_length
     xcs = np.linspace(-5, 5, 100)
     ycs = np.linspace(-5, 5, 100)
     dists = np.empty((len(ycs) - 1, len(xcs) - 1))
     for ix, x in enumerate(xcs[:-1]):
         for iy, y in enumerate(ycs[:-1]):
             dists[iy][ix] = dist_obj(0, 0, x, y)
     pcm = ax.pcolormesh(xcs * bandwidth,
                         ycs * bandwidth,
                         dists,
                         cmap="rainbow")
     fig.colorbar(pcm)
     ax.set(xlabel=_text["dgx"], ylabel=_text["dgy"])
     fig.set_tight_layout(True)
     return fig
コード例 #12
0
ファイル: grid.py プロジェクト: wsteenbeek/PredictCode
        def make_fig():
            xmin, xmax = _np.min(coords[0]), _np.max(coords[0])
            xd = (xmax - xmin) / 100 * 3
            xmin, xmax = xmin - xd, xmax + xd
            ymin, ymax = _np.min(coords[1]), _np.max(coords[1])
            yd = (ymax - ymin) / 100 * 3
            ymin, ymax = ymin - yd, ymax + yd

            width = xmax - xmin
            height = ymax - ymin
            if width == 0 or height == 0:
                size = (10, 10)
            else:
                height = height / width * 10.0
                width = 10.0
                if height > 10.0:
                    width = 100.0 / height
                    height = 10.0
                size = (width, height)

            fig = mtp.new_figure(size)
            ax = fig.add_subplot(1, 1, 1)
            ax.scatter(coords[0],
                       coords[1],
                       marker="x",
                       color="black",
                       alpha=0.5)
            lc = open_cp.plot.lines_from_regular_grid(
                self._controller.get_grid())
            ax.add_collection(
                mtp.matplotlib.collections.LineCollection(lc,
                                                          color="black",
                                                          linewidth=0.5))
            ax.set(xlim=[xmin, xmax], ylim=[ymin, ymax])
            ax.set_aspect(1.0)
            fig.set_tight_layout(True)
            return fig