Rishikesh Kumar Rishi has Published 1162 Articles

How can I make a simple 3D line with Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 08-May-2021 08:33:32

199 Views

To make a simple 3D line with matplotlib, we can take the following steps −Create a new figure or activate an existing figure.Add axes to the figure as part of a subplot arrangement.Create data points for theta, z, r, x and y using numpy.Plot x, y and z using plot() method.Place ... Read More

How to plot multiple histograms on same plot with Seaborn using Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 08-May-2021 08:31:28

4K+ Views

To plot multiple histograms on same plot with Seaborn, we can take the following steps −Create two lists (x and y).Create a figure and add a set of two subplots.Iterate a list consisting of x and y.Plot a histogram with histplot() method using the data in the list (step 3).Limit ... Read More

How to change the color of a plot frame in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 08-May-2021 08:30:42

4K+ Views

To change the color of a plot frame, we can set axes ticklines and spine value into a specific color.StepsCreate a figure and add a set of subplots, using subplots method with value 4.Zip colors with axes and iterate them together.In the iteration, set the color for spines values and ticklines ... Read More

How does one insert statistical annotations (stars or p-values) into Matplotlib plots?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 07-May-2021 08:16:37

238 Views

To insert statistical annotation, we can take the following steps −Create lists (x and y) of numbers.Using subplots() method, create a figure and a set of subplots.Using plot() method, plot the data that contains dates with linestyle "-.".Annotate a point in the plot using annotate() method, mean of x and y.To display ... Read More

Annotate Time Series plot in Matplotlib

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 07-May-2021 08:16:15

916 Views

To annotate time series plot in matplotlib, we can take the following steps −Create lists for time and numbers.Using subplots() method, create a figure and a set of subplots.Using plot_date() method, plot the data that contains dates with linestyle "-.".Annotate a point in the plot using annotate() method.Date ticklabels often overlap, so it ... Read More

Annotate data points while plotting from Pandas DataFrame

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 07-May-2021 08:11:45

3K+ Views

To annotate data points while plotting from pandas data frame, we can take the following steps −Create df using DataFrame with x, y and index keys.Create a figure and a set of subplots using subplots() method.Plot a series of data frame using plot() method, kind='scatter', ax=ax, c='red' and marker='x'.To annotate the ... Read More

How to fill color below a curve in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 07-May-2021 08:10:56

9K+ Views

To fill color below a curve, we can take the following steps −StepsInitialize variable n. Initialize x and y data points using numpy.Create a figure and a set of subplots, fig and ax.Plot the curve using plot() method.Use fill_between() method to fill the area between the two curves, with -1 value.To display ... Read More

Plotting a histogram from pre-counted data in Matplotlib

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 07-May-2021 08:09:01

2K+ Views

To plot a histogram from pre-counted data in matplotlib, we can take the following steps −Create a list of numbers.Make a pre-counted list with the help of input data.Plot a histogram with data, color=red, and label=data, using hist() method.Plot another histogram with counted data, color=default, and label=counted_data, using hist() method.To place ... Read More

How to show an Axes Subplot in Python?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 07-May-2021 08:03:30

2K+ Views

To show an axes subplot in Python, we can use show() method. When multiple figures are created, then those images are displayed using show() method.StepsCreate x and y data points using numpy.Plot x and y using plot() method.To display the figure, use show() method.Examplefrom matplotlib import pyplot as plt import ... Read More

How to change the color of the ticks in the colorbar in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 07-May-2021 08:03:03

958 Views

To change the color of the ticks in the colorbar in matplotlib, we can take the following steps−Create a random 2D−Array using numpy, with 4☓4 dimension.Use imshow() method to display the data as an image.Create a colorbar using colorbar() method with scalar mappable instance of imshow().Use getp() method to return ... Read More

Advertisements