Found 1034 Articles for Matplotlib

How to create custom markers on a plot in Matplotlib

Dev Prakash Sharma
Updated on 23-Feb-2021 06:08:50

582 Views

To create a custom marker on a plot or graph, we use a list where we write the markers we want to see in the plot. The markers are nothing but symbols, emoji, character or any character which we want to see on the figure.In order to create the marker, we will first import the required libraries.import matplotlib.pyplot as plt import numpy as npFor now, we will create a marker on a sine curve. Let us create the grid with size (12, 6), x = np.arange(1, 2.6, 0.1) y = np.sin(2 * np.pi * x) plt.subplots(figsize=(12, 6))Here we will create ... Read More

How to align multiple plots in a grid using GridSpec Class in Matplotlib

Dev Prakash Sharma
Updated on 23-Feb-2021 18:22:08

726 Views

Aligning the multiple plots in a grid can be very messy and it can create multiple issues like higher width and height or minimal width to align all the plots. In order to align all the plots in a grid, we use GridSpec class.Let us suppose that we have a bar graph plot and we want to align the symmetry of the plot in this sample.First Import all the necessary libraries and plot some graphs in two grids. Then, we will plot a constant error bar and a symmetric and asymmetric error bar on the first grid. In the second ... Read More

How to add annotations in Matplotlib Plots?

Dev Prakash Sharma
Updated on 23-Feb-2021 14:50:37

301 Views

To specify the details of a plot, we use annotations. To create annotations in Matplotlib Plots, we can use the ‘annotate’ method.Exampleimport matplotlib.pyplot as plt import numpy as np #Let us create a plot and use annotation at the point (5,3), x = np.arange(0,4*np.pi,0.1) plt.plot(np.sin(x), 'b-*') a = plt.annotate("(3,0)", xy=(3, 0), xycoords='data', xytext=(4.0,0.5), textcoords='data', arrowprops=dict(arrowstyle="->", color="green", lw=5, connectionstyle=("arc3,rad=0."))) plt.setp(a, size=25) #Display the plot plt.show()Output

How to Capture a pick event and use it to activate or deactivate Line Plots in Matplotlib

Dev Prakash Sharma
Updated on 23-Feb-2021 14:52:11

387 Views

After enabling the pick event property of artists in Matplotlib, the task is to use the pick event to enable and disable the line plots for a given axis in a set of plots.In order to pick a specific line plot, we use Legend.We will use a Binary classification plot to create the ROC Curve. ROC curve or Receiver Operating Characteristics curve is used for diagnostics, weather prediction and other applications. It contains True Negative Rate (TPR) and False Positive Rate (FPR). Using ROC, we will create multiple plots of the curve.Let us Import the libraries first. Here ‘nbAgg’ is used ... Read More

Advertisements