- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 1034 Articles for Matplotlib
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
9K+ Views
To hide the colorbar of a Seaborn heatmap, we can use cbar=False in heatmap() method.StepsSet the figure size and adjust the padding between and around the subplots.Make a dataframe using 4 columns.Use heatmap() method to plot rectangular data as a color-encoded matrix.To display the figure, use show() method.Exampleimport seaborn as sns import pandas as pd import numpy as np import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True df = pd.DataFrame(np.random.random((4, 4)), columns=["a", "b", "c", "d"]) sns.heatmap(df, cbar=False) plt.show()Output
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
739 Views
To set active subplot axes object in matplotlib, we can use subplots() method to add the axes as a subplot arrangement.StepsSet the figure size and adjust the padding between and around the subplots.Create x and y lists for data points.Create a figure and a set of subplots using subplots() method with one row and two columns.Add an axes to the current figure and make it the current axes, with axis object at the 0th index.Plot x and y data points using plot() method.Add an axes to the current figure and make it the current axes, with axis object at the ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
2K+ Views
To insert a scale bar in a map in matplotlib, we can use AnchoredBar() class to instantiate the scalebar object.StepsSet the figure size and adjust the padding between and around the subplots.Create random data using numpy.Use imshow() method to display data as an image, i.e., on a 2D regular raster.Get the current axis using gca() method.Draw a horizontal scale bar with a center-aligned label underneath.Add a scalebar artist to the current axis.Turn off the axes.To display the figure, use show() mthod.Examplefrom matplotlib import pyplot as plt from mpl_toolkits.axes_grid1.anchored_artists import AnchoredSizeBar import numpy as np plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
1K+ Views
To plot gamma distribution with alpha and beta parameters in Python, we can use gamma.pdf() function.StepsSet the figure size and adjust the padding between and around the subplots.Create x using numpy and y using gamma.pdf() function at x of the given RV.Plot x and y data points using plot() method.Use legend() method to place the legend elements for the plot.To display the figure, use show() method.Exampleimport numpy as np import scipy.stats as stats from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True x = np.linspace(0, 10, 10) y = stats.gamma.pdf(x, a=5, scale=0.333) plt.plot(x, ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
1K+ Views
To change the fontsize of scientific notation in matplotlib, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Make a list of x and y values.Plot x and y data points using plot() method.To change the font size of scientific notation, we can use style="sci" class by name.To display the figure, use show() method.Examplefrom matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True x = [10000, 20000, 300000, 34, 1, 10000] y = [1, 2, 0, 4, 1, 5] plt.plot(x, y, color='red') plt.ticklabel_format(axis="x", style="sci", scilimits=(0, ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
1K+ Views
To plot hatches bars using Pandas, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Make a dataframe using Pandas with two columns.Add an axes to the current figure as a subplot arrangement.Make a plot with kind="bars" class by name.Make a list of hatches.Get the bars patches using bars.patches.Iterate bars patches and set the hatch of each patch.To display the figure, use show() method.Exampleimport numpy as np import pandas as pd from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True df = pd.DataFrame(np.random.rand(5, 2), columns=['a', ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
2K+ Views
To surface plot/3d, we would require 2D data points, not 1D dataframe.StepsSet the figure size and adjust the padding between and around the subplots.Create a new figure or activate an existing figure using figure() method.Add an '~.axes.Axes' to the figure as part of a subplot arrangement using add_subplot() method.Initialize a variable 'n' for the number of samples.Create x, y and z data points using numpy.Use plot_surface() method to make surface 3d.To display the figure, use show() method.Exampleimport numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True fig = plt.figure() ax = ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
2K+ Views
To show different colors for points and line in a Seaborn regplot, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Make a Pandas dataframe with key X-axis and Y-axis.Plot numeric independent variables with regression model.To display the figure, use show() method.Exampleimport pandas import matplotlib.pylab as plt import seaborn as sns import numpy as np plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True df = pandas.DataFrame({"X-Axis": [np.random.randint(5) for i in range(10)], "Y-Axis": [np.random.randint(5) for i in range(10)]}) sns.regplot(x='X-Axis', y='Y-Axis', data=df, scatter_kws={"color": "red"}, line_kws={"color": "green"}) plt.show()OutputRead More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
3K+ Views
To render 3D histograms in Python, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create a new figure or activate an existing figure using figure() method.Add an axes to the cureent figure as a subplot arrangement.Create x3, y3 and z3 data points using numpy.Create dx, dy and dz data points using numpy.Use bar3d() method to plot 3D bars.To hide the axes use axis('off') class by name.To display the figure, use show() method.Exampleimport numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
3K+ Views
To add a legend to a matplotlib boxplot with multiple plots on the same axis, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create random data, a and b, using numpy.Create a new figure or activate an existing figure using figure() method.Add an axes to the current figure as a subplot arrangement.Make a box and whisker plot using boxplot() method with different facecolors.To place the legend, use legend() method with two boxplots, bp1 and bp2, and ordered label for legend elements.To display the figure, use show() method.Exampleimport matplotlib.pyplot as plt ... Read More