-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
101 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import typing | ||
import datetime | ||
|
||
import numpy as np | ||
|
||
from . import utils | ||
from .. import utilities | ||
|
||
|
||
class MPLCompletionPlot: | ||
width = 2 | ||
|
||
def __init__(self, todo_estimation, perweek_velocity_mean_std): | ||
dom, pdf = todo_estimation.divide_by_gauss_pdf(200, * perweek_velocity_mean_std) | ||
self.distribution = utilities.get_random_variable(dom, pdf) | ||
DAYS_IN_WEEK = 7 | ||
lower_bound = self.distribution.ppf(0.02) | ||
upper_bound = self.distribution.ppf(0.98) | ||
self.dom = np.arange( | ||
int(np.floor(lower_bound * DAYS_IN_WEEK)), | ||
int(np.ceil(upper_bound * DAYS_IN_WEEK)) + 1) | ||
self.probs = self.distribution.cdf(self.dom / DAYS_IN_WEEK) | ||
self.probs -= self.probs[0] | ||
self.probs /= self.probs[-1] | ||
self.probs *= 100 | ||
|
||
def _calculate_plan_wrt_day(self, ax, start): | ||
ax.plot(self.dom, self.probs, color="green", | ||
linewidth=self.width, label="prob of completion") | ||
utils.x_axis_weeks_and_months(ax, start, start + utils.ONE_DAY * self.dom[-1]) | ||
|
||
def get_figure(self): | ||
plt = utils.get_standard_pyplot() | ||
|
||
fig, ax = plt.subplots() | ||
ax.grid(True) | ||
|
||
self._calculate_plan_wrt_day(ax, datetime.datetime.today()) | ||
ax.legend(loc="upper left") | ||
|
||
ax.set_ylabel("percents") | ||
|
||
return fig | ||
|
||
def get_small_figure(self): | ||
plt = utils.get_standard_pyplot() | ||
|
||
fig, ax = plt.subplots() | ||
|
||
self._prepare_plots() | ||
self._plot_prepared_arrays(ax) | ||
self._show_plan(ax) | ||
self._show_today(ax) | ||
|
||
ax.set_axis_off() | ||
fig.subplots_adjust(0, 0, 1, 1) | ||
|
||
return fig | ||
|
||
def plot_stuff(self): | ||
plt = utils.get_standard_pyplot() | ||
self.get_figure() | ||
|
||
plt.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters