Ejemplo n.º 1
0
 def bar(self):
     print("Generating Bar Plot.....")
     plt.figure(figsize=(10, 5))
     sns.set(style="white", font_scale=1.5)
     splot = sns.barplot(
         x=[
             len(HTML().find_links()),
             len(search_clean),
             len(all_likes),
             len(all_links),
         ],
         y=["Watch", "Search", "Like", "Comment"],
         palette="Blues",
     )
     for p in splot.patches:
         width = p.get_width()
         splot.text(
             width,
             p.get_y() + p.get_height() / 2 + 0.1,
             "{:1.0f}".format(width),
             ha="left",
         )
     splot.grid(False)
     plt.title("Breakdown of Your Activity on Youtube",
               fontsize=24,
               color="steelblue",
               fontweight="bold",
               fontname="Comic Sans MS")
     plt.savefig(os.path.join(image_dir, "bar.png"), dpi=400)
     plt.clf()
Ejemplo n.º 2
0
    def heat_map(self):
        print("Generating Heat Map.....")
        html = HTML()
        Mon = html.dataframe_heatmap("Mon")
        Tue = html.dataframe_heatmap("Tue")
        Wed = html.dataframe_heatmap("Wed")
        Thu = html.dataframe_heatmap("Thu")
        Fri = html.dataframe_heatmap("Fri")
        Sat = html.dataframe_heatmap("Sat")
        Sun = html.dataframe_heatmap("Sun")
        df = np.vstack((Mon, Tue, Wed, Thu, Fri, Sat, Sun))

        print(df)
        Index = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
        Cols = [
            "0AM to 2AM",
            "2AM to 4AM",
            "4AM to 6AM",
            "6AM to 8AM",
            "8AM to 10AM",
            "10AM to 12PM",
            "12PM to 2PM",
            "2PM to 4PM",
            "4PM to 6PM",
            "6PM to 8PM",
            "8PM to 10PM",
            "10PM to 12AM",
        ]
        plt.figure(figsize=(20, 5))
        sns.heatmap(df,
                    cmap="Blues",
                    linewidths=2,
                    xticklabels=Cols,
                    yticklabels=Index)

        plt.title(
            "What Time Do You Usually Watch Youtube Videos? (Eastern Standard Time)",
            fontsize=27,
            color="steelblue",
            fontweight="bold",
            fontname="Arial",
        )

        plt.annotate(
            "             The plot above is based on a total of {:,}"
            " videos you have watched".format(len(HTML().find_links())),
            (0, 0),
            (0, -20),
            fontsize=20,
            color="steelblue",
            fontweight="bold",
            fontname="Arial",
            xycoords="axes fraction",
            textcoords="offset points",
            va="top",
        )

        plt.savefig(image_dir + "week_heatmap.png", dpi=400)
        plt.clf()
Ejemplo n.º 3
0
import numpy as np
import seaborn as sns
from matplotlib import pylab as pl
from PIL import Image
from PyPDF2 import PdfFileReader, PdfFileWriter
from reportlab.lib.styles import ParagraphStyle
from reportlab.lib.units import inch
from reportlab.pdfgen import canvas
from reportlab.platypus import Frame, Paragraph
from wordcloud import WordCloud

from parse import HTML

image_dir = os.path.join(os.getcwd(), "Images/")
logo = os.path.join(image_dir, "LOGO.png")
urls = HTML().find_links()
if (len(urls) == 0):
    raise ValueError(
        "Could not find any links. Please send the developer your takeout data, so the issue can be addressed"
    )
search_raw, search_clean = HTML().search_history()

try:
    link, all_links = HTML().comment_history()
except TypeError:
    link = all_links = ""

try:
    like, all_likes = HTML().like_history()
except FileNotFoundError:
    like = all_likes = ""