Rishikesh Kumar Rishi has Published 1156 Articles

How do you create a legend for a contour plot in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

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

3K+ Views

To create a legend for a contour plot in matplotlib, we can take the following steps−Create x, y and z data points to plot the contour function.To create a 3D filled contour plot, we can use contourf() method with x, y, z and different levels.Make a list of rectangle with ... Read More

How to change the text color of font in the legend using Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

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

6K+ Views

To change the text color of font in the legend in matplotlib, we can take the following steps−Create x and y data points using numpy.Plot x and y using plot() method, where color of line is red and label is "y=exp(x)".To place the legend, use legend() method with location of ... Read More

Overlapping Y-axis tick label and X-axis tick label in Matplotlib

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 06-May-2021 13:11:58

4K+ Views

To reduce the chances of overlapping between x and y tick labels in matplotlib, we can take the following steps −Create x and y data points using numpy.Add a subplot to the current figure at index 1 (nrows=1 and ncols=2).Set x and y margins to 0.Plot x and y data points and add a title to this subplot, ... Read More

How to plot scatter points with increasing size of marker in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 06-May-2021 13:11:20

755 Views

To plot scatter points with increasing size of marker, we can take the following steps−StepsCreate x and y data pointsTo get increasing size of marker, make a list of numbers.Use scatter method to plot scatter points.To display the figure, use show() method.Examplefrom matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.00, ... Read More

Styling a part of label in legend in Matplotlib

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

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

240 Views

To style a part of label in legend, we can take the following steps −Create data point for x using numpy.Plot a sine curve using np.sin(x) with a text label.Plot a cosine curve using np.cos(x) with a text label.To place the legend on the plot, use legend() method.To display the figure, ... Read More

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

519 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

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

Advertisements