• Coding

    Python: Matplotlib – How to use csv and subplots for beginners

    So how do I use subplots? 08/26/2018 The code below is custom to my csv file (see below), so make sure you either use the same format or change the "get_file" function to the properly process your file. MOCK_DATA_2 The file above looks like this: x,y 64,13 57,14 16,30 92,29 65,97 11,33 [sourcecode lang=”python”] from matplotlib.pyplot import * import numpy as np, os from typing import List #get file def get_file(filename: str): #determines validity of path #returns file content filepath = os.path.abspath(filename) if os.path.exists(filepath): fh = open(filepath) header = fh.readline() #excludes first row of the csv file e.g. x,y data = {"x":[],"y":[]} for row in fh.readlines(): if len(row) <= 0:…

  • Coding

    python: Creating a simple bar plot with python, matplotlib module and csv data

    This is so simple, it needs no heading.. 08/19/201810:10:49 PM Drinks Coffee as usual… Straight to the point: So this is the CSV data I will be working with ( generated using the website: https://mockaroo.com) MOCK_DATA Goal: Create a bar plot showing  the number of emails based on the alphabets they begin with . For instance, how many emails begin with “a” etc… This can be useful for visualizing emails from various email providers (e.g. yahoo, gmail, etc..).   [sourcecode lang=”python”] import csv, matplotlib.pyplot as plt, numpy as np filename = "MOCK_DATA.csv" def count_email(rows): dictionary = {} for row in rows: email = row[3] if email[0] not in dictionary: dictionary[email[0]] =…

error: Content is protected !!