Rishikesh Kumar Rishi has Published 1156 Articles

Plot a histogram with Y-axis as percentage in Matplotlib

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

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

3K+ Views

To plot a histogram with Y-axis as percentage in matplotlib, we can take the following steps −Create a list of numbers as y.Create a number of bins.Plot a histogram using hist() method, where y, bins, and edgecolor are passed in the argument.Store the patches to set the percentage on Y-axis.Create a list ... Read More

Setting Y-axis in Matplotlib using Pandas

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 06-May-2021 13:56:41

6K+ Views

To set Y-Axis in matplotlib using Pandas, we can take the following steps −Create a dictionary with the keys, x and y.Create a data frame using Pandas.Plot data points using Pandas plot, with ylim(0, 25) and xlim(0, 15).To display the figure, use show() method.Exampleimport numpy as np import pandas as pd from ... Read More

How to remove the outline of a circle marker when using pyplot.plot in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 06-May-2021 13:52:23

1K+ Views

To remove the outline of a circle marker, we can reduce the value of marker edge width.Initialize list for x and y, with a single value.Limit x and y axis range for 0 to 5.Lay out a grid in current line style.Plot the given x and y using plot() method, with marker="o", markeredgecolor="red", markerfacecolor="green" and ... Read More

How to use 'extent' in matplotlib.pyplot.imshow?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 06-May-2021 13:51:59

3K+ Views

To use extent in matplotlib imshow(), we can use extent [left, right, bottom, top].StepsCreate random data using numpy.Display the data as an image, i.e., on a 2D regular raster with data and extent [−1, 1, −1, 1] arguments.To display the figure, use show() method.Exampleimport numpy as np from matplotlib import ... Read More

Python Matplotlib Venn diagram

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 06-May-2021 13:50:18

2K+ Views

To plot a Venn diagram, first install Venn diagram using command "pip install matplotlib-venn". Using venn3, plot a 3-set area-weighted Venn diagram.StepsCreate 3 sets.Using venn3, make a Venn diagram.To display the figure, use show() method.Exampleimport matplotlib.pyplot as plt from matplotlib_venn import venn3 plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True set1 = {'A', ... Read More

How to improve the label placement for Matplotlib scatter chart?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 06-May-2021 13:49:25

1K+ Views

To imporove the label placement for matplotlib scatter chart, we can first plot the scatter points and annotate those points with labels.StepsCreate points for x and y using numpy.Create labels using xpoints.Use scatter() method to scatter points.Iterate the labels, xpoints and ypoints and annotate the plot with label, x and y with different properties.To ... Read More

How to plot bar graphs with same X coordinates side by side in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 06-May-2021 13:48:07

2K+ Views

To plot bar graphs with same X coordinates (G1, G2, G3, G4 and G5), side by side in matplotlib, we can take the following steps −Create the following lists – 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, ... Read More

Plot scatter points using plot method in Matplotlib

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 06-May-2021 13:47:24

601 Views

To plot scatter points using plot method in matplotlib, we can take the following steps−Create random data points (x1 and x2) using numpy.Plot x1 data points using plot() method with marker size 20 and green color.Plot x2 data points using plot() method with marker size 10 and red color.Exampleimport numpy ... Read More

Changing the formatting of a datetime axis in Matplotlib

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

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

7K+ Views

To change the formatting of a datetime axis in matplotlib, we can take the following steps−Create a dataframe df using pandas DataFrame with time and speed as keysCreate a figure and a set of subplots using subplots() method.Plot the dataframe using plot method, with df's (Step 1) time and speed.To ... Read More

Save figure as file from iPython notebook using Matplotlib

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 06-May-2021 13:46:34

5K+ Views

To save a figure as a file from iPython, we can take the following steps−Create a new figure or activate an existing figure.Add an axes to the figure using add_axes() method.Plot the given list.Save the plot using savefig() method.Examplefrom matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = ... Read More

Advertisements