Rishikesh Kumar Rishi has Published 1162 Articles

How to plot a rectangle inside a circle in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 11-May-2021 13:12:51

573 Views

To plot a rectangle inside 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 to the current axis.Make a rectangle and a circle instance using Rectangle() and Circle() class.Add a patch on the axes.Scale x and y ... Read More

What is the difference betweent set_xlim and set_xbound in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 11-May-2021 13:09:52

340 Views

set_xlim − Set the X-axis view limits.set_xbound − Set the lower and upper numerical bounds of the X-axis.To set the xlim and xbound, we can take the following steps −Using subplots(2), we can create a figure and a set of subplots. Here, we are creating 2 subplots.Create x and y ... Read More

How to animate a pcolormesh in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 11-May-2021 13:05:57

3K+ Views

To animate pcolormesh in matplotlib, we can take the following steps −Create a figure and a set of subplots.Create x, y and t data points using numpy.Create X3, Y3 and T3, return coordinate matrices from coordinate vectors using meshgrid.Create a pseudocolor plot with a non-regular rectangular grid using pcolormesh() method.Make a colorbar with ... Read More

How to add a colorbar for a hist2d plot in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 11-May-2021 13:01:58

3K+ Views

To add a colorbar for hist2d plot, we can pass a scalar mappable object to colorbar() method's argument.StepsCreate x and y data points using numpy.Create a figure and a set of subplots using subplots() method.Make a 2D histogram plot using hist2d() method.Create a colorbar for a hist2d scalar mappable instance.To display the ... Read More

How to set axis ticks in multiples of pi in Python Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 11-May-2021 12:44:15

3K+ Views

To set axis ticks in multiples of pi in Python, we take following steps −Initialize a pi variable, create theta and y data points using numpy.Plot theta and y using plot() method.Get or set the current tick locations and labels of the X-axis using xticks() method.Convenience method to set or retrieve autoscaling ... Read More

How to make hollow square marks with Matplotlib in Python?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 11-May-2021 12:40:16

4K+ Views

To make hollow square marks with matplotlib, we can use marker 'ks', markerfacecolor='none', markersize=15, and markeredgecolor=red.StepsCreat x and y data points using numpy.Create a figure or activate an existing figure, add an axes to the figure as part of a subplot arrangement.Plot x and y data points using plot() method. ... Read More

How to display all label values in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 11-May-2021 12:37:08

6K+ Views

To display all label values, we can use set_xticklabels() and set_yticklabels() methods.StepsCreate a list of numbers (x) that can be used to tick the axes.Get the axis using subplot() that helps to add a subplot to the current figure.Set the ticks on X and Y axes using set_xticks and set_yticks methods respectively ... Read More

How can I place a table on a plot in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 11-May-2021 12:31:31

712 Views

StepsUsing the subplots() method, create a figure and a set of subplots with figure size (7, 7).Create a data frame with two keys, time and speed.Get the size of the array.Add a table to the current axis using the table method.Shrink the font size until the text fits into the cell width.Set the font ... Read More

How to convert a .wav file to a spectrogram in Python3?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 11-May-2021 12:25:40

2K+ Views

To convert a .wav file to a spectrogram in python3, we can take the following steps −Load a .wav file from local machine.Compute a spectrogram with consecutive Fourier transforms using spectrogram() method.Create a pseudocolor plot with a non-regular rectangular grid using pcolormesh() method.Use imshow() method with spectrogram.To display the figure, use show() method.Exampleimport ... Read More

Draw axis lines or the origin for Matplotlib contour plot.

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 11-May-2021 12:22:57

4K+ Views

To draw axis lines or the origin for matplotlib contour plot, we can use contourf(),  axhline() y=0 and axvline() x=0.Create data points for x, y, and z using numpy.To set the axes properties, we can use plt.axis('off') method.Use contourf() method with x, y, and z data points.Plot x=0 and y=0 lines with red ... Read More

Advertisements