I’d like to add a colorbar to my figure from a Colormap object rather than using a mappable (such as returned from imshow. From the docs I think this should be possible using option 4. I’m using the following code: This gives the following result: Which almost what I want but I’d like to color bar values to ranges from
Tag: matplotlib
Continuous saving files to directory after manual removal of them
I created a GUI project in pyqt5 that lets us enter a country’s name in the text input field, then we are getting data from the CoVid-19 API for the particular country. I added a feature (button) which give us a possibility to save matplotlib’s plot with statistics from API to my folder called “stats”. Let’s assume that I enter
Matplotlib stacked histogram numpy.ndarray error
I am trying to make a stacked histogram using matplotlib by looping through the categories in the dataframe and assigning the bar color based on a dictionary. I get this error on the ax1.hist() call. How should I fix it? AttributeError: ‘numpy.ndarray’ object has no attribute ‘hist’ Reproducible Example Updated effort, still not working This is close, but it is
Exe generated by PyInstaller fails quietly on a different machine
I’m having trouble getting an exe generated by PyInstaller on one PC (PC-Good) working on another (PC-Bad). The exe is created on PC-Good, and executes as expected on PC-Good Both PCs are running Windows 10 Issue occurs on PC-Bad upon calling most of the matplotlib.pyplot methods (such as subplots() or plot()) Issue persists even when matplotlib is in non-interactive mode
Plot multiple columns of dataframe in multiple plots (Python)
i want to plot multiple columns from a dataframe in multiple plots. My code looks like this: The error i get is: I know x and y need to have the same shape, but how can i solve this problem here? My entire data is within one dataframe and should have the same shape. Is it possible to pass a
Python: Add dynamic text in Matplotlib animation
I made an animation from the list of images saved as numpy arrays. Then I want to add a text onto the animation like like a subtitle whose text changes for each frame but placing plt.text(some_string) only adds the string at the first iteration and it does not work if I change the passed string in the loop. Below is
Rearrange elements in numpy array to plot a 3d array in 2d, preserving grouping
Hello I have a 3d numpy array of shape (nc, nx, ny). I would like to plot it (with matpoltlib) using x and y as the axis, but in such a way that all c values are close to each other and arranged in a rectangle around a central value (you can assume nc is a power of 2). Thanks
Sharing Y-axis in a matplotlib subplots
I have been trying to create a matplotlib subplot (1 x 3) with horizontal bar plots on either side of a lineplot. It looks like this: The code for generating the above plot – Edit How do I share the y-axis of the central line plot with the other horizontal bar plots? Answer I would set the limits of all
Export huge seaborn chart into pdf with multiple pages
I created a program which generates a large number of chart using seaborn catplot. This is the example of my code with the illustration of how the final chart looks like. However since the plot may extend up to more than 300 plots, when I tried to export to pdf, the size of the chart is too big and big
How to plot a trend line in a scatter plot from multiple dataframe data?
I have 4 data frames, which are df, df1, df2 and df3.I have plotted these data into a scatter plot. To plot trend line, I use the below code found in stackoverflow. However, this only gives the trendline from df1. I would like to plot a trendline which includes the data from df1, df2 and df3. Answer It uses data