Graphical Presentation of Data


Types of Variables: || Methods of Presenting Data:


Introduction

A method of analyzing numerical data is a graphical representation. In a diagram, it depicts the relationship between facts, ideas, information, and concepts. It is simple to comprehend and one of the most fundamental learning techniques. It is always dependent on the type of data in a given domain.

We can investigate the cause and effect relationship between two variables using graphs. Graphs assist in determining the magnitude of change in one variable when another changes by a given amount.

Types of Graphs

Graphical representations come in a variety of shapes and sizes. The following are a few of them:



  • Line Graph - A line graph, also known as a linear graph, is a type of graph that is used to depict continuous data and is effective for forecasting future occurrences across time.
  • For example, if you wish to visualize the hypothetical counts of covid-19 from the first eight months, you can do so with Python as shown below:

    Example:

    import matplotlib.pyplot as plt

    covid_count = [5, 15, 25, 50, 60, 80, 120, 230]
    Month = [1, 2, 3, 4, 5, 6, 7, 8]
    plt.plot(Month, covid_count, 'o-g')
    plt.xlabel("Month")
    plt.ylabel("covid_count")
    plt.title("Covid-19 count For First 8 Months")
    plt.show()
  • Bar Graph - The data is compared using solid bars to depict the amounts in a bar graph, which is used to display the category of data. These are usually simple to make and are used to illustrate either means (with suitable error bars), like in the graph to the right, or counts of some form, such as proportions or percentages.
  • For example, if you wish to visualize the hypothetical counts of students who uses different programming languages using bar chart with the aid of python is shown below:

    Example:

    #Create a Bar Chart
    import matplotlib.pyplot as plt
    fig = plt.figure()
    ax = fig.add_axes([0,0,1,1])
    lang_s = ['C++', 'C', 'Python', 'R', 'PHP']
    stud_count = [25,20,42,31,13]
    ax.bar(lang_s, stud_count)
    plt.show()
  • Scatter plot - Dots are used to indicate values for two different numeric variables in a scatter plot (also known as a scatter chart or scatter graph). The values for each data point are indicated by the position of each dot on the horizontal and vertical axes. Scatter plots are used to see how variables relate to one another.
  • For example, if you wish to visualize the hypothetical counts of sales and price of a certain Store X with the aid of python is shown below:

    Example:

    #Creating a Scatter Plot
    import matplotlib.pyplot as plt

    price = [1.55, 2.13, 3.12, 4.15, 6.10, 3.20]
    sales_per_day = [25, 56, 50, 25, 18, 21]

    plt.xlabel("price")
    plt.ylabel("sales_per_day")

    plt.scatter(price, sales_per_day)
    plt.show()


    Watch the video here:

  • Pie Chart - A pie chart is a form of graph that uses a circular graph to display data. The graph's parts are proportional to the percentage of the total in each group. In other words, the size of each slice of the pie is proportional to the size of the group as a whole. The full "pie" represents 100% of a whole, whereas the "slices" represent sections of the total.
  • Example:

    from matplotlib import pyplot as plt
    import numpy as np
    cars = ['HONDA', 'TOYOTA', 'FORD', 'TESLA', 'JAGUAR', 'FERRARI']
    counts = [250, 170, 350, 290, 102, 241]
    fig = plt.figure(figsize =(10, 7))
    plt.pie(counts, labels = cars, autopct='%1.1f%%')
    plt.show()
  • Stem-and-Leaf Plot - A stem and leaf plot is a specific table in which each data value is divided into a "stem" (the initial digit or digits) and a "leaf" (the last digit or digits) (usually the last digit). Is a method for classifying discrete and continuous variables.
  • Example:

    from collections import namedtuple
    from pprint import pprint as pp
    from math import floor

    Stem = namedtuple('Stem', 'data, leafdigits')
    assume = Stem((12, 127, 28, 42, 39, 113, 42, 18, 44, 118, 44, 37, 113, 124, 37,
    48, 127, 36, 29, 31, 125, 139, 131, 115, 105, 132, 104, 123, 35,
    113, 122, 42, 117, 119, 58, 109, 83, 105, 63, 27, 44, 105, 99,
    41, 128, 121, 116, 125, 32, 61, 37, 127, 29, 113, 121, 58, 114,
    126, 53, 114, 96, 25, 109, 31, 141, 46, 13, 27, 43, 117, 116,
    27, 68, 40, 31, 115, 124, 42, 128, 52, 71, 88, 117, 38, 27,
    106, 33, 117, 116, 111, 40, 119, 47, 105, 57, 122, 109, 124, 115, ), 1.0)

    def stemplot(stem):
    d = []
    interval = int(10**int(stem.leafdigits))
    for data in sorted(stem.data):
    data = int(floor(data))
    stm, lf = divmod(data,interval)
    d.append( (int(stm), int(lf)) )
    stems, leafs = list(zip(*d))
    stemwidth = max(len(str(x)) for x in stems)
    leafwidth = max(len(str(x)) for x in leafs)
    laststem, out = min(stems) - 1, []
    for s,l in d:
    while laststem < s:
    laststem += 1
    out.append('\n%*i |' % ( stemwidth, laststem))
    out.append(' %0*i' % (leafwidth, l))
    out.append('\n\nKey:\n Stem multiplier: %i\n X | Y => %i*X+Y\n'
    % (interval, interval))
    return ''.join(out)

    if __name__ == '__main__':
    print( stemplot(assume) )

    Thank you for Reading!


    Can you name other types of graphs? I'd love to hear your thoughts about the Types of Graphs. Feel free to leave your comment section below.


    References:

    https://byjus.com/maths/graphical-representation/
    https://www.sheffield.ac.uk/polopoly_fs/1.96442!/file/graphical-presentation-06-07.pdf
    https://www.toppr.com/guides/business-economics-cs/descriptive-statistics/graphic-presentation-of-data/
    https://chartio.com/learn/charts/what-is-a-scatter-plot/
    https://corporatefinanceinstitute.com/resources/knowledge/other/scatter-plot/

    Is this article useful to you?



    Types of Variables: | | Methods of Presenting Data:

    Post a Comment

    1 Comments

    1. Thank you for reading! Any thoughts about graphical method of presenting data. I'd love to hear your comment.

      ReplyDelete