Rishikesh Kumar Rishi has Published 1156 Articles

How to hide in IPython notebook?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 09-Apr-2021 12:20:28

447 Views

To hide matplotlib.lines.Line2D instance while calling the plot() method, we can take the following steps −Import numpy as np.From matplotlib, import pyplot as plt.Create points for x, i.e., np.linspace(1, 10, 1000)Now plot the line using the plot() method.To hide the instance, use plt.plot(x); (with semi colon)Or, use _ = plt.plot(x).ExampleIn ... Read More

Embedding small plots inside subplots in Matplotlib

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 09-Apr-2021 12:20:06

4K+ Views

To embed small plots inside subplots, we can take the following Steps −Using subplots() method, create a figure and a set of subplots (fig, ax1).On ax1, plot a line with color red, line width=4, label=”outer plot”.Using add_axes(), add an axis, i.e., ax2 with l, b, h and w values.Plot the ... Read More

How to change the figuresize using Seaborn factorplot in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 09-Apr-2021 12:19:43

402 Views

To change the figuresize using Seaborn factorplot, we can take the following Steps −Load the exercise data using load_dataset() method.Using factorplot() method, change figure size by customising the size and aspect values.To display the figure, use the show() method.Exampleimport seaborn as sns from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] ... Read More

How to set the font size of Matplotlib axis Legend?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 09-Apr-2021 12:19:18

2K+ Views

To set the font size of matplotlib axis legend, we can take the following steps −Create the points for x and y using numpy.Plot x and y using the plot() method with label y=sin(x).Title the plot using the title() method.To set the fontsize, we can override rcParams legend fontsize by value ... Read More

Show the origin axis (x,y) in Matplotlib plot

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 09-Apr-2021 08:32:44

13K+ Views

To show the origin, we can take the following Steps −Create the points x, y1 and y2 using numpy.Plot the sine and cosine curves using plot() methods.Plot the vertical line, i.e., x=0.Plot the horizontal line, i.e.,  y=0.Intersection point of (Step 3 and 4), could be the origin.To display the label ... Read More

How to change the color of data points based on some variable in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 09-Apr-2021 08:32:15

1K+ Views

To change the color of data points based on some variable in matplotlib, we can take the following steps −Create x, y and c variables using numpy.Plot the scatter points using x, y and for color, use c (Step 1).To display the image, use the show() method.Exampleimport numpy as np from ... Read More

How to put a legend outside the plot with Pandas?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 09-Apr-2021 08:31:53

7K+ Views

To put a legend outside the plot with Pandas, we can take the following Steps −Make a dictionary d with keys Column1 and Column2.Make a data frame using DataFrame (d).Plot the data frame with a list of styles.Using legend(), place a legend on the figure. The bbox_to_anchor keyword gives a great ... Read More

How to make pylab.savefig() save image for 'maximized' window instead of default size in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 09-Apr-2021 08:31:14

2K+ Views

To save image for maximized window instead of default size, we can use the following Steps −Create figure with figsize=(7.50, 3.50), using the figure() method.Plot the lines using the plot() method with list, color=”red”, and linewidth=2.Save the figure using the savefig() method.To display the figure, use the show() method.Examplefrom matplotlib import ... Read More

How can I show figures separately in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 09-Apr-2021 08:30:32

17K+ Views

To show multiple figures in matplotlib, we can take the following Steps −To create a new figure, or activate an existing figure, use the figure() method. (Create two figures namely, Figure1 and Figure2).Plot the lines with the same lists (colors red and green and linewidth 2 and 5).Set the title ... Read More

Automatically position text box in Matplotlib

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 09-Apr-2021 08:25:06

736 Views

To position a textbox automatically in matplotlib, we can take the following Steps −Create xpoints from 1 to 2 and 100 samples.Create y1points and y2points using xpoints (Step 1) and numpy.Plot xpoints, y1points and y2points using the plot() method.To set the label, use the legend() method. It will help to position the text box.To display the figure, ... Read More

Advertisements