Rishikesh Kumar Rishi has Published 1156 Articles

How to make several plots on a single page using matplotlib in Python?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 16-Mar-2021 10:12:58

407 Views

Using Pandas, we can create a data frame and create a figure and axis. After that, we can use the scatter method to draw points.StepsCreate lists of students, marks obtained by them, and color codings for each score.Make a data frame using Panda’s DataFrame, with step 1 data.Create fig and ... Read More

How to plot ROC curve in Python?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 16-Mar-2021 10:11:36

7K+ Views

ROC − Receiver operating characteristics (ROC) curve.Using metrics.plot_roc_curve(clf, X_test, y_test) method, we can draw the ROC curve.StepsGenerate a random n-class classification problem. This initially creates clusters of points normally distributed (std=1) about vertices of an ``n_informative``-dimensional hypercube with sides of length ``2*class_sep`` and assigns an equal number of clusters to ... Read More

Defining the midpoint of a colormap in Matplotlib

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 16-Mar-2021 10:11:07

386 Views

Using plt.subplots(1, 1) method, we can create fig and axis. We can use fig.colorbar to make the color bar at the midpoint of the figure.StepsUsing mgrid() method, `nd_grid` instance which returns an open multi-dimensional "meshgrid".Create Z1, Z2 and Z data.Create fig and ax variables using subplots method, where default nrows ... Read More

How can I set the 'backend' in matplotlib in Python?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 16-Mar-2021 10:08:06

719 Views

We can use matplotlib.rcParams['backend'] to override the backend value.StepsUsing get_backend() method, return the name of the current backend, i.e., default name.Now override the backend name.Using get_backend() method, return the name of the current backend, i.e., updated name.Exampleimport matplotlib print("Before, Backend used by matplotlib is: ", matplotlib.get_backend()) matplotlib.rcParams['backend'] = 'TkAgg' print("After, ... Read More

Scatter plot and Color mapping in Python

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 16-Mar-2021 10:07:43

765 Views

We can create a scatter plot using the scatter() method and we can set the color for every data point.StepsCreate random values (for x and y) in a given shape, using np.random.rand() method.Create a scatter plot of *y* vs. *x* with varying marker size and/or color, using the scatter method ... Read More

Change figure window title in pylab(Python)

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 16-Mar-2021 10:07:24

3K+ Views

Using pylab.gcf(), we can create a fig variable and can set the fig.canvas.set_window_title('Setting up window title.') window title.StepsUsing gcf() method, get the current figure. If no current figure exists, a new one is created using `~.pyplot.figure()`.Set the title text of the window containing the figure, using set_window_title() method.. Note that ... Read More

Change x axes scale in matplotlib

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 15-Mar-2021 08:44:15

15K+ Views

Using plt.xticks, we can change the X-axis scale.StepsUsing plt.plot() method, we can create a line with two lists that are passed in its argument.Add text to the axes. Add the text *s* to the axes at location *x*, *y* in data coordinates, using plt.text() method, where the font size can ... Read More

How to change fonts in matplotlib (python)?

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 15-Mar-2021 08:42:43

2K+ Views

Using plt.text() method, we can increase the font size.StepsUsing plt.plot() method, we can create a line with two lists that are passed in its argument.Add text to the axes. Add the text *s* to the axes at location *x*, *y* in data coordinates, using plt.text() method. Font size can be ... Read More

Python matplotlib multiple bars

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 15-Mar-2021 08:41:20

446 Views

We can use a user-defined method, autolabel, to annotate the axis value. Before that, we can initialize the fig and ax using plt.subplots() method.StepsCreate lists, labels, men_means, and women_means with different data elements.Return evenly spaced values within a given interval, using numpy.arrange() method.Set the width variable i.e., width=0.35.Create fig and ... Read More

Annotate bars with values on Pandas bar plots in Python

Rishikesh Kumar Rishi

Rishikesh Kumar Rishi

Updated on 15-Mar-2021 08:39:08

490 Views

In this program, we can create a data frame and can plot a bar using df.plot.bar(x='lab', y='value', color='#5fba34') plot.StepsUsing Panda’s dataframe, we can create a data frame with the given dictionary, where the keys are lab and value, values of these keys are lists, respectively.Using Pandas plot.bar() method, we can ... Read More

Advertisements