- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 784 Articles for Data Visualization
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
11K+ Views
To fill the area under step curve using pyplot, we can take the following stepsStepsSet the figure size and adjust the padding between and around the subplots.Ceate random data points, x, y1 and y2, using numpy.To fill the area under the curve, put x and y with ste="pre", using fill_between() method.Plot (x, y1) and (x, y2) lines using plot() method with drawstyle="steps" method.To display the figure, use show() method.Exampleimport matplotlib.pyplot as plt import numpy as np plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True x = np.linspace(-10, 10, 100) y1 = np.sin(x) y2 = np.cos(x plt.fill_between(x, y1, step="pre", alpha=0.4) ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
465 Views
To make a boxplot with variable length data in Matplotlib, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Make a list of data points.Make a box and whisker plot using boxplot() 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 data = [[2, 4, 1, 3], [0, 4, 3, 2], [0, 0, 1, 0]] plt.boxplot(data) plt.show()Output
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
5K+ Views
To save all the open Matplotlib figures in one file at once, we can take follwong steps −Set the figure size and adjust the padding between and around the subplots.Create a new figure (fig1) or activate an existing figure using figure() method.Plot the first line using plot() method.Create a new figure (fig2) or activate an existing figure using figure() method.Plot the Second line using plot() method.Initialize a variable, filename, to make a pdf file.Create a user-defind function, save_multi_image, and call it to save all the open matplotlib figures in one file at once. Create a new PdfPages object, pp.Get the ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
3K+ Views
To plot a histogram, with collections.Counter, we can use bar() method. In bar() method, we can use collections.counter() to get the frequency for each element. Put the elements and their frequency as height.StepsSet the figure size and adjust the padding between and around the subplots.Make a list of a data points.Get the dictionary, d, using collections.Counter().Make bar plot with d.keys() and d.values().To display the figure, use show() method.Exampleimport collections from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True data = [0, 1, 2, 4, 1, 3, 0, 4, 1, 4, 3, 5, 6, 5, ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
2K+ Views
To show the title for the diagram for Seaborn pairplot(), we can use pp.fig.suptitle() method.StepsSet the figure size and adjust the padding between and around the subplots.Create a Pandas dataframe, i.e., a two-dimensional, size-mutable, potentially heterogeneous tabular data.Plot pairwise relationships in a dataset.Add a centered title to the figure.To display the figure, use show() method.Exampleimport seaborn as sns import pandas as pd import numpy as np import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True df = pd.DataFrame(np.random.random((5, 5)), columns=["a", "b", "c", "d", "e"]) pp = ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
132 Views
To attach a pyplot function to a figure instance, we can use figure() method and add an axes to it.StepsSet the figure size and adjust the padding between and around the subplots.Create a new figure or activate an existing figure using figure() method.Add an '~.axes.Axes' to the figure as part of a subplot arrangement.Set a title to this axis using set_title() method.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 fig = plt.figure() ax = fig.add_subplot() ax.set_title("My Title!") plt.show()OutputRead More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
790 Views
To plot events on time using Matplotlib, we can take the following steps −Set the figure size and adjust the padding between and around the subplotsMake a list of data points, where event could occur.Plot a horizontal line with y, xmin and xmax.Plot identical parallel lines at the given positions.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 a = [1, 2, 5, 6, 9, 11, 15, 17, 18] plt.hlines(1, 0, 24) plt.eventplot(a, orientation='horizontal', colors='b') plt.show()Output
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
4K+ Views
To add legend to imshow() in Matplotlib, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create random data using numpy.Initialize a color map.Get the unique data points from sample data, step 2.Plot each color with different labels and color, to place on the legend.Place a legend at the upper right corner within a box.To display the figure, use show() method.Exampleimport numpy as np from matplotlib import pyplot as plt, cm plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True data = np.random.rand(3, 3) cmap = cm.YlOrBr unique_data = np.unique(data) i ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
730 Views
To pause a pylab figure until a key is pressed of mouse is clicked, we can use"button_press_event" key event.StepsSet the figure size and adjust the padding between and around the subplots.Set the "TkAgg" background.Turn the interactive mode ON.Create a new figure or activate an existing figure.Make a variable, pause=False.Whenever "button_press_event", pause the figure.Bind the function to the event.Create data, x and y data points using numpy.Iterate a True loop to change the plot line and color.To display the figure, use show() method.Exampleimport matplotlib from matplotlib import pyplot as plt import numpy as np plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = ... Read More