Rishikesh Kumar Rishi has Published 1162 Articles

How to add legends and title to grouped histograms generated by Pandas? (Matplotlib)

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 15-Jun-2021 13:16:24

4K+ Views

To add legends and title to grouped histograms generated by Pandas, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create a Pandas dataframe with "a", "b", "c" and "d" keys.Plot data frame with kind="hist"Set a title for the axes.To display ... Read More

Plot scatter points on polar axis in Matplotlib

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 15-Jun-2021 13:15:37

1K+ Views

To plot scatter points on polar axis in Matplotlib, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Initialize a variable, N, for number of sample data.Get r, theta, area and color data using numpyCreate a new figure or activate an ... Read More

How do I omit Matplotlib printed output in Python / Jupyter notebook?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 15-Jun-2021 13:14:50

2K+ Views

To omit matplotlib printed output in Python/Jupeter notebook, we can take the following steps −import numpy as np.from matplotlib import pyplot as pltCreate points for x, i.e., np.linspace(1, 10, 1000)Now, plot the line using plot() method.To hide the instance, use plt.plot(x); (with semi-colon)Or, use _ = plt.plot(x).ExampleIn [1]: import numpy ... Read More

How to save figures to pdf as raster images in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 15-Jun-2021 13:12:21

976 Views

To save figures to pdf as raster images in Matplotlib, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create a new figure or activate an existing figure.Add an axes to the figure as part of a subplot arrangement.Create random data ... Read More

How can I get the color of the last figure in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

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

2K+ Views

To get the color of the last figure, we can use get_color() method for every plot.Set the figure size and adjust the padding between and around the subplots.Create x and y data point using numpy.Plot (x, x), (x, x2) and (x, x3) using plot() method.Place a legend for every plot ... Read More

How do I customize the display of edge labels using networkx in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 15-Jun-2021 13:03:21

2K+ Views

To set the networkx edge labels offset, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Initialize a graph with edges, name, or graph attributes.Add multiple nodes.Position the nodes using Fruchterman-Reingold force-directed algorithm.Draw the graph G with Matplotlib.Draw edge labels.To display ... Read More

How to plot contourf and log color scale in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 15-Jun-2021 13:02:37

2K+ Views

To plot contourf and log scale in Matplotlib, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Initialize a variable, N, for number of sample data.Create x, y, X, Y, Z1, Z2 and z data points using numpy.Create a figure and ... Read More

How to independently set horizontal and vertical, major and minor gridlines of a plot?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 15-Jun-2021 12:54:15

845 Views

To set horizontal and vertical, major and minor grid lines of a plot, we can use grid() method.StepsSet the figure size and adjust the padding between and around the subplots.Create a figure and a set of subplots.Make horizontal grid lines for major ticks.Locate minor locator on the axes.Use grid() method ... Read More

Contour hatching in Matplotlib plot

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 15-Jun-2021 12:53:39

623 Views

To plot contour with hatching, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create x, y and z data points using numpy.Flat the x and y data points.Create a figure and a set of subplots.Plot a contour with different hatches.Create ... Read More

How can I move a tick label without moving corresponding tick in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 15-Jun-2021 12:53:06

487 Views

To move a tick label without moving corresponding tick in Matplotlib, we can use axvline() method and can annotate it accordingly.StepsSet the figure size and adjust the padding between and around the subplots.Initialize a variable, delta.Create x and y data points using numpy.Plot delta using axvline() methodAnnotate that line using ... Read More

Advertisements