Rishikesh Kumar Rishi has Published 1162 Articles

How do I plot only a table in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

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

6K+ Views

To plot only a table, we can take the following steps−Create fig and axs, using subplots. Create a figure and a set of subplots.Create random data for 10 rows and 3 columns.Create a tuple for columns name.axis('tight') − Set the limits, just large enough to show all the data, then ... Read More

How to add different graphs (as an inset) in another Python graph?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

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

1K+ Views

To add different graphs (as an inset) in another Python graph, we can take the following steps −Create x and y data points using numpy.Using subplots() method, create a figure and a set of subplots, i.e., fig and ax.To create a new axis, add axis to the existing figure (Step 2).Plot x and y on the ... Read More

How to change the order of plots in Pandas hist command?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 06-May-2021 13:05:53

361 Views

To change order of plots in Pandas hist commad, we can take the following steps −Make a data frame using Pandas.Plot a histogram with the data frame.Plot the data frame in different order.To display the figure, use show() method.Examplefrom matplotlib import pyplot as plt import pandas as pd plt.rcParams["figure.figsize"] = [7.50, 3.50] ... Read More

How to add vertical lines to a distribution plot (sns.distplot) in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 06-May-2021 13:05:00

3K+ Views

To add vertical lines to a distribution plot, we can take the following steps−Create a list of numbers.Create an axis using sns.displot().Get x and y data of the axis ax.Plot a vertical line on the plot.Remove the line at the 0th index.To display the figure, use show() method.Exampleimport seaborn as ... Read More

How to draw a log-normalized imshow plot with a colorbar representing the raw data in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 06-May-2021 13:04:00

7K+ Views

To draw a log-normalized imshow() plot with a colorbar representing the raw data in matplotlib, we can take the following steps −Create a 2D array using numpy.Display the data as an image, i.e., on a 2D regular raster, using imshow() methodCreate a colorbar for a ScalarMappable instance, *mappable*, using imshow() ... Read More

Circular (polar) histogram in Python

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 06-May-2021 13:03:31

2K+ Views

To plot circular (polar) histogram in Python, we can take the following steps−Create data points for theta, radii and width using numpy.Add a subplot to the current figure, where projection='polar' and nrows=1, ncols=1 and index=1.. Make a bar plot using bar() method, with theta, radii and width data pointsIterate radii ... Read More

How to put text outside Python plots?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 06-May-2021 13:03:04

3K+ Views

To put text outside a plot, we can change the text position by changing the value of text_pos_x and text_pos_yStepsCreate data points for x and y.Initialize the text position of x and y.To plot x and y, use plot() method with color='red'.Use text() method to add text to figure.To display ... Read More

Adjusting gridlines and ticks in Matplotlib imshow

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

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

3K+ Views

To adjust gridlines and ticks in matplotlib imshow(), we can take the following steps−Create data, a 2D array, using numpy.Using imshow() method, display data as an image.Set xticks and yticks using set_xticks and set_yticks method.To set the xticklabels and yticklabels, use set_xticklabels and set_yticklabels method.Lay out a grid in current ... Read More

Matplotlib Plot Lines with Colors through Colormap

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

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

13K+ Views

To plot lines with colors through colormap, we can take the following steps−Create x and y data points using numpyPlot x and y data points using plot() method.Count n finds, number of color lines has to be plotted.Iterate in a range (n) and plot the lines.Limit the x ticks range.Use ... Read More

How to add group labels for bar charts in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 06-May-2021 13:01:29

853 Views

To make grouped labels for bar charts, we can take the following steps −Create lists for 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, i.e., width=0.35.Create fig and ax variables using subplots method, where default nrows and ncols are 1.The ... Read More

Advertisements