Rishikesh Kumar Rishi has Published 1162 Articles

How do you plot a vertical line on a time series plot in Pandas?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 17-Mar-2021 07:58:29

3K+ Views

Using Pandas, we will create a dataframe and set the vertical lines on the created axes, using axvline lines.StepsUsing panda we can create a data frame.Creating a data frame would help to create help.Using axvline(), add a vertical line across the axes, where color is green, linestyle="dashed".Using axvline(), add a ... Read More

Make 3D plot interactive in Jupyter Notebook (Python & Matplotlib)

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 17-Mar-2021 07:58:03

3K+ Views

In this article, we can take a program code to show how we can make a 3D plot interactive using Jupyter Notebook.StepsCreate a new figure, or activate an existing figure.Create fig and ax variables using subplots method, where default nrows and ncols are 1, projection=’3d”.Get x, y and z using ... Read More

Multiple axes in Matplotlib with different scales

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 17-Mar-2021 07:55:01

4K+ Views

In the following code, we will see how to create a shared Y-axis.StepsCreate fig and ax variables using subplots method, where default nrows and ncols are 1.Plot line with lists passed in the argument of plot() method with color="red".Create a twin of Axes with a shared X-axis but independent Y-axis.Plot ... Read More

Making matplotlib scatter plots from dataframes in Python's pandas

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 17-Mar-2021 07:54:06

821 Views

Using Pandas, we can create a dataframe and can create a figure and axes variable using subplot() method. After that, we can use the ax.scatter() method to get the required plot.StepsMake a list of the number of students.Make a list of marks that have been obtained by the students.To represent ... Read More

Prevent scientific notation in matplotlib.pyplot

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 17-Mar-2021 07:53:27

14K+ Views

To prevent scientific notation, we must pass style='plain' in the ticklabel_format method.StepsPass two lists to draw a line using plot() method.Using ticklabel_format() method with style='plain'. If a parameter is not set, the corresponding property of the formatter is left unchanged. Style='plain' turns off scientific notation.To show the figure, use plt.show() ... Read More

Manually add legend Items Python Matplotlib

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 17-Mar-2021 07:52:12

21K+ Views

Using plt.legend() method, we can create a legend, and passing frameon would help to keep the border over there.StepsSet the X-axis label using plt.xlabel() method.Set the Y-axis label using plt.ylabel() method.Draw lines using plot() method.Location and legend drawn flags can help to find a location and make the flag True ... Read More

Show only certain items in legend Python Matplotlib

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 17-Mar-2021 07:51:23

1K+ Views

Using plt.legend(), we can add or show certain items just by putting the values in the list.StepsSet the X-axis label using plt.xlabel() method.Set the Y-axis label using plt.ylabel() method.Plot the lines using the lists that are passed in the plot() method argument.Location and legend_drawn flags can help to find a ... Read More

How to add a second X-axis in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 17-Mar-2021 07:48:18

9K+ Views

We can use the twiny() method to create a second X-axis. Similarly, using twinx, we can create a shared Y-axis.StepsCreate fig and ax variables using subplots method, where default nrows and ncols are 1.Plot line with lists passed in the argument of plot() method with color="red".Create a twin of Axes ... Read More

What does .shape[] do in “for i in range(Y.shape[0])” using Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 17-Mar-2021 07:45:39

841 Views

The shape property is usually used to get the current shape of an array, but it may also be used to reshape the array in-place by assigning a tuple of array dimensions to it.StepsGet an array Y using np.array method.Y.shape would return a tuple (4, ).Y.shape[0] method would return 4, ... Read More

Automatically run %matplotlib inline in IPython Notebook

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 16-Mar-2021 20:15:30

217 Views

%matplotlib would return the backend value.%matplotlib auto would return the name of the backend, over Ipython shell.ExampleIn [1]: %matplotlib autoOutputUsing matplotlib backend: GTK3Agg

Advertisements