Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

1,016 Articles Published

Articles by Rishikesh Kumar Rishi

Page 12 of 102

Golang Program to convert Uppercase to Lowercase characters, using binary operator.

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 04-Apr-2022 922 Views

In Golang, we can use the binary operators "&" (AND) and "|" (OR) to convert strings from lowercase to uppercase and vice versa. Let's take a simple example and understand how to use these binary operators in Golang. Examplepackage main import "fmt" func main(){    fmt.Printf("Lowercase characters using OR operator: ")        for ch:='A'; ch

Read More

How to save a Librosa spectrogram plot as a specific sized image?

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 15-Feb-2022 5K+ Views

Librosa is a Python package that helps to analyse audio and music files. This package also helps to create music retrieval information systems. In this article, we will see how to save a Librosa spectrogram plot as an image of specific size.StepsSet the figure size and adjust the padding between and around the subplots..Create a figure and a set of subplots.Initialize three different variables, hl, hi, wi, to store samples per time in the spectrogram, height and width of the images.Load a demo track.Create a window, i.e., a list for audio time series..Compute a mel-scaled spectrogram, using melspectrogram() with window ...

Read More

How to change the attributes of a networkx / matplotlib graph drawing?

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 02-Feb-2022 2K+ Views

To change the attributes of a netwrokx/matplotlib graph drawing, we can take the following steps −StepsSet the figure size and adjust the padding between and around the subplots.Initialize a graph with edges, name, or graph attributes.Add the graph's attributes. Add an edge between u and v.Get the edge attributes from the graph.Position the nodes with circles.Draw the graph G with Matplotlib.To display the figure, use show() method.Exampleimport matplotlib.pyplot as plt import networkx as nx plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True G = nx.Graph() G.add_edge(0, 1, color='r', weight=2) G.add_edge(1, 2, color='g', weight=4) G.add_edge(2, 3, color='b', weight=6) G.add_edge(3, 4, ...

Read More

How to fill an area within a polygon in Python using matplotlib?

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 02-Feb-2022 2K+ Views

To fill an area within a polygon in Python using matplotlib, we can take the following steps −StepsSet the figure size and adjust the padding between and around the subplots.Create a figure and a set of subplots.Get an instance of a polygon.Get the generic collection of patches with iterable polygons.Add a 'collection' to the axes' collections; return the collection.To display the figure, use show() method.Exampleimport matplotlib.pyplot as plt from matplotlib.collections import PatchCollection from matplotlib.patches import Polygon import numpy as np plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True fig, ax = plt.subplots(1) polygon = Polygon(np.random.rand(6, 2), closed=True, alpha=1) ...

Read More

How to get data labels on a Seaborn pointplot?

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 02-Feb-2022 3K+ Views

To get data labels on a Seaborn pointplot, we can take the following steps −StepsSet the figure size and adjust the padding between and around the subplots.Create a dataframe, df, of two-dimensional, size-mutable, potentially heterogeneous tabular data.Create a pointplot.Get the axes patches and label; annotate with respective labels.To display the figure, use show() method.Examplefrom matplotlib import pyplot as plt import pandas as pd import seaborn as sns plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True df = pd.DataFrame({'a': [1, 3, 1, 2, 3, 1]}) ax = sns.pointplot(df["a"],    order=df["a"].value_counts().index) for p, label in zip(ax.patches, df["a"].value_counts().index):    ax.annotate(label, ...

Read More

How to draw a precision-recall curve with interpolation in Python Matplotlib?

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 02-Feb-2022 918 Views

To draw a precision-recall curve with interpolation in Python, we can take the following steps −StepsSet the figure size and adjust the padding between and around the subplots.Create r, p and duplicate recall, i data points using numpy.Create a figure and a set of subplots.Plot the recall matrix in the range of r.shape.Plot the r and dup_r data points using plot() method.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 r = np.linspace(0.0, 1.0, num=10) p = np.random.rand(10) * (1. - r) dup_p = p.copy() i ...

Read More

How to plot additional points on the top of a scatter plot in Matplotlib?

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 02-Feb-2022 18K+ Views

To plot additional points on the top of a scatter plot 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 x and y data points.Create a scatter plot with x and y data points.Plot the additional points with marker='*'To display the figure, use show() method.Examplefrom matplotlib import pyplot as plt # Set the figure size plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True # List of data points x = [1, 2, 6, 4] y = [1, 5, 2, 3] # Scatter plot ...

Read More

Transparent error bars without affecting the markers in Matplotlib

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 02-Feb-2022 3K+ Views

To make transparent error bars without affecting markers in matplotlib, we can take the following steps −StepsSet the figure size and adjust the padding between and around the subplots.Make lists x, y and z for data.Initialize a variable error_bar_width=5Plot y versus x as lines and/or markers with attached errorbars.Set the alpha value of bars and caps.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 x = [1, 3, 5, 7] y = [1, 3, 5, 7] z = [4, 5, 1, 4] error_bar_width = 5 markers, ...

Read More

How to set legend marker size and alpha in Matplotlib?

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 02-Feb-2022 8K+ Views

To set legend marker size and alpha 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 to store the number of sample data.Plot the x and y data points with marker="*".Place a legend on the figure.Set the marker size and alpha value of the marker.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 N = 10 x = np.random.rand(N) y = np.random.rand(N) line, = plt.plot(x, y, marker='*', markersize=20, markeredgecolor='black', ...

Read More

Showing points coordinate in a plot in Python Matplotlib

Rishikesh Kumar Rishi
Rishikesh Kumar Rishi
Updated on 02-Feb-2022 15K+ Views

To show points coordinate in a plot in Python, we can take the following steps −StepsSet the figure size and adjust the padding between and around the subplots.Initilize a variable N and create x and y data points using numpy.Zip the x and y data points; iterate them and place coordinates.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 N = 5 x = np.random.rand(N) y = np.random.rand(N) plt.plot(x, y, 'r*') for xy in zip(x, y):    plt.annotate('(%.2f, %.2f)' % xy, xy=xy) ...

Read More
Showing 111–120 of 1,016 articles
« Prev 1 10 11 12 13 14 102 Next »
Advertisements