Ich habe ein Diagramm, in Python färben ich mit matplotlib mit dem folgenden Code vorgenommen haben:Wie matplotlib Graph mit Farbverlauf
def to_percent(y, position):
s = str(250 * y)
if matplotlib.rcParams['text.usetex'] is True:
return s + r'$\%$'
else:
return s + '%'
distance = df['Distance']
perctile = np.percentile(distance, 90) # claculates 90th percentile
bins = np.arange(0,perctile,2.5) # creates list increasing by 2.5 to 90th percentile
plt.hist(distance, bins = bins, normed=True)
formatter = FuncFormatter(to_percent) #changes y axis to percent
plt.gca().yaxis.set_major_formatter(formatter)
plt.axis([0, perctile, 0, 0.10]) #Defines the axis' by the 90th percentile and 10%Relative frequency
plt.xlabel('Length of Trip (Km)')
plt.title('Relative Frequency of Trip Distances')
plt.grid(True)
plt.show()
Was wissen ich möchte ist, Es ist möglich, die Balken mit Farbverlauf statt Blockfarbe zu färben, wie in diesem Bild von Excel.
habe ich finden kann, um keine Informationen zu diesem Thema nicht.
Statt Aufruf 'hist' Sie' numpy.histogram' verwenden könnte und Plotten mit 'bar'. Dann würde [Beispiel aus der Dokumentation] (http://matplotlib.org/examples/pylab_examples/gradient_bar.html) gelten. – wflynny
Mögliches Duplikat von [Wie füllen Sie Matplotlib-Balken mit einem Farbverlauf?] (Http://stackoverflow.com/questions/38830250/how-to-fill-matplotlib-bars-with-a-gradient) – wflynny