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®.
matplotlib
72,760 questions
2
votes
1
answer
59
views
How do I embed a FigureCanvasTkAgg in a class?
To clarify this is a homework help question. I have started it already and I am running up against a brick wall when it comes to coding it. We are to use what I said above to generate a sine wave ...
Advice
0
votes
3
replies
22
views
Plot time evolution of a function y(x, t) in matplotlib (Python) where y and x are parameterized
I am trying to plot the time evolution of the function y(x, t) on a 2-D plot in matplotlib where t represents time and x one spatial dimension. I have y and x parameterized as functions of a parameter ...
1
vote
1
answer
59
views
Python Matplotlib: Animation does not update plot alongside series of images
I am trying to create an animation of two plots side by side on which on the first plot I display a series of images and on the second plot a log log representation of data corresponding the image ...
7
votes
1
answer
111
views
matplotlib axes3d how to use all window space plotting
I have an application in python that embeds a matplotlib.Axes3d in a QWidget to draw 3D curves.
The problem is that when resizing or there is a lot of space in the ...
0
votes
1
answer
56
views
Matplotlib update AnnotationBBox position
I'm trying to display labels in a 3D plot. My final goal is to display a tiny version of an image/texture at the coordinates of its average color in Lab space.
After multiple failed attempts, I ...
1
vote
1
answer
42
views
"AttributeError: 'FigureCanvasInterAgg' object has no attribute 'tostring_rgb'" in pyplot.show()
While using the following code:
...
2
votes
1
answer
84
views
Locate where a map boundary is in the world with my created shapefile
I made a shapefile containing the boundaries of all the worlds countries and some of their regions (like the states in the US, Canadian provinces, etc). I've been trying to set a boundary box of my ...
4
votes
1
answer
83
views
How to create a class that generates auto-updateable plots
I want to create a class that will create updateable plots. I plan on having 8-16 figures in one window, so it would be nice to have a class that would initiate these for me. These graphs will auto-...
-3
votes
0
answers
49
views
Creating a figure with matplotlib imshow with native resolution of the array [duplicate]
I am currently creating figures with one or more imshow plots.
I would like to get a native plot of one of those imshow plots.
To my understanding I would need to calculate the figure size, with ...
2
votes
1
answer
34
views
Matplotlib plot window does not stay minimized
I am creating a dashboard using matplotlib. The following is my python3 code. When I minimize the matplotlib plot window, the window jumps back up and the window does not stay minimized. What should I ...
-2
votes
0
answers
29
views
How do I add a legend to for pixmapped image [duplicate]
I have a 2D array of integer data that I am plotting with matplotlib's axes interface (not the pyplot interface). When I use ax.imshow I get the plot I am looking for. The built in colorizer handles ...
1
vote
1
answer
52
views
python Plot Swaps Colours in Subplot — How to make one colour stick to one data set?
I am trying to plot some data from a Markov Chain Monte Carlo run, using getDist, which (I assume) uses matplotlib under the ...
Best practices
2
votes
4
replies
59
views
Visualizing categorical features with severe Class Imbalance for ML: Absolute Counts vs Normalized Percentages?
I am performing Exploratory Data Analysis (EDA) on a medical dataset (Primary Biliary Cirrhosis) to select features for a multiclass classification model. My target variable is ...
Tooling
0
votes
3
replies
47
views
How to better emulate this broken line plot with matplotlib or seaborn?
What I want to achieve is something as below:
I have found the brokenaxes package here, and tried it:
...
1
vote
1
answer
69
views
how to carryon after matplotlib has been called
I am stuck after displaying using matplotlib because I can not seem to figure out what code to use to continue after using matplotlib. Specifically, I use:
...
1
vote
1
answer
119
views
Jupyter Lite outputs a blank file when I use plt.savefig()
I'm writing a Python code that's supposed to create a graph and export it as a vector PDF file. I'm using Jupyter Lite at jupyter.org.
I've successfully created the graph, but when I try to export it ...
1
vote
2
answers
88
views
Why does Matplotlib DatetimeIndex plot misalign dates?
Why does matplotlib round to the nearest month sometimes and not other times depending on the order lines are plotted and which dates are used. ax3 and ...
1
vote
1
answer
52
views
Colorbar tick locations not correct
I'm making a protein secondary structure plot, at first with trivial data:
...
0
votes
1
answer
75
views
Show the value at hovered position (x,y) with interactive pcolormesh plots
I find the coordinates shown below (in the form: (x, y) [z]) very useful for interacting with the data. Unfortunately, librosa.display.specshow does not show the ...
2
votes
1
answer
117
views
Why is list[list[str]] not equal to list[HashableList[Hashable]]
I struggle with typechecks using matplotlib.pyplot.subplot_mosaic.
I have create the following fuction, which generates the mosaic pattern and the ...
Advice
0
votes
2
replies
58
views
How do I set the matplotlib co-ordinate system to SVG
A synopsis of my code.
...
0
votes
1
answer
58
views
Crop extra white-space on matplotlib picture
I made a "gauge" image using the following code:
...
1
vote
1
answer
87
views
How to expand equal-aspect data limits in one direction only?
I've been trying to set equal data aspect ratios in matplotlib with ax.set_aspect('equal', 'datalim') (aka ax.axis('equal')), ...
4
votes
1
answer
118
views
Tick direction of 3D plot in Matplotlib
In Matplolib, it is possible to change the direction of the tick of 2D plots with tick_params parameters
...
2
votes
2
answers
177
views
Plotting Y data vs X data with alternating colors for each section in Python
I have what might be a simple problem.
I have a dataset that looks like this:
...
1
vote
1
answer
62
views
How to limit the number of displayed xticks in pyplot when x values are strings
I have a scatterplot in pyplot where the x-values are necessarily strings. Is there an easy way to limit the number of xticklabels that pyplot will show?
I am not referring to specifying the xticks ...
2
votes
1
answer
72
views
Matplotlib's ax.fill_between() function not working for 3D plots
I'm doing some data visualisation for an experiment on near/far field diffraction.
My goal is to essentially put several 2d plots in front of one another, pretty much identical to how this example in ...
-1
votes
1
answer
74
views
Saving matplotlib figures when running multiple subsequent python files via a .bat file on Windows
SET UP
I have multiple scripts that I execute with a .bat file, like so:
...
0
votes
1
answer
101
views
Why different files produce same GNSS plots in my Python code?
I wrote a piece of Python code to read different GPS observation files (.24o) and navigation files (.24p), and generate polar plots of satellite trajectories. The goal is that the RINEX file can be ...
3
votes
1
answer
134
views
Matplotlib LaTeX text not respecting font family
I am trying to display a LaTeX-style equation in a Matplotlib plot using a custom font (Algerian). I want both the equation and ...
2
votes
1
answer
143
views
How do I make a matplotlib bar graph scale with the amount of items?
I am working on a small project and it is my first time using matplotlib, and I am struggling with how to make my bar graph look better with more inputs. The whole idea of the program is to read text ...
Advice
0
votes
2
replies
126
views
Analysis of a tapering function
On Window function - Wikipedia tapering functions are plotted using two different styles. One shows curve (samples) and the other Fourier transform (bins).
I've prepared two tapering functions based ...
2
votes
1
answer
108
views
How to connect a callback to "Reset original view" event in Matplotlib?
I would like to connect onTool() callback to "Reset original view" event, i.e. clicking on "home" icon in the bottom left corner of Matplotlib ...
3
votes
1
answer
84
views
Why the initial figure dimensions are wrong in this matplotlib script?
This Python 3.13 script with Matplotlib 3.10.3 run on 1200x1600 display:
...
3
votes
1
answer
120
views
rasterized, dpi, bbox_inches='tight' and axins mess up the plot in a pdf
When I run the code below, the plot in the PDF is messed up. The content of the plot and the colorbar are shifted down to the left, as shown in the attached screenshot of the PDF.
...
0
votes
0
answers
77
views
Rendering matplotlib figure in VSCode (Jupyter) like fig.savefig
Problem
When saving a matplotlib figure using fig.savefig(), the figure looks different from when the figure is rendered in a <...
1
vote
1
answer
66
views
Boxplot with scatter points: preventing overlap when categories are similar
I am trying to create a boxplot with different categories and overlay scatter points on top of it. The problem I am encountering is that when the results across categories are very similar, the ...
3
votes
2
answers
113
views
How to ensure cartopy features are rendered after setting matplotlib Axes box aspect?
I have a function that will produce a map when given a DataFrame containing lat/lon coordinates. Regardless of the shape of the track that can be drawn from coodinate pairs and timestamps, I want to ...
0
votes
1
answer
51
views
Multiple CDFS on the same plot with specified ranges
I was trying to do something for a project where I create two random 3D vectors, project them onto a 2D plane by removing their x-component, taking the dot product between the two to find their ...
0
votes
0
answers
66
views
Coarsening the resolution of a xarray dataset
Very new to python! I am trying to model bottom water temperatures over time and need to reduce the resolution of my model from 1/20º to 1º. My ultimate goal is to map this and select specific grid ...
1
vote
1
answer
112
views
Specify hue when having multiple vertical plots in same graphic
I use a swarmplot to display vertically multiple distributions in the same graphic:
...
Advice
0
votes
2
replies
121
views
How to retrieve a figure title from a Figure or FigureCanvas?
I'm using python and PySide6 to build GUI desktop apps.
In my code I generate a list of figures, and then pass them to my view to display each in a separate tab. Right now, I loop through the list, ...
0
votes
1
answer
141
views
Tkinter window shrinks after embedding Matplotlib canvas — how to prevent it?
I'm building a multi-frame Tkinter app for a school project (NEA dashboard). One of the frames displays a Matplotlib scatter plot using FigureCanvasTkAgg. The issue ...
Advice
0
votes
3
replies
124
views
How to adjust vector length in quiver plot?
This is the program I am using:
...
1
vote
0
answers
168
views
Jupyter notebook refusing to recognize matplotlib installation
I am running a Jupyter notebook and I had to manually install using pip Matplotlib 3.10.7 because it wasn't recognized on my Anaconda. Now when I try to get it in Jupyter I get this error:
...
0
votes
0
answers
103
views
Shrinking colorbar for geopandas
I am attempting to shrink the colorbar for my map generated with geopandas as the default one generated is too huge.
I have tried using ...
2
votes
2
answers
125
views
getting a tensor of shape (32,) instead of a single value as a label
when i try to print/plt.tile the label of an image, its printing the tensor(32,) instead of a single label value. When i tried ...
0
votes
0
answers
138
views
New installation get this: main loop could not convert string '2023-01-02' to float64
I have just installed the new Mint 22.2 as my old hard disk with Mint 21 seems to have some issues. I use ...
0
votes
1
answer
66
views
Linking matplot++ and Libtorch together in a program causes memory corruption problem
I made a minimal example that crashes. For the crash it is required that the torch libraries are linked. I made sure that GLIBCXX_USE_CXX11_ABI=0 for all 3 components. Setup is Ubuntu, g++, C++17.
Any ...
3
votes
2
answers
114
views
How to generate scatter plot of all numeric columns against specific columns in the same dataframe
I have a dataframe with a mix of data types (object and numeric). I want to plot a scatter plot for all numeric columns in the dataset against specific columns: ...