- 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)
2K+ Views
To draw a line (i.e., arrow) outside of an axis, we can use annotate() method, 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.Clear the current figure.Add an '~.axes.Axes' to the figure as part of a subplot arrangement using add_subplot() method.Use annotate() method to place a line outside the axes.To display the figure, use show() method.Exampleimport matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True fig = plt.figure(1) fig.clf() ax = fig.add_subplot(1, 1, 1) ax.annotate('', xy=(0, -0.1), xycoords='axes fraction', xytext=(1, -0.1), ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
2K+ Views
To animate the colorbar 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.Add an '~.axes.Axes' to the figure as part of a subplot arrangement.Instantiate Divider based on the pre-existing axes, i.e., ax object and return a new axis locator for the specified cell.Create an axes at the given *position* with the same height (or width) of the main axes.Create random data using numpy.Use imshow() method to plot random data.Set the title of the plot.Instantiate the list of colormaps.To animate the ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
743 Views
To use multiple font sizes in one label in Python, we can use fontsize in title() method.StepsSet the figure size and adjust the padding between and around the subplots.Create x and y data points using numpy.Plot x and y using plot() method.Initialize a variable, fontsize.Set the title of the plot using title() method with fontsize in the argument.Turn 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] plt.rcParams["figure.autolayout"] = True x = np.linspace(-5, 5, 100) y = np.cos(x) plt.plot(x, y) fontsize = 20 ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
1K+ Views
To put the Origin at the center of the cos curve in a figure, 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.Set the position of the axes using spines, top, left, right and bottom.Plot x and y data points using plot() 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 = np.linspace(-5, 5, 100) y = np.cos(x) ax = plt.gca() ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
746 Views
To draw an arrow-like linestyle in matplotlib, we can use quiver() method.StepsSet the figure size and adjust the padding between and around the subplots.Create x and y data points using numpy.Use quiver() method to draw a line.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.linspace(-5, 5, 100) y = np.sin(x) plt.quiver(x[:-1], y[:-1], x[1:]-x[:-1], y[1:]-y[:-1], scale_units='xy', angles='xy', scale=1, color='red') plt.show()Output
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
706 Views
To plot a vector field over the axes in matplotlib, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Make X, Y, T, R, U and V data points using numpy.Add an axes to the current figure and make it the current axes.Plot a 3D field of arrows using quiver() method.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 n = 8 X, Y = np.mgrid[0:n, 0:n] T = np.arctan2(Y - n / 2., X - n/2.) ... Read More
How to plot two Pandas time series on the same plot with legends and secondary Y-axis in Matplotlib?
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
2K+ Views
To plot two Pandas time series on the sameplot with legends and secondary Y-axis, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create a one-dimensional ndarray with axis labels (including time series).Make a dataframe with some column list.Plot columns A and B using dataframe plot() method.Return the handles and labels for the legend using get_legend_handles_labels() method.Place a legend on the figure using legend() method.To display the figure, use show() method.Exampleimport pandas as pd from matplotlib import pyplot as plt import numpy as np 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)
170 Views
To work with quiver, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create vector cordinates using numpy array.Get x, y, u and v data points.Create a new figure or activate an existing figure using figure() method.Get the current axis using gca() method.Set x and y limit of the axes.To redraw the current figure, use draw() method.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 soa = np.array([[0, 0, 3, 2], [0, 0, 4, 5], [0, 0, ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
5K+ Views
To repress scientific notation in factorplot Y-axis in Seaborn/Matplotlib, we can use style="plain" in ticklabel_format()method.StepsSet the figure size and adjust the padding between and around the subplots.Make a dataframe with keys, col1 and col2.The factorplot() has been renamed to catplot().To repress the scientific notation, use style="plain" in ticklabel_format() method.To display the figure, use show() method.Examplefrom matplotlib import pyplot as plt import pandas as pd import seaborn as sns plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True df = pd.DataFrame({"col1": [1, 3, 5, 7, 1], "col2": [1, 5, 7, 9, 1]}) sns.catplot(y="col1", x="col2", kind='bar', data=df, label="Total", height=3.5) plt.ticklabel_format(style='plain', ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
3K+ Views
To make axes transparent 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 '~.axes.Axes' to the figure as part of a subplot arrangement.Set face color of the current axes.Add an axes to the figure.Create t and s data using numpy.Plot t and s data points using plot() method on axis 2 (from step 5).To make the axis transparent, use set_alpha() method and keep alpha value minimum.To display the figure, use show() method.Exampleimport matplotlib.pyplot as plt import ... Read More