Rishikesh Kumar Rishi has Published 1156 Articles

How to change the spacing between ticks in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

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

8K+ Views

To set ticks on a fixed position or change the spacing between ticks in matplotlib, we can take the following steps −Create a figure and add a set of subplots.To set the ticks on a fixed position, create two lists with some values.Use set_yticks and set_xticks methods to set the ticks ... Read More

How to normalize a histogram in Python?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 08-May-2021 08:55:40

18K+ Views

To normalize a histogram in Python, we can use hist() method. In normalized bar, the area underneath the plot should be 1.StepsMake a list of numbers.Plot a histogram with density=True.To display the figure, use show() method.Exampleimport matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True k = [5, ... Read More

How to set a default colormap in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 08-May-2021 08:55:19

5K+ Views

To set a default colormap in matplotlib, we can take the following steps −Create random data using numpy, array dimension 4×4.Create two axes and one figure using subplots() method.Display the data as an image with the default colormap.Set the title of the image, for the default colormap.Set the default colormap using ... Read More

How to plot a 3D density map in Python with Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 08-May-2021 08:54:49

2K+ Views

To plot a 3D density map in Python with matplotlib, we can take the following steps −Create side, x, y and z using numpy. Numpy linspace helps to create data between two points based on a third number.Return the coordinate matrices from coordinate vectors using side data.Create exponential data using x ... Read More

Add minor gridlines to Matplotlib plot using Seaborn

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 08-May-2021 08:54:25

3K+ Views

To add minor gridlines to matplotlib plot using Seaborn, we can take the following steps −Create a list of numbers to plot a histogram using Seaborn.Plot univariate or bivariate histograms to show distributions of datasets using histplot() method.To make minor grid lines, we can first use major grid lines and then ... Read More

How to annotate the points on a scatter plot with automatically placed arrows in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 08-May-2021 08:53:59

1K+ Views

To annotate the point on a scatter plot with automatically placed arrows, we can take the following steps −Create points for x and y using numpy.Create labels using xpoints.Use scatter() method to scatter the points.Iterate labels, xpoints and ypoints and annotate plot with label, x and y with different properties.To display the ... Read More

Setting a relative frequency in a Matplotlib histogram

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 08-May-2021 08:53:34

2K+ Views

To set a relative frequency in a matplotlib histogram, we can take the following steps −Create a list of numbers for data and bins.Compute the histogram of a set of data, using histogram() method.Get the hist and edges from the histogram.Find the frequency of the histogram.Make a bar with bins (step ... Read More

How to plot a circle in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 08-May-2021 08:53:08

14K+ Views

To plot a circle in matplotlib, we can take the following steps −Create a new figure or activate an existing figure using figure() method.Add a subplot arrangement to the current axis.Create a true circle at a center using Circle class.Add a patch to the current axis.Set limits of the x and y ... Read More

Add alpha to an existing Matplotlib colormap

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

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

2K+ Views

To add apha to an existing matplotlib colormap, we can take the following steps −Create data with a 4×4 dimension array using numpy.Get the colormap using plt.cm.RdBU.Create a new colormap using numpy.Set alpha value to the new colormap.Generate a colormap object using the list of colors.Create a new figure or ... Read More

How to annotate a heatmap with text in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 08-May-2021 08:40:15

1K+ Views

To annotate a heatmap with text in matplotlib, we can take the following steps −Create random data with 4×4 dimension array.Create a pseudocolor plot with a non-regular rectangular grid, using pcolor() method.To put text in the pixels, we can use text() method.To display the figure, use show() method.Exampleimport matplotlib.pyplot as plt ... Read More

Advertisements