Rishikesh Kumar Rishi has Published 1156 Articles

Circular (polar) histogram in Python

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 06-May-2021 13:03:31

2K+ Views

To plot circular (polar) histogram in Python, we can take the following steps−Create data points for theta, radii and width using numpy.Add a subplot to the current figure, where projection='polar' and nrows=1, ncols=1 and index=1.. Make a bar plot using bar() method, with theta, radii and width data pointsIterate radii ... Read More

How to put text outside Python plots?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 06-May-2021 13:03:04

3K+ Views

To put text outside a plot, we can change the text position by changing the value of text_pos_x and text_pos_yStepsCreate data points for x and y.Initialize the text position of x and y.To plot x and y, use plot() method with color='red'.Use text() method to add text to figure.To display ... Read More

Adjusting gridlines and ticks in Matplotlib imshow

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 06-May-2021 13:02:37

4K+ Views

To adjust gridlines and ticks in matplotlib imshow(), we can take the following steps−Create data, a 2D array, using numpy.Using imshow() method, display data as an image.Set xticks and yticks using set_xticks and set_yticks method.To set the xticklabels and yticklabels, use set_xticklabels and set_yticklabels method.Lay out a grid in current ... Read More

Matplotlib Plot Lines with Colors through Colormap

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 06-May-2021 13:02:02

13K+ Views

To plot lines with colors through colormap, we can take the following steps−Create x and y data points using numpyPlot x and y data points using plot() method.Count n finds, number of color lines has to be plotted.Iterate in a range (n) and plot the lines.Limit the x ticks range.Use ... Read More

How to add group labels for bar charts in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 06-May-2021 13:01:29

1K+ Views

To make grouped labels for bar charts, we can take the following steps −Create lists for labels, men_means and women_means with different data elements.Return evenly spaced values within a given interval, using numpy.arrange() method.Set the width variable, i.e., width=0.35.Create fig and ax variables using subplots method, where default nrows and ncols are 1.The ... Read More

How to rotate xticklabels in Matplotlib so that the spacing between each xticklabel is equal?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 06-May-2021 13:01:04

382 Views

To rotate xticklabels in matplotlib to make equal spacing between two xticklabels, we can take the following steps −Make a list of numbers from 1 to 4.Using subplot(), sdd a subplot to the current figure.Add xticks and yticks on the current subplot (using step 1).Set xtick labels by passing a list and to make ... Read More

Colorplot of 2D array in Matplotlib

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 06-May-2021 13:00:44

1K+ Views

To plot a colorplot of a 2D array, we can take the following steps −Create data (i.e., 2D array) using numpy.For colorplot, use imshow() method, with input data (Step 1) and colormap is "PuBuGn".To display the figure, use show() method.Exampleimport numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = ... Read More

Adding caption below X-axis for a scatter plot using Matplotlib

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 06-May-2021 13:00:19

5K+ Views

To add caption below X-axis for a scatter plot, we can use text() method for the current figure.StepsCreate x and y data points using numpy.Create a new figure or activate an existing figure using figure() method.Plot the scatter points with x and y data points.To add caption to the figure, ... Read More

How to plot a confusion matrix with string axis rather than integer in Python?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 06-May-2021 12:54:44

623 Views

To plot a confusion matrix with string axis rather than integer in Python, we can take the following steps−Make a list for labels.Create a confusion matrix. Use confusion_matrix() to calculate accuracy of classification.3. Add an '~.axes.Axes' to the figure as part of a subplot arrangement.Plot the values of a 2D ... Read More

How can I hide the axes in Matplotlib 3D?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 06-May-2021 12:54:18

2K+ Views

To hide the axes in matplotlib 3D, we can take the following steps−Create a 2D array, where x, y, z, u, v and w are the coordinates of the arrow locations and direction components of the arrow vectors.Using figure() method, create a new figure or activate an existing figure.Add an ... Read More

Advertisements