# 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®.

37,811 questions

**0**

votes

**0**answers

2 views

### Python Matplotlib - Overriding Stylesheets by adding spines back in

I have produced a 3x3 subplot in matplotlib and am using the following style sheet for aestehtics:
plt.style.use('ggplot')
I like the stylesheet, however I want the left spine to show. The following ...

**0**

votes

**0**answers

16 views

### Reduce data size for a plot

I need to plot large oscilloscope data sets. They are too large (100 million Values) to plot all of them in a for loop. If I try to do that it results in a MemoryError. So with the help of ...

**0**

votes

**0**answers

6 views

### Matplotlib 3-d zoom does not zoom the axis

I tried following the demo on https://matplotlib.org/gallery/mplot3d/scatter3d.html. When I tried zooming, the plot points zoom however the axis remains at the place making it impossible to study ...

**0**

votes

**0**answers

11 views

### Prefered 3-d plot library for WxPython

I am building a GUI application using Wxpython which requires 3-d scatter plots. I have tried using the following libraries but with shortcomings:
1. Matplotlib: Very slow rendering, panning and ...

**0**

votes

**1**answer

14 views

### How to add box and label to pie graph exactly as shown in figure below

Trying to create a graph exactly like in figure below and want to save it as jpeg.
I have a dataframe named 'custpref' as below
tov_type count
Inpatient 7
Office Visit ...

**-2**

votes

**3**answers

27 views

### Remove elements from numpy array smaller than 1

I am trying to plot large data (50 million values) but I am getting a MemoryError. Now I am trying to clear my dataset from redundant values. In my case, these are all values below 1 and above -1. One ...

**2**

votes

**0**answers

30 views

### Watchdog and matplotlib: Processing an image and displaying results when a new file comes in directory

I am trying to create a simple app in which
an image is pushed in a directory (by an outside process)
Python watchdog triggers and the image is processed by a function and results are displayed in a ...

**0**

votes

**0**answers

23 views

### Why am I not able to visualise background colours for buttons in Tkinter Python on a Mac?

I have six different buttons in the Tkinter GUI each having different colors. I am able to visualize them with anaconda on Windows 10. But I am not able to visualize those buttons with the same ...

**0**

votes

**0**answers

18 views

### Overlapping bars using matplotlib but want them side by side

I have this code, modeled off the example on the matplotlib website as a side by side barchart comparison, but it seems like they're all superimposed on top of each other.
def plotHighestFive(x1, y1, ...

**0**

votes

**1**answer

26 views

### how to prevent seaborn from smoothing the histogram when plotting a density plot using seaborn.distplot?

Here is the problem I'm facing for a while now. I'm trying to plot a density plot (i.e. a smoothed approximation of a histogram plot) using seaborn.distplot() and I obtain the following figure:
The ...

**0**

votes

**1**answer

16 views

### Matplotlib Subplot Boxplot x tick labels not displaying

I would like the x-axes for both boxplots to be set by the list of labels rather than the column names in the original dataframe. I've tried a lot of things but can't get it to work!
fig = plt.figure(...

**0**

votes

**1**answer

14 views

### Changing default edge-color for matplotlib scatterplot

I'm looking for a way to change the default edge color for matplotlib scatter plots. Typically, things like that would be set through rcParams, and my understanding is that I should set patch....

**1**

vote

**1**answer

15 views

### Trend graph with Matplotlib

I have the following lists:
input = ['"25', '"500', '"10000', '"200000', '"1000000']
inComp = ['0.000001', '0.0110633', '4.1396405', '2569.270532', '49085.86398']
quickrComp=['0.0000001', '0.0003665',...

**1**

vote

**1**answer

39 views

### I don't understand why one code works and the other doesn't

I tried plotting some homework and quiz score side by side and I have two sets of code that to me are similar enough but one produces two histograms side by side and the other does not.
I'm running ...

**0**

votes

**0**answers

14 views

### Plot colormap on lineplot [duplicate]

EDIT: I'm not asking about a colorbar that needs to be added to the plot as suggested by HS-nebula. I'm asking about adding a colormap to plt.plot OR using plt.scatter to create a line
My goal is to ...

**0**

votes

**1**answer

25 views

### Graphing a Curl, got an AttributeError

I have a curl of a magnetic field that I calculated that I want to graph, using matplotlib but I end up with this AttributeError. Is there something I'm doing wrong?
I tried changing the variables ...

**0**

votes

**1**answer

20 views

### ValueError in For Loop when creating matplotlib chart from a subset of grouped values

My data source has changed and I'm having trouble updating the code that creates plots from grouped data. I am able to successfully plot a subset of the data, but I need to add a condition that will ...

**0**

votes

**0**answers

15 views

### How to save output from matplotlib 3d plot in the form of an interactive figure?

I am using MPL toolkit to plot a 3d projection in python3 environment. I am able to visualize a nice interactive 3D scatter plot with this code
from mpl_toolkits.mplot3d import Axes3D
fig = plt....

**2**

votes

**2**answers

36 views

### Scatter plot do not adjust properly plot range in matplotlib

I am plotting two gaussians (one centered in 0 and the other one in 100) with plt.plot and plt.scatter in matplotlib version 2.2.3. For any reason the subplot does not adjust the plot range ...

**0**

votes

**0**answers

17 views

### The graph in python technically prints out 3 vertical lines. however, only one is visible

I have a file in python, and in that file, you'll see a plotted graph, and that graph technically prints out 3 vertical lines. however, I can only VISIBLY see on of them...I do not want to merely ...

**0**

votes

**0**answers

13 views

### plotting in python until specific date with pie chart

I need to plot in python until specific given date. I have the twits of trump in given times and I need to do a pie chart before he got elected and after. I managed to do the after but not the before ...

**1**

vote

**1**answer

31 views

### Seaborn stripplot with violin plot bars in front of points

I would like to draw a violin plot behind a jitter stripplot. The resulting plot has the mean/std bar behind the jitter points which makes it hard to see. I'm wondeing if there's a way to bring the ...

**1**

vote

**2**answers

22 views

### visualize two columns in the same data set

I am trying to group and sort four columns, count values and chart them in the same bar graph to see the trend how the count has changed.
Year Month Bl_year Month
2018 Jan 2019 Jan
2018 ...

**0**

votes

**1**answer

28 views

### Trying to subplot groups with date axis different methods

I got a DataFrame:
date phone sensor pallet
126 2019-04-15 940203 C0382C391A4D 47
127 2019-04-15 940203 C0382D392A4D 47
133 2019-04-16 940203 C0382C391A4D 47
...

**0**

votes

**1**answer

13 views

### Set_xlabel is in invalid in ax[0, 0] when drawing 4 subplots in one plot

I get some codes as followed and I want to draw 4 subplots in one plot.
fig, ax = plt.subplots(nrows=2, ncols=2)
# ax[0, 0]
sns.countplot(train_df['Survived'], ax=ax[0, 0])
ax[0, 0].set_xlabel('...

**0**

votes

**1**answer

19 views

### How to draw (animate) random process from the start (python)?

I want to draw random process path from the begginning (0,0) which is updated step by step. I used matplotlib animation, but it draws a simple line. How to draw a path?
import numpy as np
import ...

**0**

votes

**1**answer

25 views

### How to call text from a function and print it on Tkinter GUI?

I have a scenario where I need to fetch some text and print it inside the Tkinter GUI canvas when a button is pressed.
The code inside the function looks as follows:
def plot_best_batsmen():
...

**0**

votes

**1**answer

27 views

### How to display axis tick labels over plotted values using matplotlib and seaborn?

I am using matplotlib and seaborn in order to scatter plot some data contained in two arrays, x and y, (2-dimensional plot). The issue here is when it comes to displaying both axis labels over the ...

**0**

votes

**1**answer

18 views

### Plotting torch.tensor in Pytorch: Invalid dimension error

I have a torch.Tensor object and this has the shape of torch.Size([9, 1, 28, 28])).
I tried something like
for digit in range(10):
similar_img = create_interpolates(/*something...*/)
plt.figure(...

**1**

vote

**1**answer

33 views

### MemoryError while plotting large oscilloscope files on Ubuntu

I am trying to read large oscilloscope .trc files and plot them. Plotting one file works but as soon as I put the script into a loop, trying to plot all files (1 file a loop) I am getting a ...

**0**

votes

**1**answer

41 views

### How to project a line on a surfaceplot in python?

see the image contentI Have a surface plot created from point data stored in a CSV file. If I want to project a line (which is floating above the surface) on the surface created in 3D what is the ...

**2**

votes

**0**answers

55 views

### How to fix 'list.remove(x): x not in list' error while plotting table

I'm trying to plot table from excel sheet to matplotlib, but getting this ValueError: list.remove(x): x not in list
I want to have a table on top of my (Tkinter) application and this is example code.
...

**0**

votes

**0**answers

26 views

### Matplotlib y-scale setting - ValueError: cannot convert float NaN to integer

I am trying to transform the scale of y-axis to log by plt.yscale('log')
def gen_spectrograms(wav):
fs, x = scipy.io.wavfile.read(wav) # read audio file as np array
spec, freqs, _, _= plt....

**0**

votes

**1**answer

19 views

### How to plot animated scatterplot using seaborn / matplotlib changing colour of fixed or moving marker over time

I am trying to plot the readings of several air pollution sensors over time. In the first case the location (lat, long) of each sensor is fixed on the scatterplot but at different times of the day, or ...

**2**

votes

**1**answer

56 views

### Using groupby function with a dataframe from a .csv file and plotting the result

Trying to Create a view of the data that generates the sum of all births for each month of each year. need to generate a Pandas date for every row. each row contains a year value and a month value ...

**0**

votes

**1**answer

25 views

### display multiple images in one directory using imshow python

I am trying to display multiple images in one directory.
import os
import cv2
import numpy as np
import random
import math
import matplotlib
from matplotlib.pyplot import imshow
from matplotlib ...

**0**

votes

**1**answer

21 views

### How to link color of bar to yticks?

I have the datafame below:
I'd like to do a bar chart for each year, sorted , with one color to each person.
I just got fixed colors, like this:
I used this code:
color = ['red','blue','green','...

**0**

votes

**1**answer

23 views

### Returning r at different theta values with numpy

I need to generate a table based on what r equals at different theta values.
I am easily able to graph and show the equation with matplotlib, and was hoping that there was an easy way to:
give ...

**1**

vote

**1**answer

29 views

### How to create a graph representing multiple time invervals per day

Given the following dict containing pairs of opening/closing hours per day:
timetable = {
'monday': ['08:00', '12:00', '13:00', '18:00'],
'tuesday': ['08:00', '12:00', '13:00', '18:00'],
'...

**0**

votes

**0**answers

17 views

### Trying to do a contour plot or pcolor plot in 3D

I have a function (I) that defines a pressure field in a control volume.
I create this control volume by meshing 3 vectors(X,Y,Z) and the apply the I function to all the points in the 3d mesh grid.
I'...

**-2**

votes

**1**answer

25 views

### How to use data from loop in matplotlib graph?

So I have a loop (shown below)
Where after running it, it prints (t,d) up until d=0 again. How would I go about displaying this all in a graph in matplotlib? I'd rather not put each data point in one ...

**1**

vote

**2**answers

31 views

### How can I plot different length pandas series with matplotlib?

I've got two pandas series, one with a 7 day rolling mean for the entire year and another with monthly averages. I'm trying to plot them both on the same matplotlib figure, with the averages as a bar ...

**0**

votes

**0**answers

23 views

### Plotting from a dateframe from a .csv file, data isn't showing up on graph using matplotlib and pandas

Basically I have a dataframe from a csv file that ive made some changes to using pandas. Now I have to plot specific columns that compare data within the dataframe.
The last row with daily ...

**2**

votes

**1**answer

51 views

### How to plot plane of best fit for multivariate linear regression?

I am implementing multivariate linear regression using numpy, pandas and matplotlib. I am reading data from a file which looks like this:
data.head()
ldr1 ldr2 servo
0 971 956 -2
1 ...

**0**

votes

**0**answers

23 views

### how to modify seaborn violin plot legend

I have created a simple violin plot from a bands DataFrame (df10 below) using seaborn:
fig, ax = plt.subplots(figsize=(10,4))
ax = sns.violinplot(x='z', y='z_fit', hue='new_col', data=df10, cut=0, ...

**0**

votes

**0**answers

11 views

### Surface Objects wrongly obscure each other in Matplotlib

I'm trying to plot a sphere on a plane using matplotlib and encounter this problem:
The plane is normal to z-axis with the sphere tangent to it from above. Both are plotted using Axes3D.plot_surface....

**1**

vote

**0**answers

19 views

### drawing a reflexive graph using networkx and matplotlib

How can a reflexive graph be drawn with networkx and matplotlib? In other words, vertex "A" connects to itself and should have an curved arrow pointing back to itself. Can this be done with networkx ...

**0**

votes

**1**answer

43 views

### How to subplot a pivot table in Python?

a newbie programmer here. I'm trying to learn Python and I'm working with the dataset US-births which contains U.S. births data for the years 1994 to 2003.
I want to create a scatter subplots for ...

**1**

vote

**1**answer

56 views

### How to Visualize a matplotlib prediction using a tkinter GUI?

I have a scenario where I made a prediction on a particular dataset. Now I want to visualize that predicted graph using Tkinter.
My Machine Learning Model looks as below which consists of a graph:
# ...

**0**

votes

**0**answers

14 views

### How to display two plt.figures and animate both of them using matplotlib.animation.FuncAnimation?

How do I use matplotlib.animation.FuncAnimation to animate more than one plt.figure?
I've been trying to animate two separate figures so I can display a parking space in figure 1 and moving car agent ...