- 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)
560 Views
To change the legend fontname in matplotlib, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create x data points using numpy.Plot x, sin(x) and cos(x) using plot() method.Use legend() method to place the legend.Iterate legend.get_texts() and update the legend fontname.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, 100) plt.plot(x, np.sin(x), label="$y=sin(x)$") plt.plot(x, np.cos(x), label="$y=cos(x)$") legend = plt.legend(loc='upper right') i = 1 for t in legend.get_texts(): ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
488 Views
To add units to a heatmap annotation in Seaborn, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create a 5×5 dimension matrix using numpy.Plot rectangular data as a color-encoded matrix.Annotate heatmap value with %age unit.To display the figure, use show() method.Exampleimport matplotlib.pyplot as plt import seaborn as sns import numpy as np plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True data = np.random.rand(5, 5) ax = sns.heatmap(data, annot=True, fmt='.1f', square=1, linewidth=1.) for t in ax.texts: t.set_text(t.get_text() + " %") plt.show()OutputRead More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
6K+ Views
To color a matplotlib scatterplot using continuous value, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create x, y and z random data points using numpy.Create a figure and a set of subplots.Create a scatter plot.Draw a colorbar in an existing axes, with scatter points scalar mappable instance.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 x, y, z = np.random.rand(3, 50) f, ax = plt.subplots() points = ax.scatter(x, y, c=z, s=50, cmap="plasma") f.colorbar(points) ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
3K+ Views
To make text alignment in a matplotlib legend, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create x data points using numpy.Plot x, sin(x) and cos(x) using plot() method.Place legend using legend() method and initialize a method.Iterate the legend.get_texts() method to set the horizontal alignment.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, 100) plt.plot(x, np.sin(x), label="$y=sin(x)$") plt.plot(x, np.cos(x), label="$y=cos(x)$") legend = plt.legend(loc='upper right') for t in ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
597 Views
To plot 3d plot_surface with contour plot projection, we can use plot_surface() and contourf() methods.StepsSet the figure size and adjust the padding between and around the subplots.Create x, y, X, Y and Z data points using numpy.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, with 3D projection.Use plot_surface() method to create a surface plot.Create a 3D filled contour plotm using contourf() method.Trurn off the axes.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] ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
5K+ Views
To add ticks to the colorbar, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create x, y and z data points using numpy.Use imshow() method to display the data as an image, i.e., on a 2D regular raster.Create ticks using numpy in the range of min and max of z.Create a colorbar for a ScalarMappable instance, *mappable*, with ticks=ticks.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 x, y = np.mgrid[-1:1:100j, -1:1:100j] z = (x + ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
3K+ Views
To change the font properties of a matplotlib colorbar label, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create x, y and z data points using numpy.Use imshow() method to display the data as an image, i.e., on a 2D regular raster.Create a colorbar for a ScalarMappable instance, *mappable*.Using colorbar axes, set the font properties such that the label is bold.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 x, y = np.mgrid[-1:1:100j, -1:1:100j] z = ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
5K+ Views
To draw a scatter trend line using matplotlib, we can use polyfit() and poly1d() methods to get the trend line points.StepsSet the figure size and adjust the padding between and around the subplots.Create x and y data points using numpy.Create a figure and a set of subplots.Plot x and y data points using numpy.Find the trend line data points using polyfit() and poly1d() method.Plot x and p(x) 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.random.rand(100) y ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
404 Views
To plot a hexbin histogram 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 a figure and a set of subplots.Plot x and y using hexbin() method.Set the title of 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 x = 2 * np.random.randn(5000) y = x + np.random.randn(5000) fig, ax = plt.subplots() _ = ax.hexbin(x[::10], y[::10], gridsize=20, cmap='plasma') ax.set_title('Hexbin Histogram') ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
3K+ Views
To plot a 2D histogram 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 a figure and a set of subplots.Plot x and y using hist2d() method.Set the title of 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 x = 2 * np.random.randn(5000) y = x + np.random.randn(5000) fig, ax = plt.subplots() _ = ax.hist2d(x[::10], y[::10]) ax.set_title('2D Histogram') plt.show()OutputRead More