Line Graph, Bar charts, Pie-charts, Scatter plots, multiple plots

Line Graph, Bar charts, Pie-charts, Scatter plots, multiple plots

Line Graph

  • Line graphs are used to visualize trends or changes over time.
  • They are created using the plt.plot() function in Matplotlib.
  • Labels and titles can be added to provide context and clarity.
Loading…
  • We define the data points for the x-axis and y-axis.Using plt.plot(), we plot the data points on the graph.
  • We add labels for the x-axis and y-axis using plt.xlabel() and plt.ylabel(), respectively.
  • We set a title for the graph using plt.title().Finally, we display the graph using plt.show().

Bar Chart

  • Bar charts are used to visually compare categorical data by displaying the magnitude of different categories.
  • In Matplotlib, bar charts are created using the plt.bar() function, which
  • allows for customization of the bar width and color to enhance the visualization.
Loading…

Pie Chart

  • Pie charts are used to visually display the proportion or percentage of each part
  • within a whole, providing a clear representation of the relative sizes of different components.
  • They are created using the plt.pie() function in Matplotlib.
Loading…

Scatter Plot

  • Scatter plots are used to graphically illustrate the correlation or relationship between two variables,
  • allowing for the visualization of patterns, trends, and associations between the variables.
  • They are created using the plt.scatter() function in Matplotlib.
Loading…

Multiple Plots

  • Multiple plots can be created in a single figure using the subplots() function.
  • Each subplot can have its own plot type and customization.
  • Spacing between subplots can be adjusted using plt.tight_layout().
Loading…
  • We create a figure and subplots using plt.subplots().
  • In this example, we create a figure with two subplots arranged horizontally.
  • We access each subplot using ax1 and ax2 and create different plots on each subplot.
  • We set titles for each subplot using ax1.set_title() and ax2.set_title().We adjust the spacing between subplots using plt.tight_layout().

Subplots

  • Subplots allow the creation of multiple plots within a single figure.
  • They are created using the plt.subplots() function in Matplotlib.
  • Subplots can be arranged in a grid-like structure.
Loading…
  • We define the data points for the x-axis and two different y-axis values (y1 and y2).
  • We create two lines on the same plot using plt.plot() and provide labels for each line using the label parameter.
  • We add labels and a title similar to the previous examples.
  • We add a legend to the plot using plt.legend(), which automatically uses the labels provided in the plot() function.

Legends

  • Legends provide a key to understand the different elements in a plot.
  • They are added to a plot using the plt.legend() function.
  • Legends automatically use the labels provided in the plotting functions.
Loading…
  • We define the data points for the x-axis and two different y-axis values (y1 and y2).
  • We create two lines on the same plot using plt.plot() and provide labels for each line using the label parameter.
  • We add labels and a title similar to the previous examples.
  • We add a legend to the plot using plt.legend(), which automatically uses the labels provided in the plot() function.

Changing Figure Size

  • The figure size can be adjusted using the figsize parameter in the plt.figure() function.
  • The figsize parameter in Matplotlib accepts a tuple of two values, which specify the width and height of the figure in inches.
  • Changing the figure size allows you to control the overall dimensions of the plot.
Example code:
Loading…

Styling Plots using Matplotlib Library

  • Matplotlib provides various built-in styles that can be applied to plots.
  • Styles can be set using the plt.style.use() function.
  • Some popular styles include 'default', 'ggplot', 'seaborn', and 'fivethirtyeight'.
  • Example code:
Loading…
  • In the first example, we use plt.figure(figsize=(8, 6)) to create a figure with a width of 8 inches and a height of 6 inches.
  • This allows us to control the size of the plot based on our requirements.
  • In the second example, we use plt.style.use('ggplot') to apply the 'ggplot' style to the plot.
  • The 'ggplot' style mimics the aesthetics of the ggplot2 library in R, providing a visually appealing and professional look to the plot.

Seaborn Library

  • Seaborn is a statistical visualization library that leverages Matplotlib to create informative and visually
  • appealing statistical graphics, offering a high-level interface for users to easily generate a wide range of statistical plots.
  • Seaborn integrates well with Pandas data structures and supports numpy and scipy.

Line Plot

  • Line plots in Seaborn are used to visualize trends and patterns in data over a continuous variable.
  • They are created using the sns.lineplot() function.
  • Example code:
Loading…

Dist Plot

  • Dist plots (distribution plots) in Seaborn are used to visualize the distribution of a univariate set of observations.
  • They are created using the sns.distplot() function.
  • Example code:
Loading…

Lmplot

  • Lmplot (regression plot) in Seaborn is used to plot data and regression model fits across a FacetGrid.
  • It is created using the sns.lmplot() function.
  • Example code:
Loading…

Count Plot

  • Count plots in Seaborn are used to show the counts of observations in each categorical bin using bars.
  • They are created using the sns.countplot() function.
Loading…

Color Palettes

  • Seaborn provides a variety of color palettes to enhance the aesthetics of your plots.
  • Color palettes can be set using the sns.set_palette() function.
Loading…

Conclusion

We have covered basics of Line Graph, Bar charts, Pie-charts, Scatter plots, multiple plots, Subplots, Legends, Functions like relplot(), displot() ,catplot ()
and Seaborn Library