matplotlib

How can I generate more colors on pie chart matplotlib

柔情痞子 提交于 2021-01-21 03:48:32
问题 I am having more then 40 items to show in my chart. I have only 10 colours that repeatedly are shown on the chart. How can I generate more colors. plt.pie(f,labels=labels,autopct='%1.1f%%', startangle=90,shadow=True) I should add "color=colors" where colors is generated infinitely ? 回答1: You need colors argument, beside that you can use some color maps from cm . >>> import matplotlib.pyplot as plt >>> from matplotlib import cm >>> import numpy as np >>> a=np.random.random(40) >>> cs=cm.Set1

raise LinAlgError(“SVD did not converge”) LinAlgError: SVD did not converge in matplotlib pca determination

无人久伴 提交于 2021-01-20 17:07:08
问题 code : import numpy from matplotlib.mlab import PCA file_name = "store1_pca_matrix.txt" ori_data = numpy.loadtxt(file_name,dtype='float', comments='#', delimiter=None, converters=None, skiprows=0, usecols=None, unpack=False, ndmin=0) result = PCA(ori_data) this is my code. though my input matrix is devoid of the nan and inf, i do get the error stated below. raise LinAlgError("SVD did not converge") LinAlgError: SVD did not converge what's the problem? 回答1: This can happen when there are inf

raise LinAlgError(“SVD did not converge”) LinAlgError: SVD did not converge in matplotlib pca determination

给你一囗甜甜゛ 提交于 2021-01-20 17:07:03
问题 code : import numpy from matplotlib.mlab import PCA file_name = "store1_pca_matrix.txt" ori_data = numpy.loadtxt(file_name,dtype='float', comments='#', delimiter=None, converters=None, skiprows=0, usecols=None, unpack=False, ndmin=0) result = PCA(ori_data) this is my code. though my input matrix is devoid of the nan and inf, i do get the error stated below. raise LinAlgError("SVD did not converge") LinAlgError: SVD did not converge what's the problem? 回答1: This can happen when there are inf

python: plotting a histogram with a function line on top

一曲冷凌霜 提交于 2021-01-20 16:30:44
问题 I'm trying to do a little bit of distribution plotting and fitting in Python using SciPy for stats and matplotlib for the plotting. I'm having good luck with some things like creating a histogram: seed(2) alpha=5 loc=100 beta=22 data=ss.gamma.rvs(alpha,loc=loc,scale=beta,size=5000) myHist = hist(data, 100, normed=True) Brilliant! I can even take the same gamma parameters and plot the line function of the probability distribution function (after some googling): rv = ss.gamma(5,100,22) x = np

python: plotting a histogram with a function line on top

落爺英雄遲暮 提交于 2021-01-20 16:30:43
问题 I'm trying to do a little bit of distribution plotting and fitting in Python using SciPy for stats and matplotlib for the plotting. I'm having good luck with some things like creating a histogram: seed(2) alpha=5 loc=100 beta=22 data=ss.gamma.rvs(alpha,loc=loc,scale=beta,size=5000) myHist = hist(data, 100, normed=True) Brilliant! I can even take the same gamma parameters and plot the line function of the probability distribution function (after some googling): rv = ss.gamma(5,100,22) x = np

ipython notebook arrange plots horizontally

旧城冷巷雨未停 提交于 2021-01-20 16:07:55
问题 Currently, when creating two consecutive plots in an ipython notebook, they are displayed one below the other: I'm wondering if there's any way to have them displayed in rows until the space runs out in the window. So for the first two plots, the output would look like this: I realize that I can do something similar by arranging subplots in a grid, but I'm wondering if it's possible to do it automatically so that plots are wrapped onto the next 'line' when the space runs out? 回答1: This works

ipython notebook arrange plots horizontally

生来就可爱ヽ(ⅴ<●) 提交于 2021-01-20 16:07:14
问题 Currently, when creating two consecutive plots in an ipython notebook, they are displayed one below the other: I'm wondering if there's any way to have them displayed in rows until the space runs out in the window. So for the first two plots, the output would look like this: I realize that I can do something similar by arranging subplots in a grid, but I'm wondering if it's possible to do it automatically so that plots are wrapped onto the next 'line' when the space runs out? 回答1: This works

ipython notebook arrange plots horizontally

隐身守侯 提交于 2021-01-20 16:04:40
问题 Currently, when creating two consecutive plots in an ipython notebook, they are displayed one below the other: I'm wondering if there's any way to have them displayed in rows until the space runs out in the window. So for the first two plots, the output would look like this: I realize that I can do something similar by arranging subplots in a grid, but I'm wondering if it's possible to do it automatically so that plots are wrapped onto the next 'line' when the space runs out? 回答1: This works

How to put text outside python plots?

北城以北 提交于 2021-01-20 15:52:45
问题 I am plotting two time series and computing varies indices for them. How to write these indices for these plots outside the plot using annotation or text in python? Below is my code import matplotlib.pyplot as plt obs_graph=plt.plot(obs_df['cms'], '-r', label='Observed') plt.legend(loc='best') plt.hold(True) sim_graph=plt.plot(sim_df['cms'], '-g', label="Simulated") plt.legend(loc='best') plt.ylabel('Daily Discharge (m^3/s)') plt.xlabel('Year') plt.title('Observed vs Simulated Daily Discharge

Rotate xtick labels in seaborn boxplot?

倖福魔咒の 提交于 2021-01-20 14:54:22
问题 I have a question that is basically the same as a question back from 2014 (see here). However, my script still throws an error. Here is what I do: I have a pandas dataframe with a few columns. I plot a simple boxplot comparison. g = sns.boxplot(x='categories', y='oxygen', hue='target', data=df) g.set_xticklabels(rotation=30) The graph looks like this: I'd like to rotate the x-labels by 30 degrees. Hence I use g.set_xticklabels(rotation=30) . However, I get the following error: set_xticklabels