- 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
439 Views
To create multiple series scatter plots with connected points using seaborn, we can take the following steps −StepsSet the figure size and adjust the padding between and around the subplots.Create a Pandas data frame of two-dimensional, size-mutable, potentially heterogeneous tabular data.Multi-plot grid for plotting conditional relationships.Apply a plotting function to each facet's subset of the data.Plot the scatter and the data points with x and y data points.To display the figure, use show() method.Exampleimport pandas as pd import seaborn as sns from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True df = pd.DataFrame({"x": [4, ... Read More
315 Views
To make a histogram with bins of equal area in matplotlib, we can take the following steps −StepsSet the figure size and adjust the padding between and around the subplots.Create random data points using numpy.Plot a histogram with equal_area method that makes an equal area of the patches.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 def equal_area(x, nbin): pow = 0.5 dx = np.diff(np.sort(x)) tmp = np.cumsum(dx ** pow) tmp = np.pad(tmp, (1, 0), 'constant') return np.interp(np.linspace(0, tmp.max(), ... Read More
5K+ Views
To combine two heatmaps in seaborn, we can take the following steps −StepsSet the figure size and adjust the padding between and around the subplots.Create two Pandas data frames.Create a figure and a set of subplots, ax1 and ax2.Plot the rectangular data as a color-encoded matrix, on ax1 and ax2.Move ticks and ticklabels (if present) to the right of the axes.Keep the width of the padding between subplots minimum, as a fraction of the average axes width.To display the figure, use show() method.Exampleimport matplotlib.pyplot as plt import numpy as np import pandas as pd import seaborn as sns plt.rcParams["figure.figsize"] ... Read More
340 Views
To create a boxplot stratified by column in Python class, we can take the following steps −StepsSet the figure size and adjust the padding between and around the subplots.Create a Pandas data frame of two-dimensional, size-mutable, potentially heterogeneous tabular data.Compute the histogram of a set of data.Create a boxplot startified by column.To display the figure, use show() method.Exampleimport pandas as pd import numpy as np from matplotlib import pyplot as plt # Set the figure size plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True # Pandas dataframe df = pd.DataFrame({"column1": [4, 6, 7, 1, 8], "column2": [1, 5, 7, ... Read More
1K+ Views
To plot aggregated by date pandas dataframe, we can take the following steps −StepsSet the figure size and adjust the padding between and around the subplots.Create a data frame, df, of two-dimensional, size-mutable, potentially heterogeneous tabular data.Get the values of aggregated by date pandas dataframe.Plot the df (Step 3) with kind="bar".To display the figure, use show() method.Exampleimport numpy as np import pandas as pd from matplotlib import pyplot as plt, dates # Set the figure size plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True # Create a dataframe df = pd.DataFrame(dict(data=list(pd.date_range("2021-01-01", periods=10)), value=np.linspace(1, 10, 10))) df = df.groupby('data').agg(['sum']).reset_index() ... Read More
2K+ Views
To have the line color vary with the data index for a line graph in matplotlib, we can take the following steps −StepsSet the figure size and adjust the padding between and around the subplots.Create x and y data points using numpy.Get smaller limit, dydx.Get the points and segments data points using numpy.Create a figure and a set of subplots.Create a class which, when called, linearly normalizes data into some range.Set the image array from numpy array *A*.Set the linewidth(s) for the collection.Set the colorbar for axis 1.Generate Colormap object from a list of colors i.e r, g and b.Repeat ... Read More
605 Views
To format a float using matplotlib's LaTeX formatter, we can take the following steps −StepsSet the figure size and adjust the padding between and around the subplots.Create x and y data points using numpy.Plot the x and y data points using plot() method.Fill the area between the curve.Set the title of the figure with LaTeX representation.To display the figure, use show() method.Exampleimport numpy as np from matplotlib import pyplot as plt # Set the figures size plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True # x and y data points x = np.linspace(-5, 5, 100) y = x**3/3 ... Read More
2K+ Views
To set local rcParams or rcParams for one figure in matplotlib, we can take the following steps −StepsSet the figure size and adjust the padding between and around the subplots.Initialize a variable N to store the number of sample data.Create x and y data points using numpy.Return a context manager for temporarily changing rcParams.Add a subplot to the current figure, at index 1.Plot the x and y data points, using plot() method.Add a subplot to the current figure, at index 2.Plot the x and y data points, using plot() method.To display the figure, use show() method.Exampleimport pandas as pd import ... Read More
29K+ Views
To plot multiple boxplots in one graph in Pandas or Matplotlib, we can take the following steps −StepsSet the figure size and adjust the padding between and around the subplots.Make a Pandas data frame with two columns.Plot the data frame using plot() method, with kind='boxplot'.To display the figure, use show() method.Exampleimport pandas as pd import numpy as np from matplotlib import pyplot as plt # Set the figure size plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True # Pandas dataframe data = pd.DataFrame({"Box1": np.random.rand(10), "Box2": np.random.rand(10)}) # Plot the dataframe ax = data[['Box1', 'Box2']].plot(kind='box', title='boxplot') # Display ... Read More
5K+ Views
To plot a multivariate function in Python, we can take the following steps −StepsSet the figure size and adjust the padding between and around the subplots.Create random x, y and z data points using numpy.Create a figure and a set of subplots.Create a scatter plot with x, y and z data points.Create a colorbar for a ScalarMappable instance, s.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 def func(x, y): return 3 * x + 4 * y - 2 + np.random.randn(30) x, y ... Read More