- 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)
300 Views
To plot the line color of a 3D parametric curve 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 axis as a subplot arrangement.To make a parametric curve, initialize theta, z, r, x and y variables.Plot x, y and z data points using scatter() method.Set the title of the plot.To display the figure, use show() method.Exampleimport numpy as np import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True fig = plt.figure() ax = fig.add_subplot(projection='3d') ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
675 Views
To display real-time graphs in a simple UI for a Python program, we can animate the contour plot.StepsSet the figure size and adjust the padding between and around the subplots.Create a random data of shape 10×10 dimension.Create a figure and a set of subplots using subplots() method.Make an animation by repeatedly calling a function *func*, using FuncAnimation() class.To update the contour value in a function, we can define a method, animate(), that can be used in FuncAnimation() class.To display the figure, use show() method.Exampleimport numpy as np import matplotlib.pyplot as plt import matplotlib.animation as animation plt.rcParams["figure.figsize"] = [7.50, 3.50] ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
3K+ Views
To show mean in a box plot, we can use showmeans=True in the argument of boxplot() method.StepsSet the figure size and adjust the padding between and around the subplots.Create a random dataset.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.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 data = np.random.rand(100, 5) fig = plt.figure() ax = fig.add_subplot(111) bp = ax.boxplot(data, 'd', showmeans=True) plt.show()OutputRead More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
519 Views
To shade points in a scatter based on colormap, we can use copper colormap in scatter() method.StepsSet the figure size and adjust the padding between and around the subplots.Create x and y random 100 data points using numpy.Plot scatter points x and y with color=x and colormap=copper.To display the figure, use show() method.Exampleimport numpy as np from matplotlib import pyplot as plt, cm plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True x = np.random.rand(100) y = np.random.rand(100) plt.scatter(x, y, c=x, cmap='copper') plt.show()Output
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
4K+ Views
To use custome png or jpg i.e an image as a marker in a plot, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Make a paths list to store the directories of images.Make a list (x and y) of points.Using subplots() method, create a figure and a set of subplots.To plot images instead of points, iterate zipped x, y and paths.Instantiate AnnotationBbox() with image and (x, y) points.Put xticks and yticks on both the axes.To display the figure, use show() method.Exampleimport matplotlib.pyplot as plt from matplotlib.offsetbox import OffsetImage, AnnotationBbox ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
5K+ Views
To plot a 3D continuous line in Matplotlib, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create x and y data points using numpy.Create z data points using x and y data points.Create a new figure or activate an existing figure using figure() method.Add an axes as a subplot arrangement with 3D projection.Plot x, y and z data points using plot() method.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 x = np.linspace(-4 * np.pi, 4 ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
2K+ Views
To animate a plot in matplotlib, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create a random data of shape 10X10 dimension.Create a figure and a set of subplots, using subplots() method.Makes an animation by repeatedly calling a function *func*, using FuncAnimation() class.To update the contour value in a function, we can define a method animate that can be used in FuncAnimation() class.To display the figure, use show() method.Exampleimport numpy as np import matplotlib.pyplot as plt import matplotlib.animation as animation plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True data = ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
836 Views
To change the color and marker of each point using Seaborn jointplot, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Load an example dataset from the online repository (requires Internet).Use jointplot() method to plot tips data.Use cla() method to clear the current axes.Make a list of colors and markers for each point.Set the axes labels using set_axis_labels() method.To display the figure, use show() method.Examplefrom matplotlib import pyplot as plt import seaborn as sns import numpy as np plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True tips = sns.load_dataset("tips") g ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
1K+ Views
To put text at the corner of an equal aspect figure in matplotlib, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create a figure and a set of subplots, using subplots() method.Create x data points using numpy.Plot x on axis ax1, using plot() method.Plot x and 2*x on ax2, using plot() method.To put text in the corner of a figure use annotate() method for different axes.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, axes = plt.subplots(2) x ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
408 Views
To add textures to bars and wedges 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.Make a list of hatches. Bars could be filled with some hatches.Create number bars as equivalent to number of hatches.Use bar() method to plot the bars with different hatch.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