- 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)
392 Views
To handle times with a time zone in Matplotlib, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create a dataframe, i.e., two-dimensional, size-mutable, potentially heterogeneous tabular data.To handle times with a time zone, use pytz library that brings the Olson tz database into Python. This library allows accurate and cross-platform timezone calculations.Plot the dataframe using plot() method.To display the figure, use show() method.Exampleimport pandas as pd import numpy as np from matplotlib import pyplot as plt import pytz plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True df = pd.DataFrame( ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
4K+ Views
To change the default path for "save the figure", we can use rcParams["savefig.directory"] to set the directory path.StepsSet the figure size and adjust the padding between and around the subplots.Create random data using numpy.Use imshow() method. Display the data as an image, i.e., on a 2D regular raster.Save the figure using plt.savefig() method.Exampleimport os import numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True dir_name = "C:/Windows/Temp/" plt.rcParams["savefig.directory"] = os.chdir(os.path.dirname(dir_name)) data = np.random.rand(5, 5) plt.imshow(data, cmap="copper") plt.savefig("img.png")OutputWhen we execute the code, it will save the following plot as ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
6K+ Views
To have actual or any custom values in Matplotlib pie chart displayed, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Make lists of labels, fractions, explode position and get the sum of fractions to calculate the percentageMake a pie chart using labels, fracs and explode with autopct=lambda p: .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 labels = ('Read', 'Eat', 'Sleep', 'Repeat') fracs = [5, 3, 4, 1] total = sum(fracs) explode = (0, 0.05, 0, 0) ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
1K+ Views
To plot MFCC in Python, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Open and read a WAV file.Compute MFCC features from an audio signal.Create a figure and a set of subplots.Interchange two axes of an arrayDisplay the data as an image, i.e., on a 2D regular raster.To display the figure, use show() method.Examplefrom python_speech_features import mfcc import scipy.io.wavfile as wav import matplotlib.pyplot as plt import numpy as np plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True (rate, sig) = wav.read("my_audio.wav") mfcc_data = mfcc(sig, rate) fig, ax = plt.subplots() ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
262 Views
To convert from scatter size to data coordinates in Matplotlib, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create x and s data points using numpy.Create a figure and a set of subplots.Make a scatter plot with X and s, cmap and color info.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 X = np.array([[1, 1], [2, 1], [2.5, 1]]) s = np.array([20, 10000, 10000]) fig, ax = plt.subplots() ax.scatter(X[:, 0], X[:, ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
355 Views
To load a .ttf file in Matplotlib using mpl.rcParams, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Initialize the path for the .ttf file.Get an instance of a class for storing and manipulating the font properties.Set the font family with the name of the font that best matches the font properties.Create a figure and a set of subplots.Set the title of the figure.To display the figure, use show() method.Examplefrom matplotlib import pyplot as plt, font_manager as fm plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True path = '/usr/share/fonts/truetype/malayalam/Karumbi.ttf' ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
1K+ Views
To scroll backward and forwards (left and right keys) through Matplotlib plots, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create curr_pos and y using numpy.Create a new figure or activate an existing figure using figure() method.Bind the function to the event, i.e., key_press_event.Add an '~.axes.Axes' to the figure as part of a subplot arrangement.Plot curr_pos and y data points using plot() method.If the left and right arrow keys could be used, then the curve could go right and left accordingly.To display the figure, use show() method.Exampleimport numpy as np ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
1K+ Views
To increase the thickness of error line in a Matplotlib bar chart, we can use err_kw=dict() with their properties.StepsSet the figure size and adjust the padding between and around the subplots.Make a dictionary of bar details.Create a figure and a set of subplots.Use bar() method to make a bar plot with yerr and err_kwTo display the figure, use show() method.Exampleimport matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True bar_details = { "labels": ['G1', 'G2', 'G3', 'G4', 'G5'], "men_means": [20, 35, 30, 35, 27], "men_std": [2, 3, 4, 1, 2], "width": 0.35 } ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
3K+ Views
To plot a time series array, with confidence intervals displayed in Python, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Get the time series array.Initialize a variable, n_steps, to get the mean and standard deviation.Get the under and above lines for confidence intervals.Plot the mean line using plot() method.Use fill_between() method to get the confidence interval.To display the figure, use show() method.Exampleimport numpy as np import pandas as pd import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True time_series_array = np.sin(np.linspace ... Read More
![Rishikesh Kumar Rishi](https://www.tutorialspoint.com/assets/profiles/318007/profile/60_254496-1615815423.jpg)
1K+ Views
To plot a watermark image in Matplotlib, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Return a sample data file using get_sample_data() method.Create a figure and a set of subplots.Plot the data points using plot() method, with alpha=0.7 and marker face color mfc="orange".Add a non-resampled image to the figure.To display the figure, use show() method.Exampleimport numpy as np import matplotlib.cbook as cbook import matplotlib.image as image import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True with cbook.get_sample_data('logo2.png') as file: im = image.imread(file) fig, ax = ... Read More