Rishikesh Kumar Rishi has Published 1162 Articles

Plot different colors for different categorical levels using matplotlib

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 15-Mar-2021 07:55:18

986 Views

We can plot a diagram where a number of students will be plotted on the X-axis and the marks obtained by them will be plotted on the Y-axis. Also, we can set the color for different marks obtained by the students.StepsMake a list of the number of students.Make a list ... Read More

What is the difference between drawing plots using plot, axes or figure in matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

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

2K+ Views

Let’s understand the difference between plot, axes, and figure with an example.Plot − Plot helps to plot just one diagram with (x, y) coordinates.Axes − Axes help to plot one or more diagrams in the same window and sets the location of the figure.Figure − This method provides a top-level ... Read More

Plotting with seaborn using the matplotlib object-oriented interface

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

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

173 Views

Seaborn is used to visualizing the random distribution and we can use matplotlib interface to show this distribution over a diagram.We can take the following steps to show the diagram −Figure level interface for drawing distribution plots onto a Face Grid. This function provides access to several approaches for visualizing ... Read More

How to set the matplotlib figure default size in ipython notebook?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

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

4K+ Views

To set the matplotlib figure default size in iPython, use the following steps −To check the default figure size, use plt.rcParams["figure.figsize"] over the ipython shell.Now to set the figure size, override the plt.rcParams["figure.figsize"] variable with a tuple i.e., (20, 10).After overriding the plt.rcParams["figure.figsize"] variable, you can use it to get ... Read More

Fill between two vertical lines in matplotlib

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 15-Mar-2021 07:43:33

2K+ Views

To fill color between two vertical lines, use the following steps −Using plt.subplots() method, create a figure and a set of subplots. This utility wrapper makes it convenient to create common layouts of subplots, including the enclosing figure object, in a single call.To draw two vertical lines, initialize x = ... Read More

Remove or adapt the border of the frame of legend using matplotlib

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 15-Mar-2021 07:41:58

1K+ Views

To remove or adapt the border of the frame of legend we can follow the following steps −Set the X-axis label using the plt.xlabel() method.Set the Y-axis label using the plt.ylabel() method.Plot the lines using the plt.plot() method with [9, 5], [2, 5] and [4, 7, 8] array.Initializing two variables; ... Read More

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

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

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

814 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

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

Advertisements