Skip to content

Tag: matplotlib

Proplot colorbar from custom cmap

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 col…

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’ Re…

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. B…

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