{"id":37451,"date":"2022-02-19T18:11:36","date_gmt":"2022-02-19T12:41:36","guid":{"rendered":"https:\/\/mcq-questions.com\/?p=37451"},"modified":"2022-02-21T15:46:02","modified_gmt":"2022-02-21T10:16:02","slug":"class-12-informatics-practices-notes-plotting-data-using-matplotlib","status":"publish","type":"post","link":"https:\/\/mcq-questions.com\/class-12-informatics-practices-notes-plotting-data-using-matplotlib\/","title":{"rendered":"Class 12 Informatics Practices Notes \u2013 Plotting Data Using Matplotlib"},"content":{"rendered":"
\u2192 Data Visualisation: It refers to the graphicalor visual representation of information and data using visual elements like charts, graphs and maps, etc. The purpose of plotting data is to visualize variation or show relationships between variables.<\/p>\n
\u2192 Pyplot of Matplotlib Library: The matplotlib is a Python library that provides many interfaces and functionality for 2D – graphics similar to MATLAB’s in various forms. It provides both a very quick way to visualize data from Python and publication – quality figures in many formats.<\/p>\n
\u2192 Pyplot: It is a collection of methods within matplotlib which allows. user to construct 2D plots easily and interactively.
\n<\/p>\n
\u2192 Installing and Importing Matplotlib: It can be installed using the following pip command from the command prompt:
\npip install matplotlib<\/p>\n
\u2192 For plotting using Matplotlib, we need to import its pyplot module using the following command:
\nimport matplotlib.pyplot as pit<\/p>\n
\u2192 Plot ( ): The pyplot module of matplotlib contains a collection of functions that can be used to work on a plot. The plot() function of the pyplot module is used to create a figure.<\/p>\n
\u2192 Figure: A figure is the overall window where the outputs of pyplot functions are plotted. A figure contains a Notes plotting area, legend, axis labels, ticks, title, etc.<\/p>\n
\u2192 Chart Types: We can create different types of graphs and charts using Pyplot. Some commonly used charts types are:<\/p>\n
\u2192 Line Chart: A line chart or line graph is a type of chart which displays information as a series of data points called ‘markers\u2019 connected by straight line segments. With pyplot, a line chart is created using plot() function.<\/p>\n
\u2192 Bar Chart: A bar chart or bar graph is a chart or graph that presents categorical data with rectangular bars with heights or lengths proportional to the values that they represent. The bars can be plotted vertically or horizontally. With pyplot, a bar chart is created using bar( ) and barh( ) functions.<\/p>\n
\u2192 Scatter Plot: The scatter plot is similar to a line chart, the major difference is that while line graph connects the data points with a line, scatter chart simply plots the data points to show the trend in the data. With pyplot, a scatter chart is created using scatter( ) function.<\/p>\n
\u2192 Pie Chart: A pie chart (or a circle chart) is a circular statistical graphic, which is divided into slices to illustrate numerical proportion. With pyplot, a pie chart is created using pie( ) function. But pie chart can plot only one data sequence unlike other chart types.<\/p>\n
\u2192 Histogram Plot: A histogram is a type of graph that provides a visual interpretation of numerical data by indicating the number
\nof data points that lie within a range of values. With pyplot, a histogram is created using hist( ) function.<\/p>\n
<\/p>\n
\u2192 Boxplot Chart: A boxplot is the visual representation of the statistical five number summary of a given data set. With pyplot, a boxplot is created using boxplot ( ) function.’<\/p>\n
\n
\n
\n
\n\u2192 List of pyplot functions to plot different charts:<\/p>\n
<\/p>\n
plot (\\*args[, scalex, scaley, data])<\/td>\n | Plot x versus y as lines and\/or markers. Make a bar plot.<\/td>\n<\/tr>\n | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
bar(x, height!, width, bottom, align, data])<\/td>\n | Make a bar plot.<\/td>\n<\/tr>\n | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
boxplot(x[, notch, sym, vert, whis, …])<\/td>\n | Make a box and whisker plot.<\/td>\n<\/tr>\n | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
hist(x[, bins, range, density, weights, …])<\/td>\n | Plot a histogram.<\/td>\n<\/tr>\n | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
pie(x[, explode, labels, colors, autopct, …])<\/td>\n | Plot a pie chart.<\/td>\n<\/tr>\n | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
scatter(x, y[, s, c, marker, cmap, norm, …])<\/td>\n | A scatter plot of x versus y.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n \u2192 Marker: A marker is any symbol that represents a data value in a line chart or a scatter plot. In other words, the data points being plotted on a graph\/chart are called markers.<\/p>\n
|