1. Home
  2. Explore
  3. Computer Science
  4. Data Visualization with Python

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Data Visualization with Python

  • 32Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Data Visualization Basics

What is data visualization primarily described as?

32 questions

  1. 1

    What is data visualization primarily described as?

    1. A

      The method of summarizing data using statistical measures

    2. B

      The process of cleaning and organizing raw data

    3. C

      The technique of storing data in visual formats like images

    4. D

      The art of representing raw data in the form of beautiful and aesthetic graphs

    Correct answer
    D

    The art of representing raw data in the form of beautiful and aesthetic graphs

    Explanation

    The content defines data visualization as 'the art of representing the raw data in the form of beautiful and aesthetic graphs.'

  2. 2

    Why is data visualization important when working with large datasets?

    1. A

      It speeds up the data collection process

    2. B

      It automatically generates statistical summaries of the data

    3. C

      It reduces the size of the dataset by eliminating unnecessary columns

    4. D

      It helps to find interesting patterns and insights that are hard to see from raw data

    Correct answer
    D

    It helps to find interesting patterns and insights that are hard to see from raw data

    Explanation

    The content states that with a huge dataset, finding insights is extremely hard, and data visualization helps find interesting patterns from the data.

  3. 3

    In the example with mammoth and saber-tooth cat, what insight was easily obtained from the image?

    1. A

      The mammoth has a speed of 75 km/h

    2. B

      The saber-tooth cat has a speed of 25 km/h

    3. C

      The mammoth has a low aggressiveness and a size of 13,000 lbs

    4. D

      The saber-tooth cat is heavier than the mammoth

    Correct answer
    C

    The mammoth has a low aggressiveness and a size of 13,000 lbs

    Explanation

    The content mentions that from the image, the size of mammoth is 13,000 lbs and its aggressiveness is very low.

  4. 4

    What does Anscombe's quartet demonstrate?

    1. A

      That bar plots are better than histograms for numerical data

    2. B

      That averages and standard deviations are sufficient to understand data

    3. C

      That datasets with similar summary statistics can have very different graphical relationships

    4. D

      That all four datasets have identical distributions when plotted

    Correct answer
    C

    That datasets with similar summary statistics can have very different graphical relationships

    Explanation

    Anscombe's quartet shows four datasets with nearly identical sum, average, and standard deviation, but when plotted, the relationships between x and y are very different.

  5. 5

    Which of the following is NOT a Python visualization library mentioned?

    1. A

      GG plot

    2. B

      Matplotlib

    3. C

      Plotly

    4. D

      D3.js

    Correct answer
    D

    D3.js

    Explanation

    The content lists matplotlib, GG plot, plotly, plot lab, and seaborn. D3.js is a JavaScript library, not Python.

  6. 6

    How do you import the matplotlib pyplot module in Python?

    1. A

      import pyplot as plt

    2. B

      import matplotlib.pyplot as plot

    3. C

      from matplotlib import pyplot as pl

    4. D

      import matplotlib.pyplot as plt

    Correct answer
    D

    import matplotlib.pyplot as plt

    Explanation

    The content uses 'import matplotlib.pyplot as plt'.

  7. 7

    Which method is used to display a plot in matplotlib?

    1. A

      plt.output()

    2. B

      plt.display()

    3. C

      plt.show()

    4. D

      plt.print()

    Correct answer
    C

    plt.show()

    Explanation

    The content consistently uses plt.show() to display the plot.

  8. 8

    What is the correct way to create a simple line plot in matplotlib?

    1. A

      plt.graph(x, y)

    2. B

      plt.chart(x, y)

    3. C

      plt.plot(x, y)

    4. D

      plt.line(x, y)

    Correct answer
    C

    plt.plot(x, y)

    Explanation

    The content uses plt.plot(x, y) to create a line plot.

  9. 9

    How can you change the color of a line in a line plot?

    1. A

      By using the 'linecolor' attribute

    2. B

      By calling plt.color('red') before plotting

    3. C

      By passing a string argument to plt.style()

    4. D

      By setting the 'color' parameter in plt.plot()

    Correct answer
    D

    By setting the 'color' parameter in plt.plot()

    Explanation

    The content shows plt.plot(x, y, color='red') to change the line color.

  10. 10

    Which method adds a title to the current plot?

    1. A

      plt.header('Title')

    2. B

      plt.set_title('Title')

    3. C

      plt.title('Title')

    4. D

      plt.title('Title')

    Correct answer
    C

    plt.title('Title')

    Explanation

    The content uses plt.title('Line Plot') to add a title.

  11. 11

    How do you set labels for the x-axis and y-axis?

    1. A

      plt.xlabel() and plt.ylabel()

    2. B

      plt.xlabel() and plt.ylabel()

    3. C

      plt.label(x='axis') and plt.label(y='axis')

    4. D

      plt.x_label() and plt.y_label()

    Correct answer
    B

    plt.xlabel() and plt.ylabel()

    Explanation

    The content uses plt.xlabel() and plt.ylabel().

  12. 12

    What is the purpose of the plt.subplot() method?

    1. A

      To embed a plot inside another plot

    2. B

      To add a subtitle to the plot

    3. C

      To create multiple plots in the same figure

    4. D

      To split a plot into smaller segments

    Correct answer
    C

    To create multiple plots in the same figure

    Explanation

    The content uses plt.subplot() to create two subplots in the same figure.

  13. 13

    What does the first argument in plt.subplot(nrows, ncols, index) represent?

    1. A

      The total number of subplots

    2. B

      The number of columns

    3. C

      The index of the active subplot

    4. D

      The number of rows

    Correct answer
    D

    The number of rows

    Explanation

    The content explains that the first parameter is the number of images in the rows, so nrows.

  14. 14

    Which plot type is used for categorical data?

    1. A

      Histogram

    2. B

      Scatter plot

    3. C

      Line plot

    4. D

      Bar plot

    Correct answer
    D

    Bar plot

    Explanation

    The content states that a bar plot is used for categorical values and a histogram is used for numerical values.

  15. 15

    What is the difference between a bar plot and a histogram?

    1. A

      Bar plots have spaces between bars, histograms do not

    2. B

      Bar plots are horizontal, histograms are vertical

    3. C

      Bar plots are for categorical data, histograms are for numerical data

    4. D

      Bar plots show distribution while histograms show trends

    Correct answer
    C

    Bar plots are for categorical data, histograms are for numerical data

    Explanation

    The content explicitly says that a bar plot is used for categorical values and a histogram for numerical values.

  16. 16

    How do you create a horizontal bar plot in matplotlib?

    1. A

      plt.barh()

    2. B

      plt.hbar()

    3. C

      plt.bar(horizontal=True)

    4. D

      plt.bar(orient='horizontal')

    Correct answer
    A

    plt.barh()

    Explanation

    The content mentions plt.barh() for horizontal bar plots.

  17. 17

    Which method is used to create a scatter plot?

    1. A

      plt.scatter()

    2. B

      plt.point()

    3. C

      plt.dots()

    4. D

      plt.plot() with 'o' marker

    Correct answer
    A

    plt.scatter()

    Explanation

    The content uses plt.scatter() to create scatter plots.

  18. 18

    How can you change the size of points in a scatter plot?

    1. A

      By setting the 's' parameter

    2. B

      By setting the 'markersize' parameter

    3. C

      By setting the 'size' parameter

    4. D

      By setting the 'pointsize' parameter

    Correct answer
    A

    By setting the 's' parameter

    Explanation

    The content uses s parameter to change the size of points, e.g., plt.scatter(x, a, s=200).

  19. 19

    Which parameter changes the marker shape in a scatter plot?

    1. A

      symbol

    2. B

      shape

    3. C

      style

    4. D

      marker

    Correct answer
    D

    marker

    Explanation

    The content uses marker parameter to change the shape, e.g., marker=3 or marker=1.

  20. 20

    How do you change the overall figure size in matplotlib?

    1. A

      plt.set_size(width, height)

    2. B

      plt.figure(figsize=(width, height))

    3. C

      plt.resize(width, height)

    4. D

      plt.figsize(width, height)

    Correct answer
    B

    plt.figure(figsize=(width, height))

    Explanation

    The content uses plt.figure(figsize=(10,10)) to change figure size.

  21. 21

    What does a histogram show?

    1. A

      The distribution of a numerical dataset

    2. B

      The comparison of categorical quantities

    3. C

      The relationship between two variables

    4. D

      The change over time

    Correct answer
    A

    The distribution of a numerical dataset

    Explanation

    The content states that a histogram gives the distribution of the data.

  22. 22

    How can you change the number of bins in a histogram?

    1. A

      By setting the 'intervals' parameter

    2. B

      By setting the 'columns' parameter

    3. C

      By setting the 'groups' parameter

    4. D

      By setting the 'bins' parameter in plt.hist()

    Correct answer
    D

    By setting the 'bins' parameter in plt.hist()

    Explanation

    The content uses bins=30 to change the number of bins.

  23. 23

    In a box plot, what does the line inside the box represent?

    1. A

      The mode

    2. B

      The mean

    3. C

      The first quartile

    4. D

      The median

    Correct answer
    D

    The median

    Explanation

    The content says 'this line which you see at the center of the box this basically denotes the median value'.

  24. 24

    What is the main difference between a box plot and a violin plot?

    1. A

      Box plots are used for categorical data, violin plots for numerical data

    2. B

      Violin plots are always horizontal

    3. C

      Box plots show mean, violin plots show median

    4. D

      The shape: box plot looks like a box, violin plot looks like a violin

    Correct answer
    D

    The shape: box plot looks like a box, violin plot looks like a violin

    Explanation

    The content states 'the only difference between a box plot and a violin plot is that the shape is different. Box plot looks like a box and the violin plot looks like a violin'.

  25. 25

    Which arguments can show the median and mean in a violin plot?

    1. A

      showmedian and showmean

    2. B

      show_median and show_mean

    3. C

      median and mean

    4. D

      showmedians and showmeans

    Correct answer
    D

    showmedians and showmeans

    Explanation

    The content uses showmedians=True and showmeans=True.

  26. 26

    How do you add a grid to a plot?

    1. A

      plt.grid(True)

    2. B

      plt.gridline(True)

    3. C

      plt.axis('grid')

    4. D

      plt.showgrid()

    Correct answer
    A

    plt.grid(True)

    Explanation

    The content uses plt.grid(True) to add a grid.

  27. 27

    Which parameter in plt.pie() adds percentage labels?

    1. A

      labelpct

    2. B

      showpercent

    3. C

      autopct

    4. D

      percent

    Correct answer
    C

    autopct

    Explanation

    The content uses autopct='%0.1f%%' to add percentages.

  28. 28

    How do you highlight a slice in a pie chart?

    1. A

      By setting the 'separate' parameter

    2. B

      By setting the 'explode' parameter

    3. C

      By setting the 'highlight' parameter

    4. D

      By setting the 'pull' parameter

    Correct answer
    B

    By setting the 'explode' parameter

    Explanation

    The content uses explode parameter to separate a slice.

  29. 29

    How is a donut plot created in matplotlib?

    1. A

      By using plt.bar() with circular coordinates

    2. B

      By overlaying a white pie chart with smaller radius on top of a colored pie chart

    3. C

      By using plt.donut() method

    4. D

      By setting the 'donut' parameter in plt.pie()

    Correct answer
    B

    By overlaying a white pie chart with smaller radius on top of a colored pie chart

    Explanation

    The content creates a donut plot by making two pie charts: one colored with radius 2 and a white one with radius 1 on top.

  30. 30

    Which method is used to create an area plot?

    1. A

      plt.polygon()

    2. B

      plt.fill()

    3. C

      plt.area()

    4. D

      plt.stackplot()

    Correct answer
    D

    plt.stackplot()

    Explanation

    The content uses plt.stackplot() to create an area plot.

  31. 31

    How can you add a line plot on top of an area plot?

    1. A

      By using plt.overlay() method

    2. B

      By using plt.plot() with the same x and y values after the area plot

    3. C

      By using plt.line() after the area plot

    4. D

      By setting the 'line' parameter in plt.stackplot()

    Correct answer
    B

    By using plt.plot() with the same x and y values after the area plot

    Explanation

    The content shows that after the area plot, you can call plt.plot(x, y, color='green') to add a line on top.

  32. 32

    To change colors in a pie chart, what parameter is used?

    1. A

      colormap

    2. B

      colors

    3. C

      color

    4. D

      palette

    Correct answer
    B

    colors

    Explanation

    The content uses colors parameter, e.g., colors=['black','gray','yellow','green'].

Question 1 of 32
Question 1 of 32

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent