Found 784 Articles for Data Visualization

Combining two heatmaps in seaborn

Rishikesh Kumar Rishi
Updated on 02-Feb-2022 10:08:49

6K+ 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

Boxplot stratified by column in Python Pandas

Rishikesh Kumar Rishi
Updated on 02-Feb-2022 10:06:50

361 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

How to plot aggregated by date pandas dataframe?

Rishikesh Kumar Rishi
Updated on 02-Feb-2022 10:01:27

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

How to vary the line color with data index for line graph in matplotlib?

Rishikesh Kumar Rishi
Updated on 02-Feb-2022 09:49:55

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

How can I format a float using matplotlib's LaTeX formatter?

Rishikesh Kumar Rishi
Updated on 01-Feb-2022 12:18:00

638 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

How to set local rcParams or rcParams for one figure in matplotlib?

Rishikesh Kumar Rishi
Updated on 01-Feb-2022 12:14:03

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

Plot multiple boxplots in one graph in Pandas or Matplotlib

Rishikesh Kumar Rishi
Updated on 13-Sep-2023 13:13:47

31K+ 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

How to plot a multivariate function in Python Matplotlib?

Rishikesh Kumar Rishi
Updated on 01-Feb-2022 12:05:11

6K+ 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

How to make a polygon radar (spider) chart in Python Matplotlib?

Rishikesh Kumar Rishi
Updated on 01-Feb-2022 11:57:55

2K+ Views

To make a polygon radar (spider) chart in Python, we can take the following steps −StepsSet the figure size and adjust the padding between and around the subplots.Create a Pandas dataframe with sports and values columns.Create a new figure or activate an existing figure.Add an 'ax' to the figure as part of a subplot arrangement.Based on data frame values, get the theta value.Get the values list of the data frame.Make a bar plot with theta and values data points.Fill the area between polygon.To display the figure, use show() method.Exampleimport pandas as pd import matplotlib.pyplot as plt import numpy as np ... Read More

Add a legend in a 3D scatterplot with scatter() in Matplotlib

Rishikesh Kumar Rishi
Updated on 01-Feb-2022 11:52:09

5K+ Views

To add a legend in a 3D scatterplot with scatter() 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; make z1 and z2 data points list.Add a subplot to the current figure, with projection='3d'.Plot the x, y and z1 data points using plot() points on 2d axes, with marker *.Plot the x, y and z2 data points using plot() points on 2d axes, with marker o.Place legend on the figure.To display the figure ... Read More

Advertisements