Rishikesh Kumar Rishi has Published 1162 Articles

Adjusting the spacing between the edge of the plot and the X-axis in Matplotlib

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 02-Jun-2021 08:24:21

3K+ Views

To adjust the spacing between the edge of the plot and the X-axis, we can use tight_layout() method or set the bottom padding of the current figure.Set the figure size and adjust the padding between and around the subplots.Create x and y data points using numpy.Plot x and y data ... Read More

How to add footnote under the X-axis using Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 02-Jun-2021 08:21:06

2K+ Views

To add footnote under the X-axis using matplotlib, we can use figtext() and text() method.StepsSet the figure size and adjust the padding between and around the subplots.Create x and y data points using numpy.Plot x and y data points using numpy.To place the footnote, use figtext() method with x, y ... Read More

Plot yscale class linear, log, logit and symlog by name in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 02-Jun-2021 08:17:35

434 Views

To plot yscale with class by name, we can take the following stepsSet the figure size and adjust the padding between and around the subplots.Create y data points using numpy.Create x data points using numpy.Add a subplot to the current figure at index 1.Plot x and y data points using ... Read More

How to locate the median in a (Seaborn) KDE plot?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 02-Jun-2021 08:14:40

1K+ Views

To locate the median in a seaborn KDE plot, we can take the following stepsSet the figure size and adjust the padding between and around the subplots.Create random data using numpy.Find the median of data (Step 2).Use kdeplot() to plot the shaded region.Use axvline() method to plot the vertical line.To ... Read More

How to set the margins of a Matplotlib figure?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 02-Jun-2021 08:06:23

5K+ Views

To set the margins of a matplotlib figure, we can use margins() method.StepsSet the figure size and adjust the padding between and around the subplots.Create t and y data points using numpy.Add a subplot to the current figure at index 1.Plot t and y data points using plot() method.Set the ... Read More

Automatically setting Y-axis limits for a bar graph using Matplotlib

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 02-Jun-2021 08:00:21

8K+ Views

To set Y-axis limit, we can use ylim() method and put maximum and minimum limit values.StepsSet the figure size and adjust the padding between and around the subplots.Create two lists for data points.Make two variables for max and min values for Y-axis.Use ylim() method to limit the Y-axis range.Use bar() ... Read More

How do you improve Matplotlib image quality?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 01-Jun-2021 12:16:42

6K+ Views

To improve matplotlib image quality we can use greater dot per inch i.e dpi value (greater than 600) and pdf or .eps format can be recommended.StepsSet the figure size and adjust the padding between and around the subplots.Make a 2D data raster using a np.array.Display data as an image, i.e., ... Read More

Annotate Subplots in a Figure with A, B, C using Matplotlib

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 01-Jun-2021 12:16:14

1K+ Views

To annotate subplots in a figure with A, B and C using matplotlib, we can take the following stepsSet the figure size and adjust the padding between and around the subplots.Create a figure and a set of subplots, with nrows=1 and ncols=3.Make a 1D iterator over an array.Iterate each axes ... Read More

What is the simplest way to make Matplotlib in OSX work in a virtual environment?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 01-Jun-2021 12:15:36

73 Views

To make matplotlib in OSX work in a virtual environment, we can first create a virtual environment and then activate that created environment. Thereafter, install all the dependencies in that virtual environment.StepsOpen ubuntu terminal.apt-get install python-venvpython -m venv source /bin/activate

How to plot a stacked event duration using Python Pandas?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 01-Jun-2021 12:15:04

374 Views

To plot a stacked event duration using Python Pandas, we can take the following stepsSet the figure size and adjust the padding between and around the subplots.Create a dataframe with lists of xmin and its corresponding xmax.Use hlines() method to plot a stacked event duration.To display the figure, use show() ... Read More

Advertisements