- 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)
43K+ Views
To label a line in matplotlib, we can use label in the argument of plot() method,StepsSet the figure size and adjust the padding between and around the subplots.Plot with label="line1" using plot() method.Plot with label="line2" using plot() method.To place a legend on the figure, use legend() 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 line1, = plt.plot([1, 2, 3], label="line1") line2, = plt.plot([3, 2, 1], label="line2") leg = plt.legend(loc='upper center') plt.show()Output
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
2K+ Views
To customize the axis label in a Seaborn jointplot, we can take the following stepsSet the figure size and adjust the padding between and around the subplots.Create x and y data points using numpy.Use jointplot() method to plot a joint plot in Seaborn.To set the customized axis label, we can use LaTex representation or set_xlabel() method properties.To display the figure, use show() method.Exampleimport seaborn as sns import 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.randn(1000, ) y = 0.2 * np.random.randn(1000) + 0.5 h = sns.jointplot(x, y, height=3.50) h.ax_joint.set_xlabel('$\bf{X-Axis\ ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
4K+ Views
To remove the space between subplots in matplotlib, we can use GridSpec(3, 3) class and add axes as a subplot arrangement.StepsSet the figure size and adjust the padding between and around the subplots.Add a grid layout to place subplots within a figure.Update the subplot parameters of the gridIterate in the range of dimension of grid specs.Add a subplot to the current figure.Set the aspect ratios.To display the figure, use show() method.Exampleimport matplotlib.pyplot as plt import matplotlib.gridspec as gridspec plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True gs1 = gridspec.GridSpec(3, 3) gs1.update(wspace=0.5, hspace=0.1) for i in range(9): ax1 = plt.subplot(gs1[i]) ax1.set_aspect('equal') plt.show()OutputRead More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
3K+ Views
To align rows in a matplotlib legend with 2 columns, we can take the following stepsSet the figure size and adjust the padding between and around the subplots.Using plot() method, plot lines with the labels line1, line2 and line3.Place a legend on the figure with two columns. Use ncol=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"] = True plt.plot([1, 2, 3], label="line1") plt.plot([3, 2, 1], label="line2") plt.plot([2, 3, 1], label="line3") plt.legend(ncol=2, loc="upper right") plt.show()Output
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
2K+ Views
To animate text in a plot, we can take the following stepsSet the figure size and adjust the padding between and around the subplots.Set x and y axis limit.Initialize a variable, string.Use text() method to place text over the plot.Use FuncAnimation() to animate the text. Set text on the text axis.Turn off the axes.To display the figure, use show() method.Examplefrom matplotlib import pyplot as plt, animation plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True fig, ax = plt.subplots() ax.set(xlim=(-1, 1), ylim=(-1, 1)) string = 'Hello, how are you doing?' label = ax.text(0, 0, string[0], ha='center', va='center', fontsize=20, color="Red") def animate(i): ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
21K+ Views
To increase the space for X-axis labels in Matplotlib, we can use the spacing variable in subplots_adjust() 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.Create x and y data points using numpy.Plot x and y using plot() method.Put xlabel using xlabel() method with LaTex expression.Use subplots_adjust() method to increase or decrease the space for X-axis labelsTo 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 fig = plt.figure() x = ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
8K+ Views
To set Dataframe column value as X-axis labels in Python Pandas, we can use xticks in the argument of plot() method.StepsSet the figure size and adjust the padding between and around the subplots.Make a dataframe using Pandas with column1 key.Plot the Pandas dataframe using plot() method with column1 as the X-axis column.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 data = pd.DataFrame({"column1": [4, 6, 7, 1, 8]}) data.plot(xticks=data.column1) plt.show()Output
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
686 Views
To plot a color wheel based on a colormap using Python/Matplotlib, we can use the colorbar class and can use copper colormap.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 an axes to the figure using add_axes() method.Set the direction of the axes.Linearly normalize the data using Normalize class.Draw a colorbar in an existing axes.Set the artist's visibility.Turn the X- and Y-axis off.To display the figure, use show() method.Exampleimport numpy as np from matplotlib import pyplot as plt, cm, colors, colorbar 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)
1K+ Views
We can plot statsmodels linear regression (OLS) with a non-linear curve but with linear data.StepsSet the figure size and adjust the padding between and around the subplots.To create a new one, we can use seed() method.Initialize the number of sample and sigma variables.Create linear data points x, X, beta, t_true, y and res using numpy.Res is an ordinary Least Square class instance.Calculate the standard deviation. Confidence interval for prediction applies to WLS and OLS, not to general GLS, that is, independently but not identically distributed observations.Create a figure and a set of subplots using subplot() method.Plot all the curves using ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
21K+ Views
To show all X coordinates (or Y coordinates), we can use xticks() method (or yticks()).StepsSet the figure size and adjust the padding between and around the subplots.Create x and y data points using numpy.Set x=0 and y=0 margins on the axes.Plot x and y data points using plot() method.Use xticks() method to show all the X-coordinates in the plot.Use yticks() method to show all the Y-coordinates in 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 x = np.arange(0, 10, 1) y =np.arange(0, 10, 1) plt.margins(x=0, y=0) ... Read More