Found 784 Articles for Data Visualization

How to remove X or Y labels from a Seaborn heatmap?

Rishikesh Kumar Rishi
Updated on 03-Jun-2021 13:08:58

7K+ Views

To remove X or Y labels from a Seaborn heatmap, we can use yticklabel=False.StepsSet the figure size and adjust the padding between and around the subplots.Make a Pandas dataframe with 5 columns.Use heatmap() method to plot rectangular data as a color-encoded matrix with yticklabels=False.To display the figure, use show() method.Exampleimport seaborn as sns import pandas as pd import numpy as np from matplotlib import 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=["col1", "col2", "col3", "col4", "col5"]) sns.heatmap(df, yticklabels=False) plt.show()OutputRead More

Best way to display Seaborn/Matplotlib plots with a dark iPython Notebook profile

Rishikesh Kumar Rishi
Updated on 03-Jun-2021 13:05:32

277 Views

To display a Seaborn/Matplolib plot with a dark background, we can use "dark" in set_style() method that gives an aesthetic style to the plots.StepsSet the figure size and adjust the padding between and around the subplots.Use "dark" in set_style() method that sets the aesthetic style.Create a Pandas dataframe with two columns.Show point estimates and confidence intervals with bars, using bar plot() method.Rotate xticks by 45 degrees.To display the figure, use show() method.Exampleimport pandas import matplotlib.pylab as plt import seaborn as sns import numpy as np plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True sns.set_style("dark") df = pandas.DataFrame({"X-Axis": [np.random.randint(10) ... Read More

Automatic detection of display availability with Matplotlib

Rishikesh Kumar Rishi
Updated on 03-Jun-2021 13:04:06

166 Views

To detect display availability with matplotlib, we can take the following steps −StpsImport os module.Use os.environ["DISPLAY"] to get the available display.Exampleimport os env = os.environ["DISPLAY"] print("Automatic detected display availability: ", env)OutputAutomatic detected display availability: 0

Turn off the left/bottom axis tick marks in Matplotlib

Rishikesh Kumar Rishi
Updated on 03-Jun-2021 13:03:11

427 Views

To turn off the left or bottom axis tick marks in matplotlib, we can use length=0 for the axes.StepsSet the figure size and adjust the padding between and around the subplots.Create x and y data points using numpy.Plot the x and y data points using plot() method.Use tick_params() method with length=0.To display the figure, use show() method.Exampleimport numpy as np import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True x = np.linspace(-2, 2, 10) y = np.sin(x) plt.plot(x, y) plt.tick_params(axis='both', which='both', length=0) plt.show()OutputRead More

Setting the spacing between grouped bar plots in Matplotlib

Rishikesh Kumar Rishi
Updated on 03-Jun-2021 13:02:08

3K+ Views

To set the spacing between grouped bar plots in matplotlib, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Create a dictionary for bar details to be plotted.Make a Pandas dataframe using dictionary, d.Plot the bar using dictionary, d, with align="center".To display the figure, use show() method.Exampleimport matplotlib.pyplot as plt import pandas as pd plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True d = {"Name": ["John", "Jacks", "James", "Joe"], "Age": [23, 12, 30, 26], "Marks": [98, 85, 70, 77]} df = pd.DataFrame(d) df.set_index('Name').plot(kind="bar", align='center', width=0.1) plt.tick_params(rotation=45) plt.show()OutputRead More

How to show two different colored colormaps in the same imshow Matplotlib?

Rishikesh Kumar Rishi
Updated on 03-Jun-2021 13:00:42

1K+ Views

To show two different colored colormaps in the same imshow matplotlib, we can take the following steps −Set the figure size and adjust the padding between and around the subplots.Make a 2D matrix of 5×5 dimension.Get masked matrix, data1 and data2, with positive and negative values.Create a figure and a set of subplots.Display the data as an image, i.e., on a 2D regular raster, with data1 and data2.To make two different colorbars, use colorbar method.Set the colorbar for both the images.Set the label of the colorbars.To display the figure, use show() method.Exampleimport matplotlib.pyplot as plt import numpy as np ... Read More

How to make custom grid lines in Seaborn heatmap?

Rishikesh Kumar Rishi
Updated on 03-Jun-2021 12:57:23

4K+ Views

To make custom grid lines in Seaborn heatmap, we can use linewidths and linecolor values in the heatmap() method.StepsSet the figure size and adjust the padding between and around the subplots.Create a Pandas dataframe with 5 columns.Use heatmap() method to plot the rectangular data as a color-encoded matrix.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=["col1", "col2", "col3", "col4", "col5"]) sns.heatmap(df, linewidths=4, linecolor='green') plt.show()OutputRead More

How to plot scatter points in a 3D figure with a colorbar in Matplotlib?

Rishikesh Kumar Rishi
Updated on 03-Jun-2021 12:55:07

3K+ Views

To plot scatter points in a 3D figure with a colorbar in matplotlib, we can use the scatter() and colorbar() methods.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 axis as a subplot arrangement.Create xs, ys and zs data points using numpy.Use scatter() method to create a scatter plot.Use colorbar() method with scatter scalar mappable instance for colorbar.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 fig = plt.figure() ax ... Read More

Line colour of a 3D parametric curve in Python's Matplotlib.pyplot

Rishikesh Kumar Rishi
Updated on 03-Jun-2021 12:51:08

300 Views

To plot the line color of a 3D parametric curve in Matplotlib, we can take the following steps −Set 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 axis as a subplot arrangement.To make a parametric curve, initialize theta, z, r, x  and y variables.Plot x, y and z data points using scatter() method.Set the title of the plot.To display the figure, use show() method.Exampleimport numpy as np import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True fig = plt.figure() ax = fig.add_subplot(projection='3d') ... Read More

How do I display real-time graphs in a simple UI for a Python program?

Rishikesh Kumar Rishi
Updated on 04-Jun-2021 13:50:18

675 Views

To display real-time graphs in a simple UI for a Python program, we can animate the contour plot.StepsSet the figure size and adjust the padding between and around the subplots.Create a random data of shape 10×10 dimension.Create a figure and a set of subplots using subplots() method.Make an animation by repeatedly calling a function *func*, using FuncAnimation() class.To update the contour value in a function, we can define a method, animate(), that can be used in FuncAnimation() class.To display the figure, use show() method.Exampleimport numpy as np import matplotlib.pyplot as plt import matplotlib.animation as animation plt.rcParams["figure.figsize"] = [7.50, 3.50] ... Read More

Advertisements