Rishikesh Kumar Rishi has Published 1162 Articles

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

978 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

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

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

How to set the ticks on a Fixed Position in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 08-May-2021 08:38:47

5K+ Views

To set the ticks on a fixed position 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 on the axes.To display ... Read More

How do I make sans serif superscript or subscript text in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 08-May-2021 08:38:43

1K+ Views

To make superscript or subscript text in matplotlib, use LaTeX representation.StepsCreate x and y data points using numpy.Plot x and y data point using plot() method.Put the title with LateX representation using title() method.Use xlabel and ylabel methods to set the label of the axes.Exampleimport numpy as np from matplotlib import pyplot ... Read More

Change the spacing of dashes in a dashed line in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

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

1K+ Views

To change the spacing of dashes in a dashed line in matplotlib, we can take the following steps −Create data points x and y using numpy.Initialize two variables space and dash_len with value 3.Plot x and y using plot() method, with line style '--', dashes tuple stores the property of dashed ... Read More

How do I plot a step function with Matplotlib in Python?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 08-May-2021 08:35:38

1K+ Views

To plot a step function with matplotlib in Python, we can take the following steps −Create data points for x and y.Make a step plot using step() method.To display the figure, use show() method.Exampleimport matplotlib.pyplot as plt import numpy as np plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True x = np.array([1, 3, ... Read More

How can I rotate xtick labels through 90 degrees in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

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

7K+ Views

To rotate xtick labels through 90 degrees, we can take the following steps −Make a list (x) of numbers.Add a subplot to the current figure.Set ticks on X-axis.Set xtick labels and use rotate=90 as the arguments in the method.To display the figure, use show() method.Exampleimport matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.00, ... Read More

Advertisements