Rishikesh Kumar Rishi has Published 1156 Articles

How to plot a histogram using Matplotlib in Python with a list of data?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 15-Mar-2021 07:40:11

15K+ Views

To plot a histogram using Matplotlib, we can follow the steps given below −Make a list of numbers and assign it to a variable x.Use the plt.hist() method to plot a histogram.Compute and draw the histogram of *x*.We can pass n-Dimensional arrays in the hist argument also.To show the plotted ... Read More

How to display multiple images in one figure correctly in matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 15-Mar-2021 07:38:35

5K+ Views

To display multiple images in one figure, we can follow the steps given below −Initialize the number of rows and cols. nrows*ncols subplot will be created in the current figure. nrows = 2 and ncols = 2, i.e., 2*2 = 4 subplots can be created.Now add the figures at different ... Read More

How to pick a new color for each plotted line within a figure in matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 15-Mar-2021 07:37:02

1K+ Views

To pick a new color for each plotted line within a figure, use the following steps −Setup X-axis and Y-axis labels for the diagram.Set the current .rc parameters. For axes facecolor, the group is axes.Use a cycler to set the color for the group of lines. The color list consists ... Read More

Hide axis values but keep axis tick labels in matplotlib

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 15-Mar-2021 07:34:08

8K+ Views

To hide the axis value but to keep the axis tick labels, we can perform the following steps −Plot a line using the plot( ) method.Set X and Y labels using x label and y label methods.Using plt.gca(), get the current axis, creating one if necessary.Use xaxis.set_ticklabels() with an empty ... Read More

Saving images in Python at a very high quality

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 15-Mar-2021 07:32:19

8K+ Views

To save the images in Python with very high quality, you need to follow the steps given below −Create fig and ax variables using subplots method, where default nrows and ncols are 1.Plot the lines using plot() method.We can add axes labels using ylabel() and xlabel().To get a high-quality image, ... Read More

How to move the Y-axis ticks from the left side of the plot to the right side in matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 15-Mar-2021 07:28:01

7K+ Views

To shift the Y-axis ticks from left to right, we can perform the following steps −Create a figure using the figure() method.Using the above figure method, create the axis of the plot, using add_subplot(xyz), where x is row, y is column, and z is index.To shift the Y-axis ticks from ... Read More

Advertisements