Latest Questions tagged Matplotlib

Browse all latest questions tagged Matplotlib

12
Votes
Published 31 Aug, 2022
Python - What does 'numpy.ndarray' object has no attribute 'barh' mean and how to rectify it?

I want to plot a 5 x 4 plots. The code for the same is below fig, axis = plt.subplots(5, 4,figsize=[25,10]) i = 0 for channel in np.unique(data_recent['channel_id']): for year in np.unique(data_r...

54
Votes
Published 28 Jun, 2022
Python - ValueError: Invalid RGBA argument: 'rgbkymc'

train_class = train_df['Class'].value_counts().sortlevel() my_colors = 'rgbkymc' #red, green, blue, black, etc. train_class.plot(kind='bar', color=my_colors) plt.grid() plt.show() I'm getting: Val...

58
Votes
Published 26 Aug, 2022
Python - Add plots directly to a document using python package docx

I am plotting some data and I want to automatically generate a report. I can save the plot and then add it to my document. However, I prefer to do it directly, without saving step. Going through the p...

41
Votes
Published 29 Aug, 2022
Python - matplotlib bar chart with dates

I know about plot_date() but is there a bar_date() out there? The general method would be to use set_xticks and set_xticklabels, but I'd like something that can handle time scales from a few hours ou...

49
Votes
Published 27 Aug, 2022
Python - How to set center color in heatmap

I want to plot a heatmap in seaborn. My code is following: plt.rcParams['font.size'] = 13 plt.rcParams['font.weight'] = 'bold' my_dpi=96 fig, ax = plt.subplots(figsize=(800/my_dpi, 600/my_dpi), dpi=m...

116
Votes
Published 27 Aug, 2022
Python - Matplotlib - add colorbar to a sequence of line plots

I have a sequence of line plots for two variables (x,y) for a number of different values of a variable z. I would normally add the line plots with legends like this: import matplotlib.pyplot as plt...

34
Votes
Published 29 Aug, 2022
Python - smooth the path of line with python

I have a set of points, all together they create a track, where the sequence is crucial. I can plot the track using lines, how could I smooth it after or while new points are fetching? Track might loo...

38
Votes
Published 23 Aug, 2022
Python - Matplotlib.animation: how to remove white margin

I try to generate a movie using the matplotlib movie writer. If I do that, I always get a white margin around the video. Has anyone an idea how to remove that margin? Adjusted example from http://ma...

38
Votes
Published 23 Aug, 2022
Python - Plotting profile hitstograms in python

I am trying to make a profile plot for two columns of a pandas.DataFrame. I would not expect this to be in pandas directly but it seems there is nothing in matplotlib either. I have searched around an...

22
Votes
Published 06 May, 2022
Python - Image overlay in 3d plot using python

I have a 3d plot of lines generated by matplotlib. I want to overlay an image at a specific xy (or yz, xz) slice. How do I do that using python? Thanks. I have a simple 3d plot code as: fig = plt.fi...

68
Votes
Published 27 Jun, 2022
Python - Python histogram with points and error bars

I want to plot a histogram with points and error bars. I do not want bar or step histograms. Is this possible? Google has not helped me, I hope you can. Also it should not be normalized. Thanks!

17
Votes
Published 08 May, 2022
Python - Labeling boxplot in seaborn with median value

How can I label each boxplot in a seaborn plot with the median value? E.g. import seaborn as sns sns.set_style("whitegrid") tips = sns.load_dataset("tips") ax = sns.boxplot(x="day", y="total_bill",...

16
Votes
Published 26 Apr, 2022
Python - Python - How to show graph in Visual Studio Code itself?

When I try to run this example: import matplotlib.pyplot as plt import matplotlib as mpl import numpy as np x = np.linspace(0, 20, 100) plt.plot(x, np.sin(x)) plt.show() I see the result in a new wi...

48
Votes
Published 26 Apr, 2022
Python - Can Pandas plot a histogram of dates?

I've taken my Series and coerced it to a datetime column of dtype=datetime64[ns] (though only need day resolution...not sure how to change). import pandas as pd df = pd.read_csv('somefile.csv') colu...

5
Votes
Published 26 Apr, 2022
Python - How to 4D plot with contour over cube, using matplotlib?

I would like to 4D plot over the cube (x,y,z) vs. q, using the colormap on the 3 surfaces of the cubes, where the color and contour are determined depending on the q variable. Basically, I am looking...