- 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)
278 Views
To get the properties of picked objects in matplotlib 3d, we can take the following steps.StepsSet the figure size and adjust the padding between and around the subplots.Create a new figure or activate an existing figure.Add an 'ax' to the figure as part of a subplot arrangement.Make a scatter plot of random data points.Bind the function *pick_event_method* to the event *pick_event*.Print x, y and z coordinates of the event.To display the figure, use Show() method.Exampleimport matplotlib.pyplot as plt import numpy as np plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True fig = plt.figure() ax = fig.add_subplot(111, projection='3d') ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
7K+ Views
To plot a plane using some mathematical equation in matplotlib, we can take the following steps.StepsSet the figure size and adjust the padding between and around the subplots.Create x and y data points using numpy.Using x and y, find the equation of the plane (eq).Create a new figure or activate an existing figure.Get the current axis with projection='3d'.Create a surface plot with x, y and eq data points.To display the figure, use Show() method.Exampleimport numpy as np import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True x = np.linspace(-10, 10, 100) y = np.linspace(-10, 10, 100) ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
1K+ Views
To plot a 3D surface from a list of tuples in matplotlib, we can take the following steps.StepsSet the figure size and adjust the padding between and around the subplots.Make a list of tuples.Get the x, y and z data points from the list of tuples.Return the coordinate matrices from the coordinate vectors.Get the h data points for the surface plot.Create a new figure or activate an existing figure.Get the current axis, 3d, of the figure.Create a surface plot.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"] ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
8K+ Views
To plot a bar chart for a list in python matplotlib we can take the following steps.StepsSet the figure size and adjust the padding between and around the subplots.Make a list of data points.Make a bar plot with data.To display the figure, use Show() method.Examplefrom matplotlib import pyplot as plt # Set the figure size plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True # List of data points data = [0, 1, 3, 2, 1, 5, 2, 1, 4, 2, 4, 0] # Plot bar chart with data points plt.bar(data, data) # Display the plot plt.show() OutputIt will produce the following output −
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
425 Views
To preserve padding while setting axis limit, we can avoid using the tight layout, i.e., plt.rcParams["figure.autolayout"] = False.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 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.00, 3.50] plt.rcParams["figure.autolayout"] = True x = np.linspace(-10, 10, 100) y = np.sin(x) ** 2 plt.plot(x, y) plt.xlim([0, max(x)+0.125]) plt.ylim([0, max(y)+0.125]) plt.show() OutputIt will produce the following output −Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
11K+ Views
To show (0, 0) on matplotlib graph at the bottom left corner, we can use xlim() and ylim() methods.StepsSet the figure size and adjust the padding between and around the subplots.Make lists of data points for x and y.Plotx and y data points.Setx and y axes scale.To display the figure, use Show() method.Exampleimport numpy as np import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True x = np.array([0, 1, 3, 2, 1, 5]) y = np.array([0, 2, 4, 4, 3, 3]) plt.plot(x, y) plt.xlim([0, max(x)+0.5]) plt.ylim([0, max(y)+0.5]) plt.show() OutputIt will produce the ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
6K+ Views
To make graph k-NN decision boundaries in matplotlib, we can take the following Steps.StepsSet the figure size and adjust the padding between and around the subplots.Initialize a variable n_neighbors for number of neighbors.Load and return the iris dataset (classification).Create x and y data points.Make lists of dark and light colors.Classifier implementing the k-nearest neighbors vote.Create xmin, xmax, ymin and ymax data points.Create a new figure or activate an existing figure.Create a contourf plot.Create a scatter plot with X dataset.Set x and y axes labels, titles and scale of the axes.To display the figure, use Show() method.Exampleimport numpy as np import ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
2K+ Views
To make a mosaic plot in matplotlib, we can take the following steps.StepsSet the figure size and adjust the padding between and around the subplots.Install statsmodel package (pip install statsmodels). It is required to create mosaic plots. statsmodels is a Python package that provides a complement to scipy for statistical computations including descriptive statistics and estimation and inference for statistical models.Make a dictionary for mosaic plot.Create a mosaic plot from a contingency table.To display the figure, use Show() method.Exampleimport matplotlib.pyplot as plt from statsmodels.graphics.mosaicplot import mosaic plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True # Dictionary for mosaic plot ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
1K+ Views
To plot two violin plot series on the same graph using Seaborn, we can take the following Steps.StepsSet the figure size and adjust the padding between and around the subplots.Load an example dataset from the online repository (requires Internet).Create a violin plot using violinplot() method.To display the figure, use Show() method.Example# Import Seaborn and Matplotlib import seaborn as sns from matplotlib import pyplot as plt # Set the figure size plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True # Load an example dataset tips = sns.load_dataset("tips") # Create a violin plot using Seaborn sns.violinplot(x="day", y="total_bill", hue="time", data=tips) ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
343 Views
To autosize text in matplotlib, we can make a tight layout and rotate the ticks.StepsSet the figure size and adjust the padding between and around the subplots.Plot data points of the range of 10.Make a list of labels.Put ticks and labels on the X-axis with 30 rotation.To display the figure, use Show() method.Examplefrom matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True plt.plot(range(10)) labels = [7 * repr(i) for i in range(10)] plt.xticks(range(10), labels, rotation=30) plt.show() OutputIt will produce the following output −