Rishikesh Kumar Rishi has Published 1156 Articles

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

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

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

Drawing a rectangle with only border in Matplotlib

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 07-May-2021 08:02:39

3K+ Views

To draw a rectangle with only border in matplotlib, we can take the following steps−Create a figure and a set of subplots.Get the current axes, creating one if necessary.Add a patch, i.e., a rectangle to the current axes that is returned in step 2. Set the facecolor attribute to 'none'.To ... Read More

How to insert a small image on the corner of a plot with Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

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

8K+ Views

To insert a small image on the corner of a plot with matplotlib, we can take the following steps−Read an image from a file into an array using imread() method.Using subplots() method, create a figure and add a set of subplots.Plot a line on the current axis.Create newax (new axis) ... Read More

How to suppress Matplotlib warning?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

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

5K+ Views

Let's take an example. We create a set of data points such that it would generate some warnings. We will create data points x from −1 to 1 and try to find log in that range, which means it will throw an error at value 0, while calculating logs.StepsCreate data ... Read More

Plot a circle with an edgecolor and hatch in Matplotlib

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

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

506 Views

To place edge color and hatch of 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 method to the current axis.Create a circle instance using Circle() class with an edgecolor, hatch and linewidth of the edge.Add a circle path ... Read More

How to fill color above the curve in Matplotlib Program?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 07-May-2021 08:00:35

3K+ Views

To fill color above the curve, we can take the following steps −StepsInitialize the 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.Using fill_between() method, fill the area between two curves, with 1 value.To display the figure, use ... Read More

Advertisements