Rishikesh Kumar Rishi has Published 1156 Articles

How to prevent numbers being changed to exponential form in Python Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 17-Mar-2021 08:17:18

1K+ Views

Using style='plain' in the ticklabel_format() method, we can restrict the value being changed into exponential form.StepsPass two lists to draw a line using plot() method.Use 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 ... Read More

Using Colormaps to set the color of line in Matplotlib

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 17-Mar-2021 08:16:54

1K+ Views

First, we can create a list of colors, and then, we can use the colors while plotting a line in a loop.StepsReturn evenly spaced numbers over a specified interval, store in x.Update x for four lines and get another variable for evenly_spaced_interval.Make a list of colors.Iterate color and set color ... Read More

Generating a movie from Python without saving individual frames to files

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 17-Mar-2021 08:14:06

374 Views

Using the FuncAnimation method, we can create a film. We will create a user-defined method, update, to keep on changing the position of particles and at the end, the method would return the scatter instance.StepsGet the particles initial position, velocity, force, and size.Create a new figure, or activate an existing ... Read More

How to turn on minor ticks only on the y-axis Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 17-Mar-2021 08:02:26

2K+ Views

First, we can create fig, ax using subplots() and then, we can plot the lines. After that, using ax.yaxis.set_minor_locator(tck.AutoMinorLocator()), we can turn on the minor ticks.StepsCreate fig and ax variables using subplots method, where default nrows and ncols are 1.Plot the line using two lists.Set the locator of the minor ... Read More

How to zoom subplots together in Matplotlib/Pyplot?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 17-Mar-2021 08:01:02

3K+ Views

We can use the attribute sharex = "ax1", and then, use the subplot method to zoom the subplots together.StepsAdd a subplot to the current figure with (nrow = 1, ncols = 2, index = 1).Add line on the current subplot with (nrow = 1, ncols = 2, index = 1).Add ... Read More

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

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

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

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

Advertisements