![]() Grayscale with values from 0.0 to 1.0.Here R=Red, G=Green, B=Blue color = ‘#e3e3e3’ The color hex code #RRGGBB with values from 00 to FF.The common names of colors like red, blue, brown, magenta, etc.The output will be the same plot with the red-colored grid as shown above.įor color, you can use any of the following strings as values: For instance, if the above code snippet is changed: fig = plt.figure() ax = plt.axes() plt.grid(b=False, color = 'r') However, if any keyword arguments(like alpha, color, linewidth, etc) is present, then b will be set to True irrespective of the value of b given. ![]() The optional parameter b takes boolean values(True or False). The color is a keyword argument that assigns the color to the grid. plt.grid()Ī simple code to create a figure is as follows: import matplotlib.pyplot as plt fig = plt.figure() ax = plt.axes() plt.grid() plt.show() Grids help to easily identify and correlate values in the plot. Let’s make the plots beautiful by harnessing the various features of pyplot. The size of the figure is also a bit small to my liking. There’s no grid to easily identify and correlate values. There are neither labels nor title to provide some valuable information to a third person. The graph seems to appear too ordinary and bland. ()computes the PDF at any point for a given value of mean(mu) and standard deviation(std). () returns a normal continuous random variable. np.linspace() returns evenly spaced samples(number of samples equal to num) over a specific interval. As our primary concern is about making plots more beautiful, the explanation of code about the mathematical aspects will be rather brief. The code creates a simple plot of the normal distribution with mean=0 and standard deviation=1. Plot 1: Normal Distribution | Photo by ©iambipin import numpy as np import matplotlib.pyplot as plt import scipy.stats as stats mu = 0 std = 1 x = np.linspace(start=-4, stop=4, num=100) y = (x, mu, std) plt.plot(x, y) plt.show() It can be easily identified by the bell-shaped curve(Probability Density Function) and its symmetry. For the uninitiated, normal distribution is a continuous probability distribution for a real-valued random variable. Let’s create some code in Jupyter notebook to create a normal distribution. ![]() Visualizations can be quickly generated using a pyplot. ![]() pyplot function can be made to create a figure, create a plotting area in a figure, plot some lines in a plotting area, decorate the plot with labels, etc. matplotlib.pyplot is a collection of command style functions that enables matplotlib to work like MATLAB. Matplotlib is a comprehensive library for creating static, animated, and interactive visualizations in Python. Hence we would be considering Matplotlib for plotting. In the world of data science, Python is the programming language of choice(the undisputed leader in data science). Hence acquiring skills in this arena is gaining prominence. Consequently, data visualization started playing a pivotal role in the day to day affairs than ever before. As our world has become more and more data-driven, important decisions of the people who could make a tremendous impact on the world we live in, like the governments, big corporates, politicians, business tycoons(you name it) are all influenced by the data in an unprecedented manner. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |