Found 784 Articles for Data Visualization

How to plot a line graph from histogram data in Matplotlib?

Rishikesh Kumar Rishi
Updated on 11-May-2021 12:19:44

6K+ Views

To plot a line graph from histogram data in matplotlib, we use numpy histogram method to compute the histogram of a set of data.StepsAdd a subplot to the current figure, nrows=2, ncols=1 and index=1.Use numpy histogram method to get the histogram of a set of data.Plot the histogram using hist() method with edgecolor=black.At index 2, use the computed data (from numpy histogram). To plot them, we can use plot() method.To display the figure, use show() method.Exampleimport numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True plt.subplot(211) data = np.array(np.random.rand(100)) y, binEdges = np.histogram(data, bins=100) plt.hist(data, bins=100, edgecolor='black') ... Read More

How to plot a multi-colored line, like a rainbow using Matplotlib?

Rishikesh Kumar Rishi
Updated on 11-May-2021 12:15:51

2K+ Views

To plot multi-colored lines, like a rainbow, we can create a list of seven rainbow colors (VIBGYOR).StepsCreate x for data points using numpy.Create a list of colors (rainbow VIBGYOR).Iterate in the range of colors list length.Plot lines with x and y(x+i/20) using plot() method, with marker=o, linewidth=7 and colors[i] where i is the index.To display the figure, use show() method.Exampleimport numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True x = np.linspace(-1, 1, 10) colors = ["red", "orange", "yellow", "green", "blue", "indigo", "violet"] for i in range(len(colors)):    plt.plot(x, x+i/20, c=colors[i], lw=7, marker='o') plt.show()OutputRead More

How to remove the label on the left side in matplotlib.pyplot pie charts?

Rishikesh Kumar Rishi
Updated on 11-May-2021 12:11:13

2K+ Views

To remove the label on the left side in a matplotlib pie chart, we can take the following steps −Create lists of hours, activities, and colors.Plot a pie chart using pie() method.To hide the label on the left side in matplotlib, we can use plt.ylabel("") with ablank string.Exampleimport matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True hours = [8, 1, 11, 4] activities = ['sleeping', 'exercise', 'studying', 'working'] colors = ["grey", "green", "orange", "blue"] plt.pie(hours, labels=activities, colors=colors, autopct="%.2f") plt.ylabel("") plt.show()Output

How to animate a line plot in Matplotlib?

Rishikesh Kumar Rishi
Updated on 28-May-2021 15:16:11

3K+ Views

To animate the line plot in matplotlib, we can take the following steps −Create a figure and a set of subplots using subplots() method.Limit x and y axes scale.Create x and t data points using numpy.Return coordinate matrices from coordinate vectors, X2 and T2.Plot a line with x and F data points using plot() method.To make animation plot, update y data.Make an animation by repeatedly calling a function *func*, current fig, animate, and interval.To display the figure, use show() method.Exampleimport numpy as np from matplotlib import pyplot as plt, animation plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True fig, ax = ... Read More

How can I display text over columns in a bar chart in Matplotlib?

Rishikesh Kumar Rishi
Updated on 11-May-2021 11:59:47

3K+ Views

To display text over columns in a bar chart, we can use text() method so that we could place text at a specific location (x and y) of the bars column.StepsCreate lists for x, y and percentage.Make a bar plot using bar() method.Iterate zipped x, y and percentage to place text for the bars column.To display the figure, use show() method.Exampleimport matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True x = ['A', 'B', 'C', 'D', 'E'] y = [1, 3, 2, 0, 4] percentage = [10, 30, 20, 0, 40] ax = plt.bar(x, y) for x, y, p in zip(x, y, percentage): ... Read More

How to handle an asymptote/discontinuity with Matplotlib?

Rishikesh Kumar Rishi
Updated on 11-May-2021 11:48:28

866 Views

To handle an asymptote/discontinuity with matplotlib, we can take the following steps −Create x and y data points using numpy.Turn off the axes plot.Plot the line with x and y data points.Add a horizontal line across the axis, x=0.Add a vertical line across the axis, y=0.Place legend for the curve y=1/x.To display the figure, use show() method.Exampleimport numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True x = np.linspace(-1, 1, 100) y = 1 / x plt.axis('off') plt.plot(x, y, label='y=1/x') plt.axhline(y=0, c='red') plt.axvline(x=0, c='red') plt.legend(loc='upper left') plt.show()OutputRead More

Difference Between RAID 0 and RAID 1

Kiran Kumar Panigrahi
Updated on 21-Feb-2023 15:17:57

482 Views

RAID or Redundant Array of Independent Disk is a set of disk organization techniques developed to increase the reliability and performance of a system. There are various types of RAID techniques such as RAID 0, RAID 1, RAID 2, … RAID 5. Read this article to learn more about RAID 0 and RAID 1 and how they are different from each other. What is RAID 0? RAID 0 stands for Redundant Array of Independent Disk level 0. There is no redundant data stored here, so performance is very good. But the failure of any disk in the array results in loss of data. In RAID 0, ... Read More

Difference Between Data Warehouse and Data Mart

Kiran Kumar Panigrahi
Updated on 20-Dec-2022 12:42:01

617 Views

Both data warehouses and data marts serve the same purpose; they are data repositories. However, we can differentiate a data warehouse from a data mart on the basis of the amount of data they can store. A data warehouse a large repository of data that is collected from different organizations, whereas a data mart is a logical subset of a data warehouse. Read this article to find out more about data warehouses and data marts and how they are different from each other. Let's start with a basic overview of the two. What is a Data Warehouse? Data Warehouse is ... Read More

Difference Between Abstraction and Encapsulation

Kiran Kumar Panigrahi
Updated on 13-Sep-2023 14:36:47

34K+ Views

Abstraction is a process of hiding the implementation details of a system from the user, and only the functional details will be available to the user end. On the other hand, Encapsulation is a method of wrapping up the data and code acting on the data into a single unit. Read this article to find out more about abstraction and encapsulation and how they are different from each other. What is Abstraction? Abstraction is defined as a process of hiding the implementation details of a system from the user. Thus, by using abstraction, we provided only the functionality of the ... Read More

Difference Between Abstraction and Data Hiding

Kiran Kumar Panigrahi
Updated on 20-Feb-2023 15:10:46

7K+ Views

In object oriented programming (OOP), abstraction and data hiding are two important concepts. Abstraction is a process of extracting important information without involving the complete detail of the system. On the other hand, data hiding is a process of wrapping the data in a single unit, i.e., to achieve data encapsulation. Read this article to learn more about abstraction and data hiding and how these two concepts are different from each other. What is Abstraction? Abstraction, or data abstraction, is one of the object-oriented methodologies. Abstraction is defined as the process of hiding the internal implementation and keeping the complicated ... Read More

Advertisements