Rishikesh Kumar Rishi has Published 1156 Articles

How to maximize a plt.show() window using Python?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 15-Mar-2021 08:04:38

5K+ Views

Using plt.get_current_fig_manager() and mng.full_screen_toggle() methods, we can maximise a plot.StepsAdd a subplot to the current figure, where nrow = 1, ncols = 1 and index = 1.Create a pie chart using list [1, 2, 3] and pie() method.Return the figure manager of the current figure, using get_current_fig_manager() method. The figure ... Read More

How to share x axes of two subplots after they have been created in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 15-Mar-2021 08:01:21

2K+ Views

First, we can create two axes using the subplot method where nrows=2, ncols=1. That means, we can have two indices to plot the desired plot. We can use ax1.get_shared_x_axes().join(ax1, ax2) method for our plot.StepsCreate two lists of the numbers.Add a subplot to the current figure, ax1, where nrows = 2, ... Read More

Adding value labels on a matplotlib bar chart

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 15-Mar-2021 07:59:44

23K+ Views

In this program, we can initialize some input values and then try to plot a bar using those values. We can instantiate a figure and axis so that we could set the label, ticks, and annotate the height and width of the bar.StepsMake a list of years.Make a list of ... Read More

What is the difference between 'log' and 'symlog' in matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

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

1K+ Views

Log helps to make a plot with log scaling on both the X and Y axis, whereas symlog (symmetric log) is used for axis scaling.StepsFirst, we can adjust the subplot layout parameters.Return an evenly spaced value (t) within a given interval, using the numpy.arrange() method.Add a subplot to the current ... Read More

Plot different colors for different categorical levels using matplotlib

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

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

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

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

286 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

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

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

Advertisements