Share Your Experience: Take the 2024 Developer Survey

# Questions tagged [matplotlib]

Matplotlib is a plotting library for Python which may be used interactively or embedded in stand-alone GUIs. Its compact "pyplot" interface is similar to the plotting functions of MATLAB®.

54 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
534 views

### how can i plot probability distribution of my classes in the way below?

All, I would like to plot the following: I have a binary classification problem where I am using xgboost as my 'model' below: ...
• 526
741 views

### Plotting Gradient Descent in 3d - Contour Plots

I have generated 3 parameters along with the cost function. I have the $\theta$ lists and the cost list of 100 values from the 100 iterations. I would like to plot the last 2 parameters against cost ...
• 321
455 views

### Plotting facetgrid in subplot for IRIS dataset

I'm trying to plot 6 selected pair subplots with the combination of facetgrid of seaborn and scatter plot from matplotlib. I'm getting plot, but subplots remains empty whereas facetgrid gets plotted ...
3k views

### Plotting the confidence interval for a plot in python

I have a curve and I want to create the confidence interval for the curve. Here, I provide a simple example: ...
• 146
3k views

### Plotting confusion matrix for multi classification problem

I am using google colab to solve a multi-classification problem. I am trying to plot the confusion matrix for this problem, I have tried doing so using : ...
• 145
3k views

### Different scales for 2D plots grouped in 3D perspective in python

I'm trying to realize a plot similar to the one in the following figure: I started from the code contained in the answer here: https://stackoverflow.com/questions/34099518/plotting-a-series-of-2d-...
• 21
32 views

### How do I plot between 2 variables in a summation equation?

I am new to Python and using Jupyter notebook. Following is the summation equation that I have: $$y(t) = \sum_{i=1}^{t-1} a_{i}y(t-i)$$ How can I plot between variables y and t by formulating this ...
• 21
359 views

### Why are the regions/decision boundaries overlapping with multi-class classification using SVM in sci-kit?

I am using the SVM in scikit-learn library for doing multiclass classification. I am wondering why these regions (decision boundaries) are overlapping (as seen in the picture below)? Could someone ...
• 31
25 views

### Z values get rescaled while plotting in 3d

x_3d = 5.171875 , 5.3125 , 5.171875 ... 6 y_3d = 0, 1, 2, 3, 4, 5, .... 1500 (1500 points) z_3d = -10.493983 , 22.128998 , -14.582531 , 34.687847 , 11....
176 views

### Python equivalent of Wolfram Language ParametricPlot3D?

The Wolfram Language as a ParametricPlot3D that can be used to interactively examine parametric functions in 3D. Which Python package and function(s) best ...
• 705
120 views

### How to force histogram plots to have same axes?

I am comparing my trained model with other benchmark models with the error histogram but the axis of histogram is different for each method as shown in figure.For instance to plot the error histogram ...
• 2,487
1 vote
38 views

### How can I improve this chart?

I have a chart like this: There are some problems that I am stuck: Some columns value are very small compared to others, so I cannot identify whether they are zeros or not (I used logarithm scale, ...
• 11
1 vote
32 views

### Distplot 'a' parameter, does not make logical sense to me, can anyone explain?

Most sns plot parameters have names that make somewhat logical sense, For example scatterplot has the x attribute to choose what to plot on the x-axis, and y for y-axis. Similarly kdeplot uses the ...
1 vote
26 views

### Multiclass Classifier comparison decision regions

How can I get the very same effect of this tutorial in Scikit Documentation with more than 2 classes? Let's say we'll keep only the first dataset (the linear separable one) and substitute it with <...
• 113
1 vote
601 views

### Distribution of Regression Residuals: Is this a normal distribution?

I've created a histogram as well as a QQPlot from the residuals of my Regression Model: Mean: 0.35 Standard Deviation: 18.14 Judging from these plots, is it okay to say that my residuals are normally ...
• 31
1 vote
60 views

### Plot three series on the same plot grouping data by day and month

I have a dataset containing three years of data which I would like to plot and compare by date and month; but, I am having a hard time with the final result. I am nearly there, but for some strange ...
• 351
1 vote
1k views

### Finding multiple histogram graphs with Seaborn

When graphing with matplotlib I get this 4 histograms model: 4 Histograms Using Seaborn I am getting the exact graph I need but I cannot replicate it to get 4 at a time: I want to get 4 of the ...
• 193
1 vote
357 views

### Images matching using bf.match and drawing using cv2.drawMatches Python

I have successfully matched 2 images using bf.Match and drawn matches as well. Now, I am trying to match multiple images from 2 different directories. For this, I am using 2 different array to store ...
• 111
1 vote
320 views

### logarithmic exponential function python

The code below (I found from googling) does the trick in terms of outcome. What I need to work out is the formula for this, so for any Y point we can get corresponding X. This is part of a larger ...
1 vote
197 views

### Data Visualization of Feature Distribution Plot

I have been trying my best to plot this type of feature distribution plot using Python. I looked for what they are called to replicate the plot, but couldn't find the name of it? The Reference of ...
1 vote
2k views

### How can I adjust the legend when visualizing clusters in two dimensions?

How can I change the legend as we can see now the legend has some cluster numbers missing. How can I adjust the legend so that it can show all the cluster numbers (such as Cluster 1, Cluster 2 etc, no ...
• 183
1 vote
411 views

### Matplotlib pyplot: How to plot multiple trends in different areas of the plot?

I am trying plot some trends using matplotlib.pyplot. The task is straightforward, but there is one detail I can't get right. I wish to plot a numpy.array called ...
• 6,255
1 vote
56 views

### same color scheme for 2 pie charts

I want to visualize statistics from two large dataframes with similar data in two pie charts. I would like for these two charts to use the same color when the same category appears in the chart. I ...
• 111
1 vote
71 views

### How to draw diagram like this one (errorsbar)

I would like to draw a graph that looks like this one from: The closest I have come is this graph: by this code: ...
• 111
8 views

### Plotting related multiple plots sharing an axis but each disjoint from each other

I want to plot related multiple plots sharing an axis but each disjoint from each other, i.e., same x-axis feature and scale but each of the other features has their own separate y-axis region with it'...
32 views

### Why do seaborn.histplot and pyplot.hist generate two different histograms on the same data?

I'm trying to visualize a customer data, two of the variables I'm looking at are verified_status and video_transcription_length. ...
26 views

### Extracting the lines and arrows from matplotlib streamplot() (issues with scaling)

My goal is to extract the coordinates of lines and arrows produced by plt.streamplot(), since I want to reuse them elsewhere. plt.streamplot() generates lines and arrows as objects of type ...
• 133
12 views

### Need to print kNN K's together with NNF / STFT covariance matrix

Challenge on printing print kNN K's together with NNF / STFT covariance matrix Effort works for summary covariance but need solution to print print kNN K's together with NNF / STFT covariance matrix ...
39 views

### Quantifying heat map data

I have heatmap data (the x and y axis take in angles as inputs, and the color of that particular spot on the grid represents the "divergence.") I am unsure on how to numerically describe my ...
• 101
25 views

### Can't show images outputted by a VAE with pyplot.imshow - wrong dimensions

I'm trying to show images generated by a variational autoencoder using pyplot.imshow and make_grid. I can't show them, though, with the following error: "TypeError: Invalid shape (64, 530, 42) ...
• 21
62 views

### Better understand the scatter plots

I'm trying to understand how to read a scatter plot based on the results of my confusion matrix. This is the CM: I saw an high correlation between column 5 and column 6, a low correlation with column ...
46 views

### What ML Algo should I use to plot & predict customer location vs. amount spent?

Im using real customer csv files from my ecommerce store. I was initially going to use k cluster with 2 values. I want the two values to be Province Code, and amount spend on my store. This will ...
336 views

### AttributeError: module 'graphing' has no attribute 'histogram'

I want to make a histogram plot, after importing the library called graphing it gives me an error even when it has been installed. ...
545 views

### Creating a scatter plot with matplotlib with large dataset

I am trying to create a scatter plot from instrument peak area data recorded every tenth of a second or so. For some reason, when I try to plot it with Matplotlib, I get a straight line, which is not ...
59 views

### Can python's matplotlib render images as quickly as R's Cairo device?

I need to render 100k of plots. I already am doing this quickly enough with R's Cairo device. But I am also considering using python. But, I also already know python's rendering of plots is several ...
• 210
240 views

### Converting RGB values to contour values

I am using matplotlib to generate a filled contour plot, please consider the below example as a sample contour plot. I want to read off the contour values from such a filled contour plot using opencv'...
148 views

...
430 views

### Plotting two pd dataframes with n columns, each df representing an axis coordinate?

I have two dataframes which each have n columns (changes depending input), where each dataframe represents an axis coordinate. Each column represents separate lines I want to plot. Example dfs (1st ...
• 1
50 views

### Trying to understand a PCA output

I recently ran a code to generate PCA for a movie ratings dataset. Actually there were two different datasets, a 'movies' and a 'ratings' one. The movie had about 9700 rows of different movie titles ...
• 101
407 views

### need an explanation of the For Loop in the DBSCAN algorithm Demo

In the following code of the DBSCAN algorithm, as a beginner I need an explanation for what happens to the data in the bottom for loop and why ? Generate sample data ...
8k views

### How to plot the bar charts of precision, recall, and f-measure?

I have used 4 machine learning models on a task and now I am struggling to plot their bar charts just like shown below in the image. I am printing classification report to get precision, recall etc. ...
• 240
277 views

### Visualization with many lines, colors, and markers

I have a bunch of plots as the one reported below. The data is from measurements performed on different times and different days. In the plot (which is a cumulative distribution function, if that ...
• 101
169 views

### Unsynchronized time series visualization

I would like to visualize a large amount of events composed of time serie windows. A typical event would be: Problem is, my events are not synchronized, and so if I plot them all, it would look like: ...
• 1,405
4k views

### Python: How to plot time interval from a Dataframe in Pandas

I have the a dataframe(df) which has the data of a Job being executed at different time intervals. It includes the following details about the execution of a job: ...
• 11
122 views

### Time Series data visualization

When I visualize data using matplotlib it displays very well, but when using Plotly, the data display very bad.
567 views

### How to plot segmented bar chart (stacked bar graph) with Python?

cat = {'A':1, 'B':2, 'C':3} dog = {'A':2, 'B':2, 'C':4} owl = {'A':3, 'B':3, 'C':3} Suppose I have 3 dictionary, each containing pairs of (subcategory, count). How ...
• 145
74 views

### Information Visualization: which parameters should a data scientist plot to best explain the work behind a Neural Network?

I'm a beginner in the field and I wrote and trained my first Convolutional Neural Network from scratch. I would like to know what types of graphics and parameters a data scientist uses to plot to ...
• 461
443 views

### How to add Error Bar to Matplotlib line plot?

I have the following dataset which I use to plot a line plot. The plot is obtained as the mean of values obtained from the data. I want to add error bars to this ...
• 293