Rishikesh Kumar Rishi has Published 1162 Articles

Save the plots into a PDF in matplotlib

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 12-Sep-2023 03:11:35

36K+ Views

Using plt.savefig("myImagePDF.pdf", format="pdf", bbox_inches="tight") method, we can save a figure in PDF format.StepsCreate a dictionary with Column 1 and Column 2 as the keys and Values are like i and i*i, where i is from 0 to 10, respectively.Create a data frame using pd.DataFrame(d), d created in step 1.Plot the ... Read More

How to get the correlation between two columns in Pandas?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 12-Sep-2023 01:32:26

29K+ Views

We can use the .corr() method to get the correlation between two columns in Pandas. Let's take an example and see how to apply this method.StepsCreate a two-dimensional, size-mutable, potentially heterogeneous tabular data, df.Print the input DataFrame, df.Initialize two variables, col1 and col2, and assign them the columns that you ... Read More

How to hide axes and gridlines in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 12-Sep-2023 01:31:20

34K+ Views

To hide axes (X and Y) and gridlines, we can take the following steps −Create x and y points using numpy.Plot a horizontal line (y=0) for X-Axis, using the plot() method with linestyle, labels.Plot x and y points using the plot() method with linestyle, labels.To hide the grid, use plt.grid(False).To hide the axes, ... Read More

How to remove or hide X-axis labels from a Seaborn / Matplotlib plot?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 12-Sep-2023 01:10:01

31K+ Views

To remove or hide X-axis labels from a Seaborn / Matplotlib plot, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Use sns.set_style() to set an aesthetic style for the Seaborn plot.Load an example dataset from the online repository (requires Internet).To hide ... Read More

How to turn off the ticks and marks of a matlibplot axes?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 10-Sep-2023 08:25:31

39K+ Views

To turn off the ticks and marks of a matplotlib axes, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create x and y data points using numpy.Plot x and y data points using plot() method.Get the current axis of the ... Read More

How do you create line segments between two points in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 10-Sep-2023 07:43:29

34K+ Views

To create line segments between two points in matplotlib, we can take the following stepsSet the figure size and adjust the padding between and around the subplots.To make two points, create two lists.Extract x and y values from point1 and point2.Plot x and y values using plot() method.Place text for ... Read More

Plot data from CSV file with Matplotlib

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 09-Sep-2023 23:24:14

36K+ Views

To extract CSV file for specific columns to list in python, we can use Pandas read_csv() method.StepsMake a list of columns that have to be extracted.Use read_csv() method to extract the CSV file data into a data frame.Print the exracted data.Plot the data frame using plot() method.To display the figure, ... Read More

How to change xticks font size in a matplotlib plot?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 08-Sep-2023 23:25:53

35K+ Views

To change the font size of xticks in a matplotlib plot, we can use the fontsize parameter.StepsImport matplotlib and numpy.Set the figure size and adjust the padding between and around the subplots.Create x and y data points using numpy.Plot the x and y data points using plot() method.Set the font ... Read More

How to get nth row in a Pandas DataFrame?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 06-Sep-2023 21:48:02

36K+ Views

To get the nth row in a Pandas DataFrame, we can use the iloc() method. For example, df.iloc[4] will return the 5th row because row numbers start from 0.StepsMake two-dimensional, size-mutable, potentially heterogeneous tabular data, df.Print input DataFrame, df.Initialize a variable nth_row.Use iloc() method to get nth row.Print the returned ... Read More

How to change the range of the X-axis and Y-axis in Matplotlib?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 02-Sep-2023 10:31:28

71K+ Views

To change the range of X and Y axes, we can use xlim() and ylim() methods.StepsSet the figure size and adjust the padding between and around the subplots.Create x and y data points using numpy.Plot x and y data points using plot() method.Set the X and Y axes limit.To display ... Read More

Advertisements