Data Visualization Articles

Page 3 of 68

Plot multiple boxplots in one graph in Pandas or Matplotlib

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 13-Sep-2023 36K+ Views

To plot multiple boxplots in one graph in Pandas or Matplotlib, we can take the following steps −StepsSet the figure size and adjust the padding between and around the subplots.Make a Pandas data frame with two columns.Plot the data frame using plot() method, with kind='boxplot'.To display the figure, use show() method.Exampleimport pandas as pd import numpy as np from matplotlib import pyplot as plt # Set the figure size plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True # Pandas dataframe data = pd.DataFrame({"Box1": np.random.rand(10), "Box2": np.random.rand(10)}) # Plot the dataframe ax = data[['Box1', 'Box2']].plot(kind='box', title='boxplot') # Display ...

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 41K+ 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 or remove X-axis labels, use set(xlabel=None).To display the figure, use show() method.Examplefrom matplotlib import pyplot as plt import seaborn as sns plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True sns.set_style("whitegrid") tips = sns.load_dataset("tips") ax = sns.boxplot(x="day", y="total_bill", data=tips) ax.set(xlabel=None) plt.show()Output

Read More

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

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 10-Sep-2023 47K+ 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 both the points.To display the figure, use show() method.Exampleimport matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True point1 = [1, 2] point2 = [3, 4] x_values = [point1[0], point2[0]] y_values = [point1[1], point2[1]] plt.plot(x_values, y_values, 'bo', linestyle="--") plt.text(point1[0]-0.015, point1[1]+0.25, "Point1") plt.text(point2[0]-0.050, point2[1]-0.25, "Point2") plt.show()Output

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 80K+ 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 the figure, use show() method.Exampleimport numpy as np import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True x = np.linspace(-15, 15, 100) y = np.sin(x) plt.plot(x, y) plt.xlim(-10, 10) plt.ylim(-1, 1) plt.show()Output

Read More

How to plot CSV data using Matplotlib and Pandas in Python?

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 26-Aug-2023 44K+ Views

To plot CSV data using Matplotlib and Pandas in Python, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Make a list of headers of the .CSV file.Read the CSV file with headers.Set the index and plot the dataframe.To display the figure, use show() method.Exampleimport pandas as pd import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True headers = ['Name', 'Age', 'Marks'] df = pd.read_csv('student.csv', names=headers) df.set_index('Name').plot() plt.show()Output

Read More

How to label a line in Matplotlib (Python)?

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 25-Aug-2023 52K+ Views

To label a line in matplotlib, we can use label in the argument of plot() method,StepsSet the figure size and adjust the padding between and around the subplots.Plot with label="line1" using plot() method.Plot with label="line2" using plot() method.To place a legend on the figure, use legend() method.To display the figure, use show() method.Examplefrom matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True line1, = plt.plot([1, 2, 3], label="line1") line2, = plt.plot([3, 2, 1], label="line2") leg = plt.legend(loc='upper center') plt.show()Output

Read More

How to plot a function defined with def in Python? (Matplotlib)

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 24-Aug-2023 75K+ Views

To plot a function defined with def in Python, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create a user-defined function using, def, i.e., f(x).Create x data points using numpy.Plot x and f(x) using plot() method.To display the figure, use show() method.Exampleimport numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True def f(x):    return np.sin(x) + x + x * np.sin(x) x = np.linspace(-10, 10, 100) plt.plot(x, f(x), color='red') plt.show()Output

Read More

Finding the outlier points from Matplotlib

Atharva Shah
Atharva Shah
Updated on 21-Aug-2023 2K+ Views

Outliers, or data points that are markedly different from other observations, are frequently encountered in data analysis. To prevent them from skewing the outcomes of statistical analysis, it is essential to recognise and handle these outliers. We will look at finding the outlier points from Matplotlib, a well-known Python data visualization library, in this technical blog post. Installation and Syntax The popular Python module Matplotlib is used to build static, animated, and interactive visualizations. Pip, a Python package installer, may be used to install it. Run the following line in your terminal to install Matplotlib − pip install matplotlib ...

Read More

Difference between Ultra ATA and SATA

Md. Sajid
Md. Sajid
Updated on 17-Aug-2023 2K+ Views

Ultra ATA and SATA (Serial ATA) are two separate interfaces used to connect storage devices to a computer system, such as hard disc drives (HDDs) and solid-state drives (SSDs). Both interfaces have previously been widely used on several generations of devices. Read this article to find out more about Ultra ATA and SATA and how they are different from each other. What is Ultra ATA? Ultra ATA (also known as IDE or PATA, or Parallel ATA) is an older interface standard that was commonly used for connecting storage devices to computer systems, such as hard disc drives (HDDs) and optical ...

Read More

How to Color Scatterplot by a variable in Matplotlib?

Niharika Aitam
Niharika Aitam
Updated on 09-Aug-2023 3K+ Views

There are several ways to color scatterplot by a variable in Matplotlib of the python library. We have three parameters in scatter function namely cmap, alpha and c using which we can change the color of the plot. Matplotlib is one of the libraries available in python which is used to plot and visualize the given data. This can be used as the extension of the Numpy library to plot the arrays. This library has the module called pyplot which makes the visualization and plotting the data very easy. This pyplot module has many functions and parameters which ...

Read More
Showing 21–30 of 680 articles
« Prev 1 2 3 4 5 68 Next »
Advertisements