- 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)
8K+ Views
To plot cdf in matplotlib in Python, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Initialize a variable N for the number of sample data.Create random data using numpy.Compute the histogram of a set of data with data and bins=10.Find the probability distribution function (pdf).Using pdf (Step 5), calculate cdf.Plot the cdf using plot() method with label "CDF".Place a legend on the plot.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 N = 500 ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
833 Views
To adjust the branch length of a dendrogram in Matplotlib, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Draw random samples (a and b) from a multivariate normal distribution.Join a sequence of arrays along an existing axis, using concatenate() method.Perform hierarchical/agglomerative clustering.Create a new figure or activate an existing figure using figure() method.Add an axes to the figure as part of a subplot arrangement.Plot the hierarchical clustering as a dendrogram using dendrogram() method.To display the figure, use show() method.Examplefrom matplotlib import pyplot as plt from scipy.cluster.hierarchy import dendrogram, linkage import ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
1K+ Views
To add bold annotated text in matplotlib, we can use LaTeX representation for labels.StepsSet the figure size and adjust the padding between and around the subplots.Create x and y data points using numpy.To set the label for each scattered point, make a list of labels.Plot xpoints, ypoints using scatter() method. For color, use xpoints.Iterate zipped labels, xpoints and ypoints.Use annotate() method with bold LaTeX representation insie the for loop.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 xpoints = np.linspace(1, 10, 10) ypoints = np.random.rand(10) labels ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
972 Views
To plot half or quarter polar plots in Matplotlib, 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 figure as part of a subplot arrangement.For half or quarter polar plots, use set_thetamax() method.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 fig = plt.figure() ax = fig.add_subplot(111, projection="polar") max_theta = 90 ax.set_thetamax(max_theta) plt.show()OutputRead More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
5K+ Views
To plot a point on 3D axes in Matplotlib, 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 figure as part of a subplot arrangement, with 3d projection.To plot a point in 3d axes, use scatter() method.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 fig = plt.figure() ax = fig.add_subplot(111, projection='3d') ax.scatter(2, 3, 4, c='red', marker='*', s=1000) plt.show()OutputRead More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
1K+ Views
To display a dataframe next to a plot, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Make a Pandas dataframe with straight and square keys.Create a new figure or activate an existing figure using figure() method.Add a subplot to the figure with nrows=1, cols=2 and index=1.Plot dataframe points using scatter() method.Add subplot to the figure with nrows=1, cols=2 and index=2.Initialize variables font_size, bbox to make a table.Turn off the current axes.Add a table to the current axis using table() method.To display the figure, use show() method.Exampleimport matplotlib.pyplot as plt import ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
201 Views
To plot histograms against classes in Pandas/Matplotlib, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Make a potentially hetrogeneous tabular data using Pandas dataframe.Make a histogram from the DataFrame values.To display the figure, use show() method.Examplefrom matplotlib import pyplot as plt import pandas as pd plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True df = pd.DataFrame({'a': [1, 1, 1, 1, 3],'b': [1, 1, 2, 1, 3],'c': [2, 2, 2, 1, 3], 'd': [2, 1, 2, 1, 3],}) df.hist() plt.show()Output
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
2K+ Views
To plot a bar chart with multiple labels in Matplotlib, we can take the following steps −Make some data set for men_means, men_std, women_means, and women_std.Make index data points using numpy.Initialize the width of the bars.Use subplots() method to create a figure and a set of subplots.Create rects1 and rects2 bars rectangle using bar() method.Use set_ylabel(), set_title(), set_xticks() and set_xticklabels() methods.Place a legend on the plot.Add multiple labels for bar chart using autolabel() method.To display the figure, use show() method.Exampleimport matplotlib.pyplot as plt import numpy as np plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True men_means, men_std = (20, ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
3K+ Views
To rotate axes label text in 3D matplotlib, we can use set_zlabel() method with rotation in the method's argument.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 a subplot to the current axis with projection="3d".Initialize a variable, angle, for an angle.Set Z-axis label using set_zlabel() method with a rotation.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 fig = plt.figure() ax = fig.add_subplot(111, projection='3d') angle = 45 ax.set_zlabel('Z-Axis', rotation=angle) plt.show()OutputRead More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
8K+ Views
To draw multiple legends on the same axes in Matplotlib, we can take the following steps −Set the figure size and adjust the padding between and around the subplotsPlot lines using two lists with different labels, linewidth and linestyle.Place the first legend at the upper-right location.Add artist, i.e., first legend on the current axis.Place the second legend on the current axis at the lower-right location.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 line1, = plt.plot([1, 2, 3], label="Line 1", linestyle='--') line2, = plt.plot([3, 2, 1], label="Line 2", ... Read More