Rishikesh Kumar Rishi has Published 1156 Articles

How to make hollow square marks with Matplotlib in Python?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

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

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

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

808 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

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

How to plot a line graph from histogram data in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

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

8K+ Views

To plot a line graph from histogram data in matplotlib, we use numpy histogram method to compute the histogram of a set of data.StepsAdd a subplot to the current figure, nrows=2, ncols=1 and index=1.Use numpy histogram method to get the histogram of a set of data.Plot the histogram using hist() method ... Read More

How to plot a multi-colored line, like a rainbow using Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

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

2K+ Views

To plot multi-colored lines, like a rainbow, we can create a list of seven rainbow colors (VIBGYOR).StepsCreate x for data points using numpy.Create a list of colors (rainbow VIBGYOR).Iterate in the range of colors list length.Plot lines with x and y(x+i/20) using plot() method, with marker=o, linewidth=7 and colors[i] where i is the index.To display ... Read More

How to remove the label on the left side in matplotlib.pyplot pie charts?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

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

3K+ Views

To remove the label on the left side in a matplotlib pie chart, we can take the following steps −Create lists of hours, activities, and colors.Plot a pie chart using pie() method.To hide the label on the left side in matplotlib, we can use plt.ylabel("") with ablank string.Exampleimport matplotlib.pyplot as plt plt.rcParams["figure.figsize"] ... Read More

How can I display text over columns in a bar chart in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 11-May-2021 11:59:47

3K+ Views

To display text over columns in a bar chart, we can use text() method so that we could place text at a specific location (x and y) of the bars column.StepsCreate lists for x, y and percentage.Make a bar plot using bar() method.Iterate zipped x, y and percentage to place text for the ... Read More

How to handle an asymptote/discontinuity with Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 11-May-2021 11:48:28

1K+ Views

To handle an asymptote/discontinuity with matplotlib, we can take the following steps −Create x and y data points using numpy.Turn off the axes plot.Plot the line with x and y data points.Add a horizontal line across the axis, x=0.Add a vertical line across the axis, y=0.Place legend for the curve ... Read More

Advertisements