- 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 784 Articles for Data Visualization
![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)
637 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)
369 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
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
3K+ Views
To plot multiple line graphs using Pandas and Matplotlib, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Make a 2D potentially heterogeneous tabular data using Pandas DataFrame class, where the column are x, y and equation.Get the reshaped dataframe organized by the given index such as x, equation, and y.Use the plot() method to plot the lines.To display the figure, use show() method.Exampleimport 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([ ["y=x^3", 0, 0], ["y=x^3", 1, 1], ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
2K+ Views
To show multiple colorbars 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.Initialize a variable N for the number of sample data.Create random data1 using numpy.Display data as an image, i.e., on a 2D regular raster, with data1.Add a colorbar to a plot.Repeat steps 4, 5, and 6, with different datasets and axes.To display the figure, use show() method.Examplefrom matplotlib import pyplot as plt import numpy as np plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True fig, (ax1, ax2) = plt.subplots(nrows=2, ncols=1) N ... Read More