Beispiel #1
0
def plotDoubleByDate(datalocation, datatypeA, datatypeB):
    figure = plt.figure(num=None,
                        figsize=(8, 6),
                        dpi=imageResolution,
                        facecolor=backgroundFigure,
                        edgecolor='k')
    figure.suptitle("COVID-19: since " + startDate,
                    fontsize=13,
                    fontname=defaultFont)
    plt.subplot2grid((2, 1), (0, 0))
    for i in range(len(datalocation[datatypeA])):
        databases[datatypeA][startDate:][datalocation[datatypeA][i]].plot(
            kind='line', label=regions[i], linewidth=2.5)
    plt.title(dataTitles[datatypeA], fontname=defaultFont, fontsize=10)
    plt.legend(loc=0,
               shadow=True,
               facecolor=backgroundFigure,
               prop={
                   'family': legendFont,
                   'size': 8
               })
    plt.grid(which='both', axis='both')
    plt.yscale(plotScale)
    plt.ylabel("Number of cases", fontname=legendFont)
    plt.xlabel("")
    plt.minorticks_on()
    plt.grid(True,
             "major",
             "y",
             ls="-",
             lw=0.8,
             c=majorGridColor,
             alpha=alphaMGC)
    plt.grid(True,
             "minor",
             "y",
             ls="--",
             lw=0.3,
             c=minorGridColor,
             alpha=alphamGC)
    plt.grid(True,
             "major",
             "x",
             ls="-",
             lw=0.8,
             c=majorGridColor,
             alpha=alphaMGC)
    plt.grid(True,
             "minor",
             "x",
             ls="--",
             lw=0.3,
             c=minorGridColor,
             alpha=alphamGC)
    plt.xticks(fontsize=6)
    plt.yticks(fontsize=6)
    plt.gca().set_facecolor(backgroundPlot)
    plt.subplot2grid((2, 1), (1, 0))
    for i in range(len(datalocation[datatypeB])):
        databases[datatypeB][startDate:][datalocation[datatypeB][i]].plot(
            kind='line', label=regions[i], linewidth=2.5)
    plt.title(dataTitles[datatypeB], fontname=defaultFont, fontsize=10)
    plt.legend(loc=0,
               shadow=True,
               facecolor=backgroundFigure,
               prop={
                   'family': legendFont,
                   'size': 8
               })
    plt.grid(which='both', axis='both')
    plt.yscale(plotScale)
    plt.ylabel("Number of cases", fontname=legendFont)
    plt.xlabel("Time in days", fontname=legendFont)
    plt.minorticks_on()
    plt.grid(True,
             "major",
             "y",
             ls="-",
             lw=0.8,
             c=majorGridColor,
             alpha=alphaMGC)
    plt.grid(True,
             "minor",
             "y",
             ls="--",
             lw=0.3,
             c=minorGridColor,
             alpha=alphamGC)
    plt.grid(True,
             "major",
             "x",
             ls="-",
             lw=0.8,
             c=majorGridColor,
             alpha=alphaMGC)
    plt.grid(True,
             "minor",
             "x",
             ls="--",
             lw=0.3,
             c=minorGridColor,
             alpha=alphamGC)
    plt.xticks(fontsize=6)
    plt.yticks(fontsize=6)
    plt.gca().set_facecolor(backgroundPlot)
    plt.tight_layout(rect=[0, 0, 1, 1])
    plt.show()
Beispiel #2
0
def plotDoubleNewCases5Av(datalocation, datatypeA, datatypeB, dataguide):
    startPoints = regionsStartPoints(regions)
    period = databases[dataguide].shape[0] - startPoints[dataguide][
        0] - outbreakDayCount
    figure = plt.figure(num=None,
                        figsize=(8, 6),
                        dpi=imageResolution,
                        facecolor=backgroundFigure,
                        edgecolor='k')
    figure.suptitle("COVID-19: New cases trend since number " +
                    str(caseCount) + " " + dataTitles[dataguide],
                    fontsize=13,
                    fontname=defaultFont)
    plt.subplot2grid((2, 1), (0, 0))
    for i in range(len(datalocation[datatypeA])):
        startPoint = startPoints[dataguide][i] + outbreakDayCount
        if startPoint > 0:
            startPoint -= 1
        datalist = databases[datatypeA][startPoint:startPoint + period][
            regionsIndexes[datatypeA][i]].values.tolist()
        datalistsub = getNewCasesAv(getNewCases(datalist))
        plt.plot(datalistsub, label=regions[i], linewidth=2.5)
    plt.title(dataTitles[datatypeA])
    plt.legend(loc=0,
               shadow=True,
               facecolor=backgroundFigure,
               prop={
                   'family': legendFont,
                   'size': 8
               })
    plt.grid()
    plt.ylabel("Average of new cases (7 days)", fontname=legendFont)
    plt.xlabel("", fontname=legendFont)
    plt.yscale(plotScale)
    plt.xticks(fontsize=6)
    plt.yticks(fontsize=6)
    plt.minorticks_on()
    plt.grid(True,
             "major",
             "y",
             ls="-",
             lw=0.8,
             c=majorGridColor,
             alpha=alphaMGC)
    plt.grid(True,
             "minor",
             "y",
             ls="--",
             lw=0.3,
             c=minorGridColor,
             alpha=alphamGC)
    plt.grid(True,
             "major",
             "x",
             ls="-",
             lw=0.8,
             c=majorGridColor,
             alpha=alphaMGC)
    plt.grid(True,
             "minor",
             "x",
             ls="--",
             lw=0.3,
             c=minorGridColor,
             alpha=alphamGC)
    plt.gca().set_facecolor(backgroundPlot)
    plt.subplot2grid((2, 1), (1, 0))
    for i in range(len(datalocation[datatypeB])):
        startPoint = startPoints[dataguide][i] + outbreakDayCount
        if startPoint > 0:
            startPoint -= 1
        datalist = databases[datatypeB][startPoint:startPoint + period][
            regionsIndexes[datatypeB][i]].values.tolist()
        datalistsub = getNewCasesAv(getNewCases(datalist))
        plt.plot(datalistsub, label=regions[i], linewidth=2.5)
    plt.title(dataTitles[datatypeB])
    plt.legend(loc=0,
               shadow=True,
               facecolor=backgroundFigure,
               prop={
                   'family': legendFont,
                   'size': 8
               })
    plt.grid()
    plt.ylabel("Average of new cases (7 days)", fontname=legendFont)
    plt.xlabel("Time in days", fontname=legendFont)
    plt.yscale(plotScale)
    plt.xticks(fontsize=6)
    plt.yticks(fontsize=6)
    plt.minorticks_on()
    plt.grid(True,
             "major",
             "y",
             ls="-",
             lw=0.8,
             c=majorGridColor,
             alpha=alphaMGC)
    plt.grid(True,
             "minor",
             "y",
             ls="--",
             lw=0.3,
             c=minorGridColor,
             alpha=alphamGC)
    plt.grid(True,
             "major",
             "x",
             ls="-",
             lw=0.8,
             c=majorGridColor,
             alpha=alphaMGC)
    plt.grid(True,
             "minor",
             "x",
             ls="--",
             lw=0.3,
             c=minorGridColor,
             alpha=alphamGC)
    plt.gca().set_facecolor(backgroundPlot)
    plt.tight_layout(rect=[0, 0, 1, 1])
    plt.show()
Beispiel #3
0
def plotWeeklyCasesR(regionindexC, regionindexD, region):
    figure = plt.figure(num=None,
                        figsize=(5, 4),
                        dpi=imageResolution,
                        facecolor=backgroundFigure,
                        edgecolor='k')
    figure.suptitle(region + ": Weeks analysis ( since " + startDate + ")",
                    fontsize=12)
    weeklyCases = getWeeklyCasesR(regionindexC, 0)
    plt.subplot2grid((2, 1), (0, 0))
    for w in range(len(weeklyCases) - 1):
        plt.plot(weeklyCases[w], linewidth=2.0, color="tab:blue", alpha=0.5)
    plt.plot(weeklyCases[len(weeklyCases) - 1],
             linewidth=2.5,
             color="orange",
             alpha=1.0)
    plt.plot([0, 6], [
        weeklyCases[len(weeklyCases) - 1][0],
        weeklyCases[len(weeklyCases) - 1][6]
    ],
             linewidth=1.0,
             linestyle="--",
             color="tab:red",
             alpha=1.0)
    plt.title("New confirmed cases by day of the week",
              fontsize=10,
              fontname=legendFont)
    plt.grid()
    plt.ylabel("Cases relative\nto week maximum",
               fontsize=8,
               fontname=legendFont)
    ylimits = plt.ylim()
    plt.yticks(nu.arange(0, ylimits[1] * 1.2, 0.2))
    plt.xticks(nu.arange(0, 7, step=1),
               getDaysTags(dayTags, 0),
               fontsize=6,
               rotation=30)
    plt.xticks(fontsize=5)
    plt.yticks(fontsize=6)
    plt.minorticks_on()
    plt.grid(True, "major", "y", ls="-", lw=0.8, c="dimgray", alpha=0.5)
    plt.gca().set_facecolor(backgroundPlot)
    weeklyCases = getWeeklyCasesR(regionindexD, 1)
    plt.subplot2grid((2, 1), (1, 0))
    for w in range(len(weeklyCases) - 1):
        plt.plot(weeklyCases[w], linewidth=2.0, color="tab:blue", alpha=0.5)
    plt.plot(weeklyCases[len(weeklyCases) - 1],
             linewidth=2.5,
             color="orange",
             alpha=1.0)
    plt.plot([0, 6], [
        weeklyCases[len(weeklyCases) - 1][0],
        weeklyCases[len(weeklyCases) - 1][6]
    ],
             linewidth=1.0,
             linestyle="--",
             color="tab:red",
             alpha=1.0)
    plt.title("New deaths by day of the week",
              fontsize=10,
              fontname=legendFont)
    plt.grid()
    plt.ylabel("Deaths relative\nto week maximum",
               fontsize=8,
               fontname=legendFont)
    ylimits = plt.ylim()
    plt.yticks(nu.arange(0, ylimits[1] * 1.2, 0.2))
    plt.xticks(nu.arange(0, 7, step=1),
               getDaysTags(dayTags, 0),
               fontsize=6,
               rotation=30)
    plt.xticks(fontsize=5)
    plt.yticks(fontsize=6)
    plt.minorticks_on()
    plt.grid(True, "major", "y", ls="-", lw=0.8, c="dimgray", alpha=0.5)
    plt.gca().set_facecolor(backgroundPlot)
    plt.tight_layout(rect=[0, 0, 1, 1])
    plt.show()