- 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)
416 Views
To control matplotlib marker orientation, we can use marker tuple that contains a number of sides, style and rotation or orientation of the marker.StepsSet the figure size and adjust the padding between and around the subplots.Create x and y data points using numpy.Make an array of 10 different rotations.Zip x, y and i. Iterate them and plot the points using plot() method with marker tuple.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.random.rand(10) y = np.random.rand(10) i = np.linspace(0, 10, 10) for x, ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
2K+ Views
To change the linewidth of a hatch in matplotlib, we can set the linewidth of the hatch in the params.StepsSet the figure size and adjust the padding between and around the subplots.Create x and y=sin(x) data points using numpy.Set the linewidth of the hatch in the plot.Plot x and y data points using scatter() method with a square marker having "/" hatches with set linewidth.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(-5, 5, 25) y = np.sin(x) plt.rcParams['hatch.linewidth'] = 1 plt.scatter(x, y, ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
779 Views
To add a custom border to certain cells in a Matplotlib/Seaborn plot.StepsSet the figure size and adjust the padding between and around the subplots.Create a dataframe with some columns.Plot a matrix dataset as a hierarchically-clustered heatmap.Get heatmap axis as a subplot arrangement.To add a custom border to certain cells in Matplotlib, we can intialize a variable, border_color.Using custom bordder color, add a rectangle patch on the heatmap axes.To display the figure, use show() method.Exampleimport pandas as pd from matplotlib import pyplot as plt import seaborn as sns plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True df = pd.DataFrame({"col1": [1, 4, 2, ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
1K+ Views
To just show the text label in plot legend we can use legend method with handlelength=0, handletextpad=0 and fancybox=0 in the arguments.StepsSet the figure size and adjust the padding between and around the subplots.Create random x and y data points using numpy.Create a figure and a set of subplots using subplots() method.Plot x and y data points using plot() method with label "Zig-Zag" for the legend.Use legend() method to place the label for the plot with handlelength=0, handletextpad=0 and fancybox=0 in the arguments.To display the figure, use show() method.Exampleimport numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
5K+ Views
To make a box plot for min, max, average and standard deviation in matplotlib, StepsSet the figure size and adjust the padding between and around the subplots.Create a random dataset of 5☓5 dimension.Find min, max, average and standard deviation from the data.Make a Pandas dataframe with Step 3, min, max, average and standard deviation data.Make a box plot from the dataframe column.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 data = np.random.randn(5, 5) min = data.min(0) max = data.max(0) avg = data.mean(0) std = data.std(0) df = ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
4K+ Views
To add a scatter of points to a boxplot using matplotlib, we can use boxplot() method and enumerate the Pandas dataframe to get the x and y data points to plot the scatter points.StepsSet the figure size and adjust the padding between and around the subplots.Make a dataframe using DataFrame class with the keys, Box1 and Box2.Make boxplots from the dataframe.Find x and y for the scatter plot using data (Step 1).To display the figure, use show() method.Exampleimport pandas as pd import numpy as np from matplotlib import pyplot as plt 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)
6K+ Views
To place the labels at the center in a histogram plot, we can calculate the mid-point of each patch and place the ticklabels accordinly using xticks() method.StepsSet the figure size and adjust the padding between and around the subplots.Create a random standard sample data, x.Initialize a variable for number of bins.Use hist() method to make a histogram plot.Calculate the list of ticks at the center of each patch.Make a list of tickslabels.Use xticks() method to place xticks and labels.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"] = ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
638 Views
To show the tick labels when sharing an axis, we can just use the subplot() method with sharey argument. By default, y ticklabels could be visible.StepsSet the figure size and adjust the padding between and around the subplots.Add a subplot to the current figure using subplot() method, where nrows=1, ncols=2 and index=1 for axis ax1.Plot a line on the axis 1.Add a subplot to the current figure, using subplot() method, where nrows=1, ncols=2 and index=2 for axis ax2.Plot a line on the axis 2.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"] ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
13K+ Views
To extract data from a plot in matplotlib, we can use get_xdata() and get_ydata() methods.StepsSet the figure size and adjust the padding between and around the subplots.Create y data points using numpy.Plot y data points with color=red and linewidth=5.Print a statment for data extraction.Use get_xdata() and get_ydata() methods to extract the data from the plot (step 3).Print x and y data (Step 5).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 y = np.array([1, 3, 2, 5, 2, 3, 1]) curve, = plt.plot(y, c='red', lw=5) print("Extracting ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
373 Views
To plot complex numbers using matplotlib, we can make a dataset with complex numbers.StepsSet the figure size and adjust the padding between and around the subplots.Create random complex numbers.Create a figure and a set of subplots using subplots() method.Plot the scatter points using scatter() 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 data = np.random.rand(10) + 1j*np.random.rand(10) fig, ax = plt.subplots() ax.scatter(data.real, data.imag, c=data.real, cmap="RdYlBu_r") plt.show()OutputRead More